Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Resend the inventory when the device has reauthenticated #1714

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ error::Error HTTPClient::AsyncCall(
});
return;
}
reauthenticated_ = true;
};

return authenticator_.WithToken(
Expand Down
9 changes: 9 additions & 0 deletions src/api/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,19 @@ class HTTPClient : public Client {
authenticator_.ExpireToken();
}

bool HasReauthenticated() {
return reauthenticated_;
}

void SetReauthenticated(bool reauthenticated) {
reauthenticated_ = reauthenticated;
}

private:
events::EventLoop &event_loop_;
http::Client http_client_;
auth::Authenticator &authenticator_;
bool reauthenticated_ {false};
};

} // namespace api
Expand Down
7 changes: 6 additions & 1 deletion src/mender-update/daemon/states.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ void PollForDeploymentState::OnEnter(Context &ctx, sm::EventPoster<StateEvent> &
} else if (!response.value()) {
log::Info("No update available");
poster.PostEvent(StateEvent::NothingToDo);

if (ctx.http_client.HasReauthenticated()) {
log::Debug("Client has reauthenticated, clear inventory data cache");
ctx.inventory_client->ClearDataCache();
ctx.has_submitted_inventory = false;
ctx.http_client.SetReauthenticated(false);
}
if (not ctx.has_submitted_inventory) {
// If we have not submitted inventory successfully at least
// once, schedule this after receiving a successful response
Expand Down