Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix watchdogd disarm spam#3623

Draft
essess-ss wants to merge 2 commits into
u-root:mainu-root/u-root:mainfrom
essess-ss:fix-watchdogd-disarm-spamessess-ss/u-root:fix-watchdogd-disarm-spamCopy head branch name to clipboard
Draft

Fix watchdogd disarm spam#3623
essess-ss wants to merge 2 commits into
u-root:mainu-root/u-root:mainfrom
essess-ss:fix-watchdogd-disarm-spamessess-ss/u-root:fix-watchdogd-disarm-spamCopy head branch name to clipboard

Conversation

@essess-ss

Copy link
Copy Markdown
Contributor

pkg/watchdogd: fix disarm spam and potential panics

  • Stop petting loop and clear CurrentWd on disarm.
  • Make StartPetting idempotent.
  • Auto-start petting on arm.
  • Fix potential nil pointer dereference on SetTimeout/SetPreTimeout failure paths in ArmWatchdog.

Why?

Because of the below spams once the watchdog is disarmed and waiting for host os kexec:

watchdogd: 2026/06/03 16:36:10 New op received: D
watchdogd: 2026/06/03 16:36:10 Watchdog disarming request went through (Watchdog will not be disabled if CONFIG_WATCHDOG_NOWAYOUT is enabled)
watchdogd: 2026/06/03 16:36:11 Failed to keep alive: write /dev/watchdog: file already closed
watchdogd: 2026/06/03 16:36:16 Failed to keep alive: write /dev/watchdog: file already closed
watchdogd: 2026/06/03 16:36:21 Failed to keep alive: write /dev/watchdog: file already closed
watchdogd: 2026/06/03 16:36:26 Failed to keep alive: write /dev/watchdog: file already closed
watchdogd: 2026/06/03 16:36:31 Failed to keep alive: write /dev/watchdog: file already closed
watchdogd: 2026/06/03 16:36:36 Failed to keep alive: write /dev/watchdog: file already closed
watchdogd: 2026/06/03 16:36:41 Failed to keep alive: write /dev/watchdog: file already closed
watchdogd: 2026/06/03 16:36:46 Failed to keep alive: write /dev/watchdog: file already closed
watchdogd: 2026/06/03 16:36:51 Failed to keep alive: write /dev/watchdog: file already closed

@essess-ss
essess-ss force-pushed the fix-watchdogd-disarm-spam branch 2 times, most recently from 599f1d1 to 83af213 Compare June 3, 2026 17:24
@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.95%. Comparing base (cbcc7b3) to head (83af213).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3623      +/-   ##
==========================================
+ Coverage   60.92%   60.95%   +0.03%     
==========================================
  Files         659      659              
  Lines       46507    46510       +3     
==========================================
+ Hits        28333    28349      +16     
+ Misses      18174    18161      -13     
Flag Coverage Δ
.-amd64 90.90% <ø> (ø)
cmds/...-amd64 52.47% <ø> (ø)
integration/generic-tests/...-amd64 30.29% <0.00%> (-0.01%) ⬇️
integration/generic-tests/...-arm 33.34% <0.00%> (-0.01%) ⬇️
integration/generic-tests/...-arm64 ?
integration/gotests/...-amd64 60.74% <ø> (+0.21%) ⬆️
integration/gotests/...-arm 61.14% <ø> (-0.01%) ⬇️
integration/gotests/...-arm64 61.26% <ø> (-0.01%) ⬇️
pkg/...-amd64 58.69% <0.00%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
everything 65.74% <0.00%> (+0.03%) ⬆️
cmds/exp 34.18% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Stop petting loop and clear CurrentWd on disarm.
- Make StartPetting idempotent.
- Auto-start petting on arm.
- Fix potential nil pointer dereference on SetTimeout/SetPreTimeout failure paths in ArmWatchdog.
- Add unit tests for daemon start/stop and petting loop using a mock device file.

Signed-off-by: Sahil Sharma <sharmasah@google.com>
@essess-ss
essess-ss force-pushed the fix-watchdogd-disarm-spam branch 2 times, most recently from 0125745 to 3d50fcd Compare June 3, 2026 19:16
}
if d.CurrentOpts.Timeout != timeoutIgnore {
if err := wd.SetTimeout(d.CurrentOpts.Timeout); err != nil {
d.CurrentWd.Close()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wow, this is crazy that it happened this way.

if err := wd.SetTimeout(d.CurrentOpts.Timeout); err != nil {
d.CurrentWd.Close()
wd.Close()
log.Printf("Failed to set timeout: %v", err)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pretty much every print in this package should be removed. This kind of print in a package is asking for trouble -- as you saw. I'm going to guess this was a command that got turned into package?

d.CurrentWd.Close()
wd.Close()
log.Printf("Failed to set pretimeout: %v", err)
return OpResultError

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we've got errors package now, and fmt.Errorf, let's use them?
return fmt.Errorf("failed to set pretimeout: %w", err)

same for all the other returns.

log.Printf("No armed Watchdog")
return OpResultOk
}
if r := d.StopPetting(); r != OpResultOk {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it seems very odd that these functions return runes instead of error -- what's the purpose of that? the convention would be
if err := d.StopPetting(); err != nil
What's the pupose of having them return runes? Or is this something you inherited :-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ah I see where it came from. But it should be fixed, if you are willilng.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.