fix: Unload flow when removing script instead of removing#4036
fix: Unload flow when removing script instead of removing#4036Bravo555 wants to merge 3 commits intothin-edge:mainfrom
Conversation
…ning Signed-off-by: reubenmiller <reuben.d.miller@gmail.com>
Unload flow when one of its scripts is removed instead of removing. Removing sometimes made flow not start back up when script was restored. Instead, unloading keeps it in an unloaded list that is checked when relevant script is reloaded. Signed-off-by: Marcel Guzik <marcel.guzik@cumulocity.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Robot Results
|
|
I was testing with the PoC sm-plugin for a flow, and upgrading an existing flow results in the following log entries: The WARN level for the flow removal is overkill (INFO would be more appropriate), however interesting enough, #4031, only yields a single "Reloading flow" log entry on updates (which is preferable from a users perspective given an update for a user should trigger a reload and the "remove" operation is unnecessary (again from the users point of view). |
Indeed we were removing the flow first and the script after, in order to not trigger that warning, but it would be better to adjust it to not appear if removing a script for a flow that's unloaded. |
Signed-off-by: Marcel Guzik <marcel.guzik@cumulocity.com>
|
Removed the extra warning and added one more test case for moving a script. |
I just tested the update version and there is a lot of noise when updating a single flow (via the poc sm-plugin). The following entries show with 1 software update (which replaces the flow.toml and lib/main.js)...6 log entries in total. In comparison to the other PR #4031, which produced the following entries (but yes also not perfect). The main point is that the first set of log entries are confusing for the user and show that we're being very inefficient when processing flows as we're removing, loading, unloading, loading...so this just makes the system harder to reason with, and I would assume it would also be consuming additional resources doing all of these things. |
Indeed, in #4031 logs are more concise, because some events are explicitly ignored, with the motivation that I think is not entirely correct (can't observe Then I think we can go forward with #4031, but with the addition of |
|
Selected alternative #4031 to be merged. |
Proposed changes
Unload flow when one of its scripts is removed instead of removing. Removing sometimes made flow not start back up when script was restored. Instead, unloading keeps it in an unloaded list that is checked when relevant script is reloaded.
This is an alternative fix to #4031 using the same test suite, but addresses flow not being reloaded without assuming stale, out-of-order
FileDeletedmessages, which I could not reproduce. Instead my hypothesis is that the flow wasn't being reloaded becausereload_scriptlooks at unloaded flows list to restart flows, but the flow wasn't in that list because it was removed instead of just unloaded.Types of changes
Paste Link to the issue
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments