fix: startdaemon reclaim on startup failure - #773
Open
qinfustu wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #773 +/- ##
==========================================
+ Coverage 25.42% 26.11% +0.68%
==========================================
Files 133 134 +1
Lines 12639 12914 +275
==========================================
+ Hits 3213 3372 +159
- Misses 9036 9128 +92
- Partials 390 414 +24
🚀 New features to boost your workflow:
|
qinfustu
force-pushed
the
fix/startdaemon-reclaim-on-startup-failure
branch
from
July 14, 2026 09:48
92cd72c to
6a75b2f
Compare
qinfustu
force-pushed
the
fix/startdaemon-reclaim-on-startup-failure
branch
from
July 29, 2026 08:11
6a75b2f to
fb2d098
Compare
Collaborator
|
Three things:
Smaller ones: |
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Terminate nydusd processes that fail startup verification instead of leaving
them running as orphans that keep pulling from the registry.
Related Issues
Related #771
Change Details
When
StartDaemon's background goroutine detects that a newly spawned nydusdfailed to come up (API socket not ready within ~10s, event subscription failed,
or daemon not RUNNING within ~2s), it previously just logged and returned,
leaving the process alive. Under registry pressure these timeouts are easily
hit, and upper-layer retries (
Prepare,doDaemonRestart) spawn yet anotherdaemon — each round leaks one live, still-pulling orphan.
pkg/manager/daemon_adaptor.goterminateFailedDaemonhelper which does
SIGTERM→ 5s timeout →SIGKILL→Wait(reap).It operates on the captured
*os.Processhandle (not pid) so it is safeagainst pid reuse and concurrent teardown.
kill is not misinterpreted as a death event that triggers another restart.
d.Supervisor != nil): a failover-managed daemonlegitimately stays in INIT/READY while the takeover flow runs
(
TakeOver→Start). Killing it would wreck the takeover, so the helperskips it and leaves cleanup to the failover flow.
retained via
TryRetainSharedDaemon(e.g. spurious timeout race), killingit would drop the active shared daemon. A new
IsSharedDaemonRetainedcallback lets the helper detect and skip this case.
pkg/manager/manager.goIsSharedDaemonRetainedcallback field to theManagerstruct.pkg/filesystem/fs.goinitSharedDaemonnow waits forDaemonStateRunningbefore callingTryRetainSharedDaemon, so a failed shared daemon is never retained with adead process — and a truly-failed one is cleaned up by the helper above.
IsSharedDaemonRetainedcallbacks for both fscache and fusedev managers.Test Results
New unit tests in
pkg/manager/daemon_adaptor_test.go:TestTerminateFailedDaemon/nil_process_is_a_no-opTestTerminateFailedDaemon/SIGTERM_stops_a_well-behaved_process— assertsthe process is reaped and finishes well before the SIGKILL escalation timeout.
TestTerminateFailedDaemon/escalates_to_SIGKILL_when_SIGTERM_is_ignored—spawns a process that traps SIGTERM, asserts it is still killed via SIGKILL.
Change Type
Please select the type of change your pull request relates to:
Self-Checklist
Before submitting a pull request, please ensure you have completed the following: