Skip to content

ami create: per-instance spored/plugin state (plugins.json, job-array env, peer files) is still baked into images #1241

Closed

Description

@scttfrdmn

Found while fixing #1057 (PR #1240). That fix cleans the --command run state before spawn ami create snapshots: the completion file, /tmp/SPAWN_*, and the rendered and embedded command. Other per-instance state the bootstrap writes also gets baked into an image, and an instance launched from that image inherits it.

Evidence (main @ c97d887)

  • /etc/spawn/plugins.json: the bootstrap writes it only when the launch declares plugins (pkg/launcher/bootstrap.go, if len(cfg.Plugins) > 0). It never removes it. spored reads it on every startup (pkg/provider/ec2.go loadPluginDeclarations, file optional). So an instance launched from an image of a plugin-bearing instance, with no plugins of its own, still loads the parent's plugin declarations.
  • /var/lib/spored/plugins: the on-instance plugin state store (pkg/plugin/state.go NewDiskStateStore) and /var/lib/spored/queue-state.json (pkg/agent/queue_runner.go) both persist on the root volume.
  • /etc/profile.d/job-array.sh and /etc/spawn/job-array-peers.json / /etc/spawn/pipeline-peers.json: the parent's array identity and peer list land in login shells and peer discovery on the child.
  • /var/lib/spored/compute-checkpoint.json carries instance_id (pkg/agent/computecheckpoint.go), so it is probably harmless. Listed here so whoever picks this up can confirm.

Not verified

I worked this out from reading the code. I have not reproduced it on an instance launched from an image.

Options

Either extend launcher.ImageStateCleanupScript (#1057), or have the bootstrap and spored discard inherited state when the instance ID differs from the one that wrote it. The second also covers images made outside spawn ami create.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions