Repository navigation
Conversation
This was referenced Oct 15, 2026
…te fails (#979) stop() and hibernate() run Cleanup before the EC2 call, and Cleanup's pluginRuntime.StopAll ends every running plugin's health loop and persists StatusStopped. When the EC2 call then failed, the instance kept running with every plugin recorded as stopped and no health loop, so a plugin that failed later was never noticed. - pluginruntime.Runtime now remembers the health block each loop was started with (healthSpecs) and what the last StopAll stopped: each plugin's prior status and, if it had one, its health block. - New Runtime.ResumeStopped undoes the last StopAll once: the prior status (running or degraded) is saved back and the health loop is restarted. A plugin no longer recorded as stopped (removed or reinstalled since) is left alone. StopAll runs no stop steps, so nothing else needs restarting. - restoreAfterFailedStop calls it, beside the DNS and registry restore from #948. - New NewRuntimeWithStore, so the agent's tests can use a temp store. (#979)
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Fixes #979. Stacked on #1005 (fix/978) → #986 → #977 → #969 → #960 → #955 → #936. The base is
fix/978, so the diff shows only #979.What was wrong
stop()andhibernate()callCleanupbefore the EC2 call.CleanupcallspluginRuntime.StopAll, which ends each running plugin's health loop and savesStatusStopped. If the EC2 call then fails, the instance keeps running, but:spawn plugin statusreports every plugin as stopped;#977 already restored DNS and the registry entry. It could not restore plugins, because the runtime kept no record of what
StopAllhad stopped.What changed
pkg/pluginruntimestartHealthLooprecords the health block each loop was started with (healthSpecs, undermu), andstopHealthLoopreturns it.StopAllrecords what it stopped: each plugin's prior status and its health block, if it had one.ResumeStopped(ctx)undoes the lastStopAll, once. It saves the prior status back (running or degraded) and restarts the health loop.stoppedwhenResumeStoppedruns (removed, or reinstalled in between) is left alone.StopAllruns no stop steps, so a plugin's processes were never stopped and nothing else needs restarting.NewRuntimeWithStore, so tests can use a temp state store.pkg/pluginruntimeis not part of the public surface.pkg/agent:restoreAfterFailedStopcallsResumeStopped, next to the DNS and registry restore. That covers the idle path and the on-complete path, for both stop and hibernate.I took the issue's second option rather than splitting
Cleanup. With hibernate, the guest freezes as soon as EC2 accepts the request, so there is no safe point to stop plugins after the call. The runtime record also gives #987 (stacked next) a way to restart plugins after a resume.Tests
pkg/pluginruntime/resume_test.goTestResumeStoppedRestoresStatusAndHealthLoopsets up a running plugin with a real 20 ms health step that appends to a file, plus degraded, already-stopped, failed and removed plugins.StopAll, the plugins are stopped and the file stops growing.ResumeStopped, running and degraded are back, the others are unchanged, the removed plugin is not recreated, and the file grows again.TestResumeStoppedIsOnceAndYieldsToNewerState: a reinstall in between is left alone, and a second resume is a no-op.pkg/agent/idle_stop_retry_test.goTestFailedStopRestoresPlugins: after a failed stop or hibernate the plugin is running. After a successful stop it is stopped.Revert checks. Each revert compiled, and the test ran and failed:
restoreAfterFailedStopdoesn't callResumeStoppedFailedStopRestoresPlugins/{stop,hibernate}_fails("stopped", want "running")ResumeStoppeddoesn't restart the health loopResumeStoppedRestoresStatusAndHealthLoop(health loop did not restart)ResumeStoppeddoesn't restore the statusFailedStopRestoresPluginsThe health-loop test passed 30 runs in a row under
-race.Checks
make check: green except the known Docker-onlyTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker.make check-nested: all 9 nested modules clean.go test -race ./pkg/agent ./pkg/pluginruntime: ok.