-
Notifications
You must be signed in to change notification settings - Fork 154
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 state store SetAction panic #5438
Conversation
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
7facba4
to
4f67b2a
Compare
The state store SetAction did not correctly cover the case where a nil action is passed as parameter. The unenroll handler might pass a nil action if the unenroll is a auto-unenroll, that means, it does not come from fleet Also the unenroll handler does checks for a nil state store anymore, it assumes it's valid just as it does for all other dependencies.
e9ddfec
to
9cd34bc
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.
Left a comment about the log level used to signal the error in action store when trying to save a nil action.
Moreover if the unenroll action is generated internally, shouldn't we fix that too somehow ?
@@ -92,12 +92,10 @@ func (h *Unenroll) Handle(ctx context.Context, a fleetapi.Action, acker acker.Ac | |||
unenrollPolicy := newPolicyChange(ctx, config.New(), a, acker, true) | |||
h.ch <- unenrollPolicy | |||
|
|||
if h.stateStore != nil { |
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.
It seems to have been used just to test the handler without a state store, which is one of the reasons the panic was not caught
…stic-agent into 5434-fix-state-store-panic
|
* fix state store SetAction panic The state store SetAction did not correctly cover the case where a nil action is passed as parameter. The unenroll handler might pass a nil action if the unenroll is a auto-unenroll, that means, it does not come from fleet Also the unenroll handler does checks for a nil state store anymore, it assumes it's valid just as it does for all other dependencies. (cherry picked from commit c113a26)
* fix state store SetAction panic The state store SetAction did not correctly cover the case where a nil action is passed as parameter. The unenroll handler might pass a nil action if the unenroll is a auto-unenroll, that means, it does not come from fleet Also the unenroll handler does checks for a nil state store anymore, it assumes it's valid just as it does for all other dependencies. (cherry picked from commit c113a26)
* fix state store SetAction panic The state store SetAction did not correctly cover the case where a nil action is passed as parameter. The unenroll handler might pass a nil action if the unenroll is a auto-unenroll, that means, it does not come from fleet Also the unenroll handler does checks for a nil state store anymore, it assumes it's valid just as it does for all other dependencies. (cherry picked from commit c113a26) Co-authored-by: Anderson Queiroz <anderson.queiroz@elastic.co>
The state store SetAction did not correctly cover the case where a nil action is passed as parameter. The unenroll handler might pass a nil action if the unenroll is a auto-unenroll, that means, it does not come from fleet
Also the unenroll handler does checks for a nil state store anymore, it assumes it's valid just as it does for all other dependencies
What does this PR do?
Fixes the state store panicking when receiving an
nil
actionWhy is it important?
Panic is bad, the agent should not panic
Also the unenroll handler sets an
nil
action on the state store if the unenroll is self-inflicted. The agent auto unenroll after the 7th authentication failure against fleet.Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files./changelog/fragments
using the changelog tool[ ] I have added an integration test or an E2E testDisruptive User Impact
How to test this PR locally
run the tests added on the PR, all work
keep the tests, rever the changes on the state store, they will panic
Related issues
nil
action #5434Questions to ask yourself