-
Notifications
You must be signed in to change notification settings - Fork 99
Add agent_policy_id and policy_revision_idx to checkin request #5501
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
Add agent_policy_id and policy_revision_idx to checkin request #5501
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
3c342b8
to
f0dcf41
Compare
Integration or E2E tests can be added after elastic/elasticsearch#134517 has been merged and a snapshot with the changes is available. |
Allow the agents to add their currently running policy_id and revision_idx attributes to the checkin request bodies. These attributes, if included and different from the agent doc will be used when updating the agent doc in the pre-poll checkin. If the agent's policy id does not match the expected policy id from the server a reassign is detected and a new policy change action will be sent. If the checkin ID is greater than what was previously recorded or the policy id changes from what was previously recoreded, then the api keys will be managed.
f0dcf41
to
9aa2ba2
Compare
Handle the scenario when the agent checks in with a revision_idx value that is greater than the latest available policy in ES. Add E2E tests when using policy_id and revision_idx values in checkin.
9aa2ba2
to
557ffd0
Compare
b59e45c
to
a5c7f64
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the fix for the revision being higher. Looks good.
What is the problem this PR solves?
Agent policy details (id + revision) may go out of sync with what fleet-server records.
This occurs when a VM running and agent with policy
X
on revisionN
is restored to an earlier time when it was runningX N-1
, or even a different policy. It can also occur if the ES cluster is restored to an earlier snapshot where the agent will be running policy N+1.How does this PR solve the problem?
Allow the agents to add their currently running policy_id and
revision_idx attributes to the checkin request bodies. These attributes,
if included and different from the agent doc will be used when updating
the agent doc in the pre-poll checkin. If the agent's policy id does not
match the expected policy id from the server a reassign is detected and
a new policy change action will be sent. If the revision differs a policy
change action will also be sent. If an agent checks in with a different
policy/revision the api keys may be managed. Add a feature flag to disable
this behaviour and only use Acks + the fleet-agents doc as the source of
truth.
How to test this PR locally
Added testing in the e2e API test suite, run:
Design Checklist
Checklist
I have made corresponding changes to the documentation./changelog/fragments
using the changelog toolRelated issues