Skip to content

fix: missing reload events#3831

Merged
didier-wenzek merged 3 commits intothin-edge:mainfrom
didier-wenzek:fix/missing-reload-events
Oct 28, 2025
Merged

fix: missing reload events#3831
didier-wenzek merged 3 commits intothin-edge:mainfrom
didier-wenzek:fix/missing-reload-events

Conversation

@didier-wenzek
Copy link
Copy Markdown
Contributor

Proposed changes

Applying this suggestion #3805 (review)
highlighted two bugs, previously masked because all the tests were pre-loaded and sharing timers.

  • Isolate flow system tests, installating a flow per test
  • Fix timer of periodic sources
  • Fix flow reloading on inotify events

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


Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s. You can activate automatic signing by running just prepare-dev once)
  • I ran just format as mentioned in CODING_GUIDELINES
  • I used just check 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

@didier-wenzek didier-wenzek added the skip-release-notes Don't include the ticket in the auto generated release notes label Oct 24, 2025
@didier-wenzek didier-wenzek requested review from a team and rina23q as code owners October 24, 2025 18:10
Comment on lines +141 to 142
Install Flow append-to-file.toml
Execute Command for i in $(seq 3); do tedge mqtt pub seq/events "$i"; done
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This might still be flacky, even if okay after 10 runs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To avoid that flakiness, we need to wait till the file is modified before doing the grep, right?

Came across this inotifywait tool that makes it easier to do that with a simple command:

inotifywait --timeout 1 --event modify

But it's not available out-of-the-box. The inotify-tools package must be installed first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We need to wait for the flow to be fully loaded before sending MQTT messages to the flow input topic.

For that we need to improve tedge flow so status or stats messages are published over MQTT when a flow is loaded.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to wait for the flow to be fully loaded before sending MQTT messages to the flow input topic.

Aah okay. I thought the flakiness was because we're doing the grep on the output file immediately after publishing the message, without giving enough time for the mapper to process that input and write to the file.

For that we need to improve tedge flow so status or stats messages are published over MQTT when a flow is loaded.

Yeah, that'd fix both.

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/extensions/tedge_flows/src/runtime.rs 72.72% 3 Missing ⚠️
crates/extensions/tedge_flows/src/actor.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 24, 2025

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
723 0 3 723 100 2h12m3.830273999s

Comment on lines +141 to 142
Install Flow append-to-file.toml
Execute Command for i in $(seq 3); do tedge mqtt pub seq/events "$i"; done
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To avoid that flakiness, we need to wait till the file is modified before doing the grep, right?

Came across this inotifywait tool that makes it easier to do that with a simple command:

inotifywait --timeout 1 --event modify

But it's not available out-of-the-box. The inotify-tools package must be installed first.

The test "Appending messages to a file" is flaky,
but not only because the flow is exercised too soon
(i.e. publishing events just after moving the flow definition under the
tedge flow directory). But also, because of the following bugs:

- The timer of periodic sources are not properly registered.
  This error was masked by other flows registering step timers.
- The inotify messages are not always leading to a proper reload.
  The root cause being that depending of the command used to deploy a
  flow, inotify might wrongly notify that a flow has been modified and
  not added.

Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
The flow actor was trying to be smart, but actually too smart.
It was reloading a flow on an modified event only if the file was
actually loading. However, inotify might wrongly notify an update for a
new file.

Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
@didier-wenzek didier-wenzek force-pushed the fix/missing-reload-events branch from 1ccbc2f to bcbb61e Compare October 28, 2025 07:18
@didier-wenzek didier-wenzek added this pull request to the merge queue Oct 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 28, 2025
@didier-wenzek didier-wenzek added this pull request to the merge queue Oct 28, 2025
Merged via the queue into thin-edge:main with commit 2952453 Oct 28, 2025
34 checks passed
@didier-wenzek didier-wenzek mentioned this pull request Oct 31, 2025
13 tasks
@didier-wenzek didier-wenzek deleted the fix/missing-reload-events branch November 20, 2025 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-release-notes Don't include the ticket in the auto generated release notes theme:flows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants