Skip to content

A failed --on-complete stop/hibernate repeats the completion notification, webhook, grace period and stop on every tick #978

Closed

Description

@scttfrdmn

Found while fixing #948 (PR #977). Verified by reading pkg/agent/agent.go; not reproduced live.

checkCompletion runs whenever the completion file exists. It sends the completion notification, fires the completion webhook (#497), warns users, sleeps the grace period (CompletionDelay), and then calls stop() / hibernate(). It returns true whatever the outcome. If StopInstances fails (for example a one-time Spot instance, #922, or a missing ec2:StopInstances), the completion file is still there on the next tick, so all of that runs again every minute until TTL:

  • another completion notification, and another POST to the caller's completion webhook, which a caller can reasonably treat as "done" each time;
  • the grace-period sleep blocks the monitor loop, and with it the TTL and cost-limit checks, for CompletionDelay on every tick;
  • another stop attempt.

#977 already makes stop() / hibernate() return the error and restore DNS on failure, so the name is no longer deleted on each repeat. The idle path has a backoff (idleTimeoutReached). The completion path has neither a "fired once" guard for the notification and webhook nor a backoff for the action.

Suggested fix: fire completion and the webhook once per spored lifetime. Retry a failed stop/hibernate action on the same backoff as the idle path, without repeating the grace sleep. terminate is out of scope: retrying a failed terminate every tick is the right behaviour for TTL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions