Repository navigation
Conversation
This was referenced Oct 15, 2026
…n failure (#948) A failed StopInstances (one-time Spot, missing ec2:StopInstances) was only logged, so the next idle tick ran the whole stop again: once a minute until TTL, each time sending `idle_stopped` for a running instance and deleting its DNS name again. - idleTimeoutReached owns the idle action. It sends idle_stopped / idle_hibernated only after the provider call succeeds. A failure sends one idle_stop_failed with the error and sets a backoff of 5, 10, 20, 40 minutes, then hourly (idleActionRetryDelay); ticks inside the backoff do nothing. - stop() and hibernate() return the provider error. On failure they call restoreAfterFailedStop, which re-registers the hybrid-registry entry and makes the DNS lease due so the record Cleanup deleted is registered again (through the same path as the renewal, so spawn:dns-status stays honest). Cleanup still runs before the EC2 call: a hibernating guest is frozen, not shut down, and gets no later chance to deregister. - The pre-stop hook was already run-once (preStopDone); unchanged. - Test seams: Notifier.record, stubProvider stopErr/hibernateErr and call counts, and Agent.warnDelay for the 5s user-warning sleep. (#948)
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 #948. Stacked on #969 (fix/952) → #960 → #955 → #936. The base is
fix/952, so the diff shows only #948.What was wrong
When the idle timeout was reached,
checkAndActsentidle_stoppedbefore callingstop().stop()then ran cleanup (DNS deletion, plugin stop, registry deregistration), warned users, and only logged aStopInstancesfailure. On the next tick the instance was still idle and past the timeout, so the whole sequence ran again, once a minute until TTL. Each run sent another falseidle_stoppedand deleted the DNS name of an instance that was still running.The issue also says the pre-stop hook re-ran on each attempt. It does not:
runPreStopis already guarded bypreStopDone, and the task flush bytaskFlushDone, so this PR leaves both alone.What changed
idleTimeoutReachednow owns the idle action:idle_stopped/idle_hibernatedare sent only after the provider call succeeds.idle_stop_failedwith the error. It sets a backoff of 5, 10, 20 and 40 minutes, then hourly (idleActionRetryDelay). Ticks inside the backoff do nothing.stop()/hibernate()return the provider error. On failure they callrestoreAfterFailedStop, which:refreshDNSLease, so the deleted record is registered again through the same path as renewal, andspawn:dns-statusrecords a failure if that re-registration fails.stop/hibernatepaths get the DNS restore too, because it lives instop()/hibernate().Notifier.record(synchronous event capture),stubProvider.stopErr/hibernateErrwith call counts, andAgent.warnDelayfor the 5 s user-warning sleep.Tests (
pkg/agent/idle_stop_retry_test.go)TestFailedIdleStopBacksOffAndIsNotAnnouncedAsStopped(stop and hibernate): ten idle one-minute ticks against a provider returning EC2's one-time-SpotUnsupportedOperation. Expected: 2 attempts, 0idle_stopped/idle_hibernated, exactly 1idle_stop_failed.TestSuccessfulIdleStopIsAnnounced.TestIdleActionRetryDelay: the schedule and its cap.TestFailedStopRestoresDNS: a realdns.Clientagainst anhttptestupdater. A failed stop or hibernate gives[DELETE UPSERT]; a successful stop gives[DELETE].Revert checks. Each revert compiled (
go vetclean), and the test ran and failed:"idle_stopped" sent 2 times although nothing stopped(andidle_hibernated)DNS actions = [DELETE], want [DELETE UPSERT]idle_stop_failed sent 2 times over two failures, want oncego test -race ./pkg/agentpasses, and the wholepkg/agentsuite passes on Linux (an arm64 test binary run in an AL2023 container).make checkpasses except for the known Docker-onlyTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker.make check-nestedpasses: all 9 modules are clean.Caveats
UnsupportedOperationtext, returned by a stub.idle_stop_failedyet, so it falls through to its generic"*name*: idle_stop_failed"message and drops the detail. That fix belongs to spore-host/spore-host: spore-bot: no message for spored's new idle_stop_failed event (falls through to the generic text and drops the detail) spore-host#558.--spotlaunches, and the backoff already limits the cost to one notification and a handful of attempts.Cleanupalso marks plugins stopped (pluginRuntime.StopAll). That is not undone after a failed stop: A failed stop/hibernate leaves every plugin marked stopped on a running instance (Cleanup's StopAll is not undone) #979.