Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package google-guest-oslogin for openSUSE:Factory checked in at 2023-11-02 20:22:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/google-guest-oslogin (Old) and /work/SRC/openSUSE:Factory/.google-guest-oslogin.new.17445 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "google-guest-oslogin" Thu Nov 2 20:22:44 2023 rev:23 rq:1122665 version:20231101.00 Changes: -------- --- /work/SRC/openSUSE:Factory/google-guest-oslogin/google-guest-oslogin.changes 2023-10-20 23:21:13.208268325 +0200 +++ /work/SRC/openSUSE:Factory/.google-guest-oslogin.new.17445/google-guest-oslogin.changes 2023-11-02 20:23:11.555638940 +0100 @@ -1,0 +2,6 @@ +Thu Nov 2 09:47:31 UTC 2023 - John Paul Adrian Glaubitz <adrian.glaub...@suse.com> + +- Update to version 20231101.00 (bsc#1216548, bsc#1216750) + * Fix HTTP calls retry logic (#117) + +------------------------------------------------------------------- Old: ---- google-guest-oslogin-20231004.00.tar.gz New: ---- google-guest-oslogin-20231101.00.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ google-guest-oslogin.spec ++++++ --- /var/tmp/diff_new_pack.MZLEYe/_old 2023-11-02 20:23:12.035656603 +0100 +++ /var/tmp/diff_new_pack.MZLEYe/_new 2023-11-02 20:23:12.039656750 +0100 @@ -19,7 +19,7 @@ %{!?_pam_moduledir: %define _pam_moduledir %{_pamdir}} Name: google-guest-oslogin -Version: 20231004.00 +Version: 20231101.00 Release: 0 Summary: Google Cloud Guest OS Login License: Apache-2.0 ++++++ google-guest-oslogin-20231004.00.tar.gz -> google-guest-oslogin-20231101.00.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-oslogin-20231004.00/src/include/oslogin_utils.h new/guest-oslogin-20231101.00/src/include/oslogin_utils.h --- old/guest-oslogin-20231004.00/src/include/oslogin_utils.h 2023-10-05 00:45:15.000000000 +0200 +++ new/guest-oslogin-20231101.00/src/include/oslogin_utils.h 2023-10-10 02:26:19.000000000 +0200 @@ -186,6 +186,9 @@ bool HttpGet(const string& url, string* response, long* http_code); bool HttpPost(const string& url, const string& data, string* response, long* http_code); +// Based on known MDS status codes returns whether the HTTP request +// should be retried or not. +bool ShouldRetry(long http_code); // Returns whether user_name is a valid OsLogin user name. bool ValidateUserName(const string& user_name); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-oslogin-20231004.00/src/oslogin_utils.cc new/guest-oslogin-20231101.00/src/oslogin_utils.cc --- old/guest-oslogin-20231004.00/src/oslogin_utils.cc 2023-10-05 00:45:15.000000000 +0200 +++ new/guest-oslogin-20231101.00/src/oslogin_utils.cc 2023-10-10 02:26:19.000000000 +0200 @@ -48,7 +48,10 @@ using std::string; // Maximum number of retries for HTTP requests. -const int kMaxRetries = 1; +const int kMaxRetries = 3; + +// Backoff duration 1 sec between retries. +const int kBackoffDuration = 1; // Regex for validating user names. static const char kUserNameRegex[] = "^[a-zA-Z0-9._][a-zA-Z0-9._-]{0,31}$"; @@ -392,6 +395,18 @@ return 0; } +bool ShouldRetry(long http_code) { + if (http_code == 200) { + // Request returned successfully, no need to retry. + return false; + } + if (http_code == 404) { + // Metadata key does not exist, no point of retrying. + return false; + } + return true; +} + bool HttpDo(const string& url, const string& data, string* response, long* http_code) { if (response == NULL || http_code == NULL) { return false; @@ -410,6 +425,10 @@ return false; } do { + // Apply backoff strategy before retrying. + if (retry_count > 0) { + sleep(kBackoffDuration); + } response_stream.str(""); response_stream.clear(); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_list); @@ -428,7 +447,7 @@ return false; } curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, http_code); - } while (retry_count++ < kMaxRetries && *http_code == 500); + } while (retry_count++ < kMaxRetries && ShouldRetry(*http_code)); curl_slist_free_all(header_list); } *response = response_stream.str(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-oslogin-20231004.00/test/oslogin_utils_test.cc new/guest-oslogin-20231101.00/test/oslogin_utils_test.cc --- old/guest-oslogin-20231004.00/test/oslogin_utils_test.cc 2023-10-05 00:45:15.000000000 +0200 +++ new/guest-oslogin-20231101.00/test/oslogin_utils_test.cc 2023-10-10 02:26:19.000000000 +0200 @@ -460,6 +460,12 @@ ASSERT_EQ(errnop, 0); } +TEST(CurlClient, RetryLogic) { + ASSERT_FALSE(ShouldRetry(200)); + ASSERT_FALSE(ShouldRetry(404)); + ASSERT_TRUE(ShouldRetry(429)); +} + TEST(ParseJsonEmailTest, SuccessfullyParsesEmail) { string test_user = "{\"loginProfiles\":[{\"name\":\"f...@example.com\",\"posixAccounts\":["