From a5a92ffa9888de15d21f90b690f7d29501013029 Mon Sep 17 00:00:00 2001 From: Joseph Marrero Date: Wed, 4 Oct 2023 12:55:19 -0400 Subject: [PATCH] ostree-repo-pull: add options to configure retry behavior This introduces the retry-all-network-errors option which is enabled by default. This is a behavior change as now ostree will retry on requests that fail except when they fail with NOT_FOUND. It also introduces the options low-speed-limit-bytes and low-speed-time-seconds these map to CURL options only at the moment. Which have defaults set following librepo: https://github.com/rpm-software-management/librepo/blob/7c9af219abd49f8961542b7622fc82cfdaa572e3/librepo/handle.h#L90 https://github.com/rpm-software-management/librepo/blob/7c9af219abd49f8961542b7622fc82cfdaa572e3/librepo/handle.h#L96 Currently this changes only apply when using libcurl. --- src/libostree/ostree-repo-pull.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index 13403d859b..d7f3904f6b 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -3000,11 +3000,9 @@ _ostree_repo_remote_new_fetcher (OstreeRepo *self, const char *remote_name, gboo } } - _ostree_fetcher_set_low_speed_limit (fetcher, (low_speed_limit) ? low_speed_limit - : OPT_LOWSPEEDLIMIT_DEFAULT); - _ostree_fetcher_set_low_speed_time (fetcher, - (low_speed_time) ? low_speed_time : OPT_LOWSPEEDTIME_DEFAULT); - _ostree_fetcher_set_retry_all (fetcher, (retry_all) ? retry_all : OPT_RETRYALL_DEFAULT); + _ostree_fetcher_set_low_speed_limit (fetcher, low_speed_limit); + _ostree_fetcher_set_low_speed_time (fetcher, low_speed_time); + _ostree_fetcher_set_retry_all (fetcher, retry_all); { g_autofree char *tls_ca_path = NULL; @@ -3524,6 +3522,9 @@ ostree_repo_pull_with_options (OstreeRepo *self, const char *remote_name_or_base gboolean opt_gpg_verify_summary_set = FALSE; gboolean opt_collection_refs_set = FALSE; gboolean opt_n_network_retries_set = FALSE; + gboolean opt_low_speed_limit_set = FALSE; + gboolean opt_low_speed_time_set = FALSE; + gboolean opt_retry_all_set = FALSE; gboolean opt_ref_keyring_map_set = FALSE; gboolean disable_sign_verify = FALSE; gboolean disable_sign_verify_summary = FALSE; @@ -3588,9 +3589,12 @@ ostree_repo_pull_with_options (OstreeRepo *self, const char *remote_name_or_base &pull_data->timestamp_check_from_rev); (void)g_variant_lookup (options, "max-metadata-size", "t", &pull_data->max_metadata_size); (void)g_variant_lookup (options, "append-user-agent", "s", &pull_data->append_user_agent); - (void)g_variant_lookup (options, "low-speed-limit-bytes", "u", &pull_data->low_speed_limit); - (void)g_variant_lookup (options, "low-speed-time-seconds", "u", &pull_data->low_speed_time); - (void)g_variant_lookup (options, "retry-all-network-errors", "b", &pull_data->retry_all); + opt_low_speed_limit_set + = g_variant_lookup (options, "low-speed-limit-bytes", "u", &pull_data->low_speed_limit); + opt_low_speed_time_set + = g_variant_lookup (options, "low-speed-time-seconds", "u", &pull_data->low_speed_time); + opt_retry_all_set + = g_variant_lookup (options, "retry-all-network-errors", "b", &pull_data->retry_all); opt_n_network_retries_set = g_variant_lookup (options, "n-network-retries", "u", &pull_data->n_network_retries); opt_ref_keyring_map_set @@ -3665,6 +3669,12 @@ ostree_repo_pull_with_options (OstreeRepo *self, const char *remote_name_or_base if (!opt_n_network_retries_set) pull_data->n_network_retries = DEFAULT_N_NETWORK_RETRIES; + if (!opt_low_speed_limit_set) + pull_data->low_speed_limit = OPT_LOWSPEEDLIMIT_DEFAULT; + if (!opt_low_speed_time_set) + pull_data->low_speed_time = OPT_LOWSPEEDTIME_DEFAULT; + if (!opt_retry_all_set) + pull_data->retry_all = OPT_RETRYALL_DEFAULT; pull_data->repo = self; pull_data->progress = progress;