Skip to content

Conversation

didier-wenzek
Copy link
Contributor

@didier-wenzek didier-wenzek commented Dec 19, 2024

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

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

#3305

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

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>
@didier-wenzek didier-wenzek added bug Something isn't working theme:workflows Theme: Workflow engine topics labels Dec 19, 2024
Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ore/tedge_agent/src/operation_workflows/persist.rs 0.00% 14 Missing ⚠️
crates/core/tedge_api/src/workflow/supervisor.rs 0.00% 6 Missing ⚠️
.../core/tedge_agent/src/operation_workflows/actor.rs 0.00% 1 Missing ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

Copy link
Contributor

github-actions bot commented Dec 19, 2024

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
551 0 2 551 100 1h29m34.513268999s

Copy link
Contributor

@jarhodes314 jarhodes314 left a 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, &current_version)
.await;
*command = command.clone().set_workflow_version(&current_version);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Comment on lines +139 to +142
match self.workflows.get_mut(&operation.as_str().into()) {
Some(versions) => versions.use_current_version().cloned(),
None => None,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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()

Copy link
Contributor Author

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.

@reubenmiller reubenmiller added this pull request to the merge queue Dec 19, 2024
Merged via the queue into thin-edge:main with commit 99b38fa Dec 19, 2024
33 checks passed
@didier-wenzek didier-wenzek deleted the fix/agent-self-update-with-unversionned-pending-commands branch December 19, 2024 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working theme:workflows Theme: Workflow engine topics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants