Skip to content

capi: add final image hygiene goss checks - #2065

Merged
kubernetes-prow[bot] merged 2 commits into
kubernetes-sigs:mainfrom
MaxRink:tcaas/image-hygiene-goss
Jul 7, 2026
Merged

capi: add final image hygiene goss checks#2065
kubernetes-prow[bot] merged 2 commits into
kubernetes-sigs:mainfrom
MaxRink:tcaas/image-hygiene-goss

Conversation

@MaxRink

@MaxRink MaxRink commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What this does

  • Adds Linux-only Goss checks for final image hygiene after sysprep.
  • Verifies SSH host private keys, machine-id, cloud-init instance identity, crash dumps, and oversized /var/log content are absent from captured images.
  • Leaves Windows Goss rendering unchanged by guarding the checks on OS != windows.

Why

  • These are generic final-image correctness checks and mirror cleanup that the sysprep role already performs.
  • The checks are provider-neutral and contain no project-specific paths, cache plumbing, or credentials.
    Validation
  • git diff --check
  • shell-semantics check proving the SSH-host-key and core-file commands fail when matching files exist
  • docker run --rm --platform linux/arm64/v8 -v "$PWD":/work -w /work/images/capi python:3.12-bookworm bash -lc ./scripts/ci-goss-populate.sh

@kubernetes-prow kubernetes-prow Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 25, 2026
@MaxRink
MaxRink force-pushed the tcaas/image-hygiene-goss branch from 3883d21 to f8c8697 Compare June 26, 2026 04:00
@MaxRink

MaxRink commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

/test pull-azure-sigs

@MaxRink
MaxRink force-pushed the tcaas/image-hygiene-goss branch from f8c8697 to b7340cc Compare June 27, 2026 19:27
@MaxRink
MaxRink force-pushed the tcaas/image-hygiene-goss branch 2 times, most recently from 2e7f6ab to ffc1716 Compare July 1, 2026 17:58

@mboersma mboersma 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.

Thanks for this! The intent is great and it's correctly guarded to Linux-only, follows our existing goss conventions, and runs after sysprep so the cleaned-up state is actually present. It won't break builds.

One substantive thing though: the SSH-host-key and core-dump checks don't actually assert anything as written. find ... -print exits 0 whether or not it finds matches, and stdout: [] in goss means "no required stdout patterns", not "output must be empty". So both checks pass unconditionally and would never catch a leftover key or core file. You can see the same stdout: [] pattern on crictl ps in goss-command.yaml, which always prints a header yet passes.

To make them effective, I'd have the command exit non-zero when something is found, something like:

sh -c '! find /etc/ssh -xdev -type f -name "ssh_host_*_key" | grep -q .'

The machine-id, cloud-init instance-id, and /var/log size checks all use exit-status meaningfully, so those are fine.

A couple of smaller things: the core-dump find / scans the whole filesystem with a 10s timeout, which could get slow or flaky on larger images, and once that check is effective the *.core/core.* patterns could match legitimate files. The 200MB /var/log threshold is also a bit arbitrary. None of those are blockers.

@MaxRink
MaxRink force-pushed the tcaas/image-hygiene-goss branch 2 times, most recently from 4bf7554 to 99ce77f Compare July 5, 2026 12:45
@MaxRink
MaxRink force-pushed the tcaas/image-hygiene-goss branch from 99ce77f to 7cb6763 Compare July 7, 2026 04:04

@mboersma mboersma 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.

/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 7, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mboersma

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 7, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit f9816b5 into kubernetes-sigs:main Jul 7, 2026
11 checks passed
vomba pushed a commit to elastisys/image-builder that referenced this pull request Jul 14, 2026
…ene-goss

capi: add final image hygiene goss checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants