Skip to content

extend: Reload/handleReload report success even when the on-instance config refresh (DescribeTags) failed #505

Closed

Description

@scttfrdmn

Summary

`spawn extend` prints `✓ Configuration reloaded on instance` (via SSH-triggered `spored reload` → `handleReload` → `Agent.Reload`), even when the instance's own tag refresh (`ec2:DescribeTags`) failed with a 403 and the daemon is provably still running on stale/zero config. Found live while diagnosing #502's field report.

Root cause

`pkg/agent/agent.go`'s `Reload`:

func (a *Agent) Reload(ctx context.Context) error {
	log.Printf("Reloading configuration...")

	// Refresh the provider's cached config from EC2 tags first
	if err := a.provider.RefreshConfig(ctx); err != nil {
		log.Printf("Warning: failed to refresh config from tags: %v", err)
	}

	// Re-read config from provider
	newConfig, err := a.provider.GetConfig(ctx)
	...

`RefreshConfig`'s error is logged as a warning and then discarded — `GetConfig` just returns whatever's cached (stale, possibly the zero-value config from a startup `DescribeTags` 403), and `Reload` returns `nil`. `handleReload` in `cmd/spored/main.go` then unconditionally prints `✓ Configuration reloaded successfully`.

The caller-side `cmd/extend.go` compounds this: it triggers the reload over SSH and, as long as the SSH command itself exits 0 (which it does — `spored reload` never returns non-zero here), prints `✓ Configuration reloaded on instance`. The combined effect is two layers of "success" reported for an operation that changed nothing on the instance.

Reproduction

From a live field incident (account with a custom `--iam-policy-file` role, i.e. #502's exact scenario, present on an instance launched before the #503 fix was deployed):

Extending TTL deadline to ... UTC...
✅ TTL extended successfully!
...
Triggering configuration reload on instance...
✓ Configuration reloaded on instance

— while `sudo journalctl -u spored` on the instance showed the daemon had logged `Warning: Could not load config from tags: ... 403 ... ec2:DescribeTags` at startup and never successfully refreshed since, so `spored status` on the same instance reported `TTL: none — instance will not auto-terminate` immediately after the "reloaded successfully" message.

Why this matters independent of #502

#502 (now fixed/released in v0.100.1) closes the specific IAM gap that caused the `DescribeTags` 403 for new/relaunched roles. But any transient or permanent tag-read failure (throttling, a role edited out-of-band, a policy boundary, IMDS hiccup) hits this same code path — and every one of them is currently reported to the operator as a successful reload. A lifecycle daemon silently continuing to enforce nothing is exactly the failure mode #65/#71/#72/#475 already treat as unacceptable elsewhere in this codebase; `Reload` is the one place that class of protection doesn't exist.

Suggested fix

  • `Agent.Reload` should return the `RefreshConfig` error (or a wrapped form of it) rather than swallowing it into a warning log line, so `handleReload` prints failure and `spored reload` (and therefore `spawn extend`'s SSH invocation) exits non-zero.
  • `cmd/extend.go`'s "✓ Configuration reloaded on instance" message should only print when the remote command's output/exit code actually confirms success — today it only checks that SSH itself didn't error, not what the remote command reported.
  • Consider: since `RefreshConfig`'s failure means the daemon's cached config could be arbitrarily stale (not just "the fields extend touched"), the safest behavior on a hard read failure is probably to leave the previous good config in place rather than adopt a fresh, poisoned zero-value one — worth checking whether `GetConfig` after a failed `RefreshConfig` can return something worse than "unchanged."

Environment

Found via a live field report (2026-08-18): 7× `c8g.48xlarge`, us-east-1, spored v0.100.0, custom `--iam-policy-file` role (the #502 scenario) predating the v0.100.1 fix.

Activity

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

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