Jonathan Keane created ARROW-15149:
--------------------------------------

             Summary: [R] [CI] Ensure that RSPM is responsive when using it
                 Key: ARROW-15149
                 URL: https://issues.apache.org/jira/browse/ARROW-15149
             Project: Apache Arrow
          Issue Type: Improvement
            Reporter: Jonathan Keane


This might not be necessary in the long run, but we've had a few days of RSPM 
being intermittently accessible[1]. We could add a check [when we construct the 
RSPM url|https://github.com/apache/arrow/blob/master/ci/etc/rprofile] that 
checks the URL we're using for http response and then sets the url to NULL if 
it errors. Something like:

{code}
  # Check the url from RSPM first
  .ensure_rspm_works <- function(url) {
    if (is.null(url)) {
      return(NULL)
    }

    # check for curl, if it doens't exist, return the URL anyway
    if (system("command -v curl") == 0) {
      # curl to get the http response
      code <- tryCatch({
      system(
        paste0(
          'curl -s -o /dev/null -w "%{http_code}" ',
          paste0(url, "/cran/latest/src/contrib/PACKAGES")
        ),
        intern = TRUE
      )
      # if this errors, assume the URL works and the error was in curl
      }, error = function(e) "200")

      # if the response code is in the error range, then return null.
      if (as.numeric(code) >= 400) {
        return(NULL)
      }
    }

    url
  }
{code}

and then wrap {{.pick_cran()}} with this function at 
https://github.com/apache/arrow/blob/6e20c6b9d7131af41f2e979529d06e507c731373/ci/etc/rprofile#L46

[1] Here's one PR where that happened for a few days: 
https://github.com/apache/arrow/pull/11965




--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to