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
|
jarhodes314
left a comment
There was a problem hiding this comment.
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.
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.
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.
| 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.
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-usedirectory and assigned to the command.Types of changes
Paste Link to the issue
#3305
Checklist
cargo fmtas mentioned in CODING_GUIDELINEScargo clippyas mentioned in CODING_GUIDELINESFurther comments