-
Notifications
You must be signed in to change notification settings - Fork 146
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
Refactor state store #4253
Refactor state store #4253
Conversation
type state struct { | ||
ActionSerializer actionSerializer `json:"action,omitempty"` | ||
AckToken string `json:"ack_token,omitempty"` | ||
Queue fleetapi.Actions `json:"action_queue,omitempty"` |
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.
Add a field to version the store
This pull request is now in conflicts. Could you fix it? 🙏
|
b6811f3
to
708f615
Compare
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
This pull request is now in conflicts. Could you fix it? 🙏
|
rename its methods to be more meaningful and change the signature to reflect what actually happens.
5eb5e3b
to
cc98d01
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.
Code looks fine except for some typos or nitpicks...
I wonder if we should go deeper with the refactor and have an ordered queue of actions with some retention mechanism (keep all the received but not yet run/unacked actions, keep at least 2 PolicyChangeActions, keep the UnEnroll action) in order to feed the dispatcher the necessary actions.
I realize that it is a big change but I think it would give us more flexibility and reliability as we have one more checkpoint between receiving an action from fleet and trying to run it.
Thoughts ?
Quality Gate passedThe SonarQube Quality Gate passed, but some issues were introduced. 2 New issues |
} | ||
if st.Version != Version { | ||
return nil, fmt.Errorf( | ||
"invalid state store version, got %q isntead of %s", |
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.
"invalid state store version, got %q isntead of %s", | |
"invalid state store version, got %q instead of %q", |
a7b7bca
into
elastic:bugfix/3912-borken-stat-store
Fix action store -> state store migration tests (#4235) * use golden file for store migration test * remove withFile function * migrate take in a storage.Store instead of the storage's path. It's needed so we can set the encrypted store vault's path refactor state store (#4253) It modifies the state store API to match the current needs. update action model to match fleet-server schema (#4240) * simplify fleetapi.Actions.UnmarshalJSON * add test to ensure the state store is correctly loaded from disk * skip state store migration tests, they will be fixes on a follow-up PR as part of #3912 add migrations for action and state stores (#4305)
What does this PR do?
It refactors the state store to:
Version
field to the state store stateWhy is it important?
So the state store API reflects its actual usage and purpose.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added an entry in./changelog/fragments
using the changelog tool[ ] I have added an integration test or an E2E testRelated issues
error parsing version ""
if agent restarts before the upgrade starts #3912Questions to ask yourself