-
Notifications
You must be signed in to change notification settings - Fork 66
fix: Persist workflow definition of pending commands on start #3307
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: Persist workflow definition of pending commands on start #3307
Conversation
When the agent restarts and loads pending operations, these operations might not have been assign a workflow version. This is notably the case after a self update from a previous version of the agent that was oblivious of workflow versions. In such a case, the agent assumes the current user-defined version of the workflow is the version to be used for the pending command. The workflow definition is persisted in `workflows-in-use` directory and assigned to the command. Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Codecov ReportAttention: Patch coverage is Additional details and impacted files📢 Thoughts on this report? Let us know! |
Robot Results
|
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.
I'm a bit puzzled by some of what's going on with the APIs, but believe this functions correctly
if let Some(current_version) = self.workflows.use_current_version(&operation) { | ||
self.persist_workflow_definition(&operation, ¤t_version) | ||
.await; | ||
*command = command.clone().set_workflow_version(¤t_version); |
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.
I'm puzzled by this API where we seemingly are cloning command
just to mutate it and return it from set_workflow_version
?
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.
You can be!
Not only set_workflow_version
but all the updating methods of GenericCommandState
are consuming self
.
Fixing that would not be complicated, but I prefer to fix this bug asap.
match self.workflows.get_mut(&operation.as_str().into()) { | ||
Some(versions) => versions.use_current_version().cloned(), | ||
None => None, | ||
} |
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.
match self.workflows.get_mut(&operation.as_str().into()) { | |
Some(versions) => versions.use_current_version().cloned(), | |
None => None, | |
} | |
self.workflows.get_mut(&operation.as_str().into())?.use_current_version().cloned() |
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.
Good point. I will fixed that in a follow-up PR.
Proposed changes
When the agent restarts and loads pending operations, these operations might not have been assign a workflow version. This is notably the case after a self update from a previous version of the agent that was oblivious of workflow versions.
In such a case, the agent assumes the current user-defined version of the workflow is the version to be used for the pending command. The workflow definition is persisted in
workflows-in-use
directory and assigned to the command.Types of changes
Paste Link to the issue
#3305
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments