fix(sd_notify): send Stopping on shutdown and use timeout/2 for watchdog interval - #433
Conversation
…ndency Follows the project's convention of minimizing pulled-in features. No functional change: sd-notify does not enable any features by default today. Item 3 of eclipse-opensovd#325.
📊 Coverage Report (unit + DoIP/CAN/mixed integration)Total line coverage: 74.3% |
| /// systemd-configured watchdog timeout, per the systemd-recommended convention | ||
| /// (see `sd_watchdog_enabled(3)`). | ||
| fn watchdog_notify_interval() -> Option<Duration> { | ||
| sd_notify::watchdog_enabled().map(|timeout| timeout / 2) |
There was a problem hiding this comment.
suggestion: We should keep some safe guard, so Duration != Duration::Zero because tokio will panic when using Duration::Zero as tick interval
There was a problem hiding this comment.
@mohammadp1001 Please do not resolve my threads yourself. I will resolve them if I agree with the solution. It helps tracking what I commented and what I reviewed, instead of going through the closed threads.
There was a problem hiding this comment.
Hi, Anything else missing?
There was a problem hiding this comment.
1ms interval will lead to considerable system load. It's legal from the systemd configuration as it supports intervals starting a 1 micro second. But imho it's not a sane configuration for the CDA, we should log a warning once.
tokio::time::interval panics on a zero-length tick interval; clamp the halved WatchdogSec to a minimum of 1ms.
|
@mohammadp1001 can you check the pipeline failure and fix the reported clippy lint? |
|
Sure, I will check. |
Plain division tripped clippy::arithmetic_side_effects, which is deny-level workspace-wide. The divisor is a non-zero literal, so the fallback is unreachable and behaviour is unchanged.
Summary
Follow-up to PR #322's post-merge review, addressing items 1, 2, and 3 from #325 in
cda-extra'ssystemd_notifyimplementation:NotifyState::Stoppingto systemd when the shutdown signal fires, so anintentional shutdown isn't mistaken for a watchdog failure.
timeout - 5s(floored to 1s) watchdog notify interval withtimeout / 2, matching systemd's documented convention(
sd_watchdog_enabled(3)).The previous formula collapsed to "always notify every 1s" for any realistic
watchdog timeout, since
.min(1s)was acting as a cap rather than a floor.determine_intervaltowatchdog_notify_interval(item 2.1) to makeits purpose clearer, and updated the doc comments accordingly.
default-features = falseon the workspacesd-notifydependency inthe root
Cargo.toml. No functional change:sd-notifyenables nofeatures by default today.
Checklist
Related
Follow-up to #322