From e09c4618e70bebe235f59f30c16ae30cca498d15 Mon Sep 17 00:00:00 2001 From: Lucas Manuel Rodriguez Date: Sat, 11 May 2024 09:11:32 -0300 Subject: [PATCH] Add verbose logging when distributed requests fail and retry (#8321) --- osquery/remote/utility.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/osquery/remote/utility.h b/osquery/remote/utility.h index 5df6eb83d15..8ca323a2a1f 100644 --- a/osquery/remote/utility.h +++ b/osquery/remote/utility.h @@ -17,10 +17,11 @@ #include // clang-format on -#include #include -#include #include +#include +#include +#include #include #include @@ -269,15 +270,24 @@ class TLSRequestHelper : private boost::noncopyable { if (s.ok()) { return s; } + + const auto& sleep_time_seconds = i * i; + const auto& errMessage = "HTTP(S) request failed: " + s.getMessage(); + if (i == attempts) { + VLOG(1) << errMessage << ", done retrying after " << i << " times"; break; + } else { + VLOG(1) << errMessage << ", retrying in " << sleep_time_seconds + << " seconds..."; } + for (auto& m : override_params_doc.GetObject()) { params.add(m.name.GetString(), m.value); } - should_shutdown = - waitTimeoutOrShutdown(std::chrono::milliseconds(i * i * 1000)); + should_shutdown = waitTimeoutOrShutdown( + std::chrono::milliseconds(sleep_time_seconds * 1000)); } return s; }