-
Notifications
You must be signed in to change notification settings - Fork 24
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 workload control loop #266
Comments
With introducing the config files mount for workload within #426 (Issue #393), the logic for cleaning up the In addition, the ControlInterface creation happens outside of the control loop, in the RuntimeFacade for create and resume and in the workload.rs for the update operation. This means the ControlInterface creation decoupled in time from the actual atomic and queued workload operations. This leads to the unsightly side effect that when doing cleanup of subfolders of the workload after the delete part of an update that it must be checked with conditionals "what the control loop is allowed to clean up". Because it might be the case that the control interface remains at the same location for an update and then cleaning up the whole workload folder leads to unwanted deletion of the control interface. The problem is that the control interface belongs actually to the atomic update "plan" within the control loop, because then the steps can be performed in the correct order to avoid the "cleanup checks". When refactoring the control loop, consider to move the creation of the control interface into the correct "create", "update" and "delete" plan within the control loop eliminating unnecessary checks afterwards. The rows signal the timeline.
To simplify the code, group together what belongs together and fix the order of the update plan itself:
Grouping thins belonging together reduces complexity and if a reader wants to see all the steps of the upate plan it is all in one place. |
In addition, @krucod3 suggested to let the functions return an error, so that it can be logged once in the match statement distinguishing between the workload commands. |
There are also state machine crates: https://docs.rs/rust-fsm/latest/rust_fsm/ that might help. Or we implement our own state machine to refactor this control loop. Also a behavior tree implementation might help, which is more efficient to define as a state machine: https://github.com/msakuta/rusty-behavior-tree-lite |
Description
The
agent/src/workload/workload_control_loop.rs
file has a little bit too much responsibilities. We can decouple more and simplify the unit tests here, when:ControlLoopState
variable contains the expected field values.Goals
The WorkloadControlLoop shall be decoupled from the concrete operations it executes and unit tests shall be simplified.
Final result
Summary
To be filled when the final solution is sketched.
Tasks
The text was updated successfully, but these errors were encountered: