Skip to content

fix(packer/aws): AMI cleanup check fails a correct image (#3004) - #3182

Merged
vybe merged 1 commit into
devfrom
fix/3004-ami-sshd-check
Oct 2, 2026
Merged

vybe merged 1 commit into
devfrom
fix/3004-ami-sshd-check

Conversation

@obasilakis

Copy link
Copy Markdown
Contributor

Part of #3004.

packer/aws/scripts/90-aws-cleanup.sh failed every AMI build from v1.0.0-aws.1. Three defects, each found on a real build in us-east-1:

  1. sshd -T exits 255 (Missing privilege separation directory: /run/sshd) on Ubuntu 24.04, where ssh is socket-activated. The check read that as "password auth enabled". Fix: install -d /run/sshd first (tmpfs, not baked).
  2. sshd -T | grep -q under set -o pipefail fails even when the setting is right: grep exits on the match, sshd gets SIGPIPE. Fix: capture into a variable, then grep. A failing sshd -T now reports its own error line.
  3. find /var/log -path /var/log/journal -prune -o ... -delete exits 1 on GNU find (-delete implies -depth, which disables -prune), so set -e aborted the script. Fix: -print0 | xargs -0r rm -f.

Verification

  • Probe instance from the same Canonical source AMI: with /run/sshd created, sshd -T rc=0 and prints passwordauthentication no; the old pipe form still failed.
  • Stub test of the new check: pass on a correct config (100k lines of output), fail on yes, fail with the sshd error on rc=255. Old pipe form fails on the correct config.
  • find forms run in ubuntu:24.04: old form exits 1; new form deletes *.gz / *.[0-9] outside the journal and leaves journal files untouched.
  • packer build -var image_tag=v1.0.0-aws.1 with this script: === AMI cleanup checks passed ===, AMI created.

The script is a build-time step only; nothing it changes reaches a running instance's behaviour beyond what the tag already intended.

🤖 Generated with Claude Code

90-aws-cleanup.sh stopped every build from the v1.0.0-aws.1 tag:

- `sshd -T` exits 255 with "Missing privilege separation directory:
  /run/sshd" on Ubuntu 24.04, where ssh is socket-activated. Create the
  directory first (tmpfs, not baked into the image).
- `sshd -T | grep -q` under pipefail fails even when the setting is right:
  grep exits on the match and sshd dies of SIGPIPE. Capture the output,
  then grep it.
- `find -prune ... -delete` exits 1 on GNU find (-delete implies -depth,
  which disables -prune), so set -e aborted the log cleanup. Delete via
  -print0 | xargs rm.

A build from the tag with this script produced an AMI with all cleanup
checks passing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge-train: validated READY (lane B, sole survivor of today's queue — merged individually, no train assembled). Traced all three fixes: the captured sshd -T avoids the pipefail/SIGPIPE false-fail and a non-zero exit in a || list doesn't trip set -e; -print0 | xargs -0r rm -f keeps the journal prune and removes GNU find's -delete/-prune exit 1. tests/unit/test_3004_aws_packer.py 14/14 on the head. Coverage note: those tests are source-text only; behaviour is evidenced by the real packer build in the PR body, which is the only harness this build-time script has.

@vybe
vybe merged commit 69ef057 into dev Oct 2, 2026
21 checks passed
vybe pushed a commit that referenced this pull request Oct 5, 2026
Pre-release for the AWS Marketplace AMI (#3004). Supersedes 1.0.0-aws.1 and
carries the AMI cleanup fix (#3182) and the CPU cap at the host's count
(#3184), without which the system agent never starts on a 2-vCPU instance.
The DigitalOcean installer default moves with VERSION (trinity#2380).

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants