Skip to content

Commit

Permalink
Add verbose logging when distributed requests fail and retry (osquery…
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmrod authored May 11, 2024
1 parent a577830 commit e09c461
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions osquery/remote/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
#include <osquery/remote/transports/tls.h>
// clang-format on

#include <osquery/remote/enroll/enroll.h>
#include <osquery/core/flags.h>
#include <osquery/core/system.h>
#include <osquery/core/shutdown.h>
#include <osquery/core/system.h>
#include <osquery/logger/logger.h>
#include <osquery/remote/enroll/enroll.h>

#include <osquery/process/process.h>
#include <osquery/remote/requests.h>
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e09c461

Please sign in to comment.