Skip to content

Commit

Permalink
ostree-fetcher-curl: add ENV VAR to retry requests
Browse files Browse the repository at this point in the history
This introduces the OSTREE_CURL_IO_RETRY environment
variable that enables retries on requests that fail
except when they fail with NOT_FOUND. We accomplish
this by returning G_IO_ERROR_TIMED_OUT instead of
G_IO_ERROR_FAILED as error code.
  • Loading branch information
jmarrero committed Sep 13, 2023
1 parent 5fe050f commit 3fe6101
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/libostree/ostree-fetcher-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ check_multi_info (OstreeFetcher *fetcher)
const char *eff_url;
gboolean is_file;
gboolean continued_request = FALSE;
gboolean should_retry;

if (msg->msg != CURLMSG_DONE)
continue;
Expand All @@ -330,7 +331,14 @@ check_multi_info (OstreeFetcher *fetcher)
}
else
{
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
/* When it is not a file and the OSTREE_CURL_IO_RETRY
* environment variable is set, we want to retry the request.
* We accomplish that by using G_IO_ERROR_TIMED_OUT.
*/
should_retry = g_getenv ("OSTREE_CURL_IO_RETRY") != NULL;
int g_io_error_code
= (is_file || !should_retry) ? G_IO_ERROR_FAILED : G_IO_ERROR_TIMED_OUT;
g_task_return_new_error (task, G_IO_ERROR, g_io_error_code,
"While fetching %s: [%u] %s", eff_url, curlres,
curl_easy_strerror (curlres));
_ostree_fetcher_journal_failure (req->fetcher->remote_name, eff_url,
Expand Down

0 comments on commit 3fe6101

Please sign in to comment.