Skip to content

Commit

Permalink
fix: retry polling on all errors
Browse files Browse the repository at this point in the history
When implementing the backoff for errors when polling for deployment or
submitting inventory, we added an exception for unauthorized errors.
After looking at how it was done in Mender Client 3, we discovered
that such an exception was not present there, and that the backoff
should be triggered for all types of errors.

Changelog: All errors on attempts to communicate with the server
are retried with an exponential backoff. This aligns the behavior
of the state machine with Mender Client 3.

Ticket: MEN-7938

Signed-off-by: Daniel Skinstad Drabitzius <[email protected]>
  • Loading branch information
danielskinstad committed Jan 22, 2025
1 parent 75c3772 commit 45f88a1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/mender-update/daemon/states.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,8 @@ void SubmitInventoryState::DoSubmitInventory(Context &ctx, sm::EventPoster<State
auto handler = [this, &ctx, &poster](error::Error err) {
if (err != error::NoError) {
log::Error("Failed to submit inventory: " + err.String());
if (err.code != auth::MakeError(auth::UnauthorizedError, "").code) {
// Replace the inventory poll timer with a backoff
HandlePollingError(ctx, poster);
}
// Replace the inventory poll timer with a backoff
HandlePollingError(ctx, poster);
poster.PostEvent(StateEvent::Failure);
return;
}
Expand Down Expand Up @@ -261,10 +259,8 @@ void PollForDeploymentState::OnEnter(Context &ctx, sm::EventPoster<StateEvent> &
[this, &ctx, &poster](mender::update::deployments::CheckUpdatesAPIResponse response) {
if (!response) {
log::Error("Error while polling for deployment: " + response.error().String());
if (response.error().code != auth::MakeError(auth::UnauthorizedError, "").code) {
// Replace the update poll timer with a backoff
HandlePollingError(ctx, poster);
}
// Replace the update poll timer with a backoff
HandlePollingError(ctx, poster);
poster.PostEvent(StateEvent::Failure);
return;
} else if (!response.value()) {
Expand Down

0 comments on commit 45f88a1

Please sign in to comment.