-
Notifications
You must be signed in to change notification settings - Fork 617
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
Model transformer: model reconciliation for agent upgrades #3878
Conversation
7392af8
to
a33b844
Compare
0145053
to
219a63b
Compare
219a63b
to
cc0437a
Compare
3c6b9e6
to
b8cd118
Compare
Thanks a lot for contributing this transformation logic to unblock our future & ongoing works!
|
Thanks for the input. I think one thing I am not making clear in the description is the transformation functions and models introduced here are just placeholder and will always be skipped with current implementation. Therefore I didn't do 2/3/5. I will do 1 but maybe after this one is pushed, and will do 4! |
238b15e
to
81eef5d
Compare
81eef5d
to
2951b2a
Compare
Summary
This adds the functionality of model transformer to agent, which detects model incompatibility between the running agent version and the data we persists in boltDB.
Note 1: the transformation functions and models introduced in this PR is example/template change and will never be executed!
Note 2: this is only for agent upgrades. Support for agent downgrades is not in scope.
A version check (using
version.Version
in "running" agent andagent-version
in boltDB metadata bucket) is performed before we load boltDB data to agent state. If a version difference is detected, the loaded json will go through a series of transformation functions, apply those applicable transformation functions, then reach a state that it is compatible with current running agent version then loaded into agent state.Here, "applicable" transformation functions means that the model is older than the version we introduce a new model (and as a result, anew transformation function). We check the model version against transformation function's threshold version, if it is older (smaller version number), it will go through the transformation function.
Implementation details
transformer
inecs-agent
moduletransformer
stores transformation functions registered by agent (during data client initialization), and expose method to actually execute transformation functions in a loop (through a slice of function closure).model
andtranstf
inagent
modulemodel
contains different models we introduced that are mutually incompatible.transtf
contains corresponding transformation functions we introduced with models.I also included a template task transformation function which will never get executed now.
Testing
New tests cover the changes: Yes
New unit tests are added. Manual testing done: manually verified following:
Log from manual testing
BoltDB stored agent version is 1.75.0
transformation functions registered and executed, since 1.75.0 < 1.75.2 and a breaking change introduced.
transformation functions registered but not executed, since it's 1.75.2 = 1.75.2, and models have been updated since last load.
Description for the changelog
Model transformer: model reconciliation for agent upgrades
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.