Skip to content

fix(plugin,agent): failed state for unresolvable launch plugins, login_user for local steps, idle-terminate notification - #1333

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/1225-1226-1205-plugin-idle
Oct 26, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/1225-1226-1205-plugin-idle

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Three fixes: plugin runtime state, the plugin template context, and spored's idle-terminate notification.

#1226: unresolvable launch-time plugin now records a failed state

When a spawn launch plugin's spec failed to resolve, or its config did (missing required key, undeclared key), spored only logged it, and spawn plugin status said "not installed". LoadFromDeclarations now saves a StatusFailed state with the error, through a new recordDeclarationFailure. plugin status and plugin list already show Error.

  • Config failure: checked in LoadFromDeclarations before Install, because Install refuses the config before it records any state. The push-API install path (spawn plugin install) is unchanged. It resolves config on the controller first, and leaving it alone means a bad push can't overwrite a running plugin's state.
  • Spec failure: the state name comes from plugin.ParseRef(ref).Name. A ref that gives no valid store name (e.g. a local path) still only logs.
  • No overwrite: a plugin recorded as running or degraded is left alone, so a failed spec fetch on a later boot doesn't mark a working plugin failed.

#1225: local steps get the same instance.* as remote steps

  • New pluginInstanceVars(instance, inst) in cmd/plugin.go builds id, name, ip and login_user for local steps.
  • login_user uses resolveSSHUser (spawn:local-username, else ec2-user), the same source spawn connect and spored use.
  • runPluginInstall reuses the instance it already resolved for the Windows guard. The vars go into the local record, so reconcile and deprovision get login_user too.
  • Behaviour change (CHANGELOG, Changed): local instance.id is now the EC2 ID when spawn can resolve the instance, matching remote steps. Before, it was the --instance value as typed.
  • spore-sync still hardcodes ec2-user (spore-plugins repo). It can switch once this ships. Follow-up filed there (spore-sync: use {{ instance.login_user }} instead of hardcoded ec2-user (needs spawn with #1225) spore-plugins#32).

#1205: idle terminate sends a notification

spore-bot lists no idle_terminated event. Its Slack and Discord formatters keep a case for it only as "legacy", SMS has none, and spawn's vendored list rejects it. Per the brief, this sends the closest listed event: ttl_expired, the bot's only "has terminated" message. It is sent once EC2 has accepted the terminate. terminate() now returns the provider error, and existing callers ignore it.

Gates (each watched failing against a revert that compiles)

  • TestIdleTerminateIsAnnouncedOnceAccepted:
    • err == nil && false (never notify): the accepted case fails.
    • err == nil || true (notify on failure): the refused case fails.
  • TestLoadFromDeclarations_UnresolvableRecordsFailedState (waits on a Save seam, with a hang guard):
    • recordDeclarationFailure turned into a no-op: all 3 cases fail.
    • Config pre-check disabled (&& false): both config cases fail.
  • TestRecordDeclarationFailure_LeavesRunningPluginAlone: dropping the running/degraded guard (&& false) fails it.
  • TestRemoteInstanceVarsMatchTheDocumentedSet and TestPluginInstanceVarsMatchTheDocumentedSet: both discover the {{ instance.* }} keys from Render's doc comment in pkg/plugin/template.go (and fail on an empty discovery), then hold the remote and the controller context to that set. So the two contexts agree without either test listing the keys.
    • Dropping login_user on the controller fails the controller test, TestPluginInstanceVarsLoginUser and TestPluginInstallRecordsLoginUserForTeardown. The last one drives runPluginInstall and reads the saved local record.
    • _ = loginUser on the remote fails the remote test.

Checks

Fixes #1225
Fixes #1226
Fixes #1205

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/pluginruntime/runtime.go 94.11% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

…n_user for local steps, idle-terminate notification

- spored records a failed plugin state when a launch-time plugin's spec or
  config does not resolve, so plugin status shows the error (#1226).
- Local plugin steps get the same instance.* variables as remote steps,
  including login_user from spawn:local-username; instance.id is the EC2 ID
  when resolvable (#1225).
- spored's idle terminate sends spore-bot's ttl_expired "has terminated"
  event once EC2 accepts the terminate (#1205).

Fixes #1225
Fixes #1226
Fixes #1205
@scttfrdmn
scttfrdmn force-pushed the fix/1225-1226-1205-plugin-idle branch from 8acd307 to 7ac465b Compare October 26, 2026 23:01
@scttfrdmn
scttfrdmn merged commit 0885bb5 into main Oct 26, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1225-1226-1205-plugin-idle branch October 26, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant