feat: Add system cleanup-state subcommand#41
Open
aaljewarane wants to merge 2 commits into
Open
Conversation
… cleanup-state' to remove well-known OS state that must not be carried into an image (AMI) built from an instance. Initially this removes the macOS cached network interface configuration (NetworkInterfaces.plist), which affects startup health of networking for EC2 Mac instances launched from derived images. The cleanup targets the running system only. The target root is an internal abstraction to permit future targets (e.g. external volumes) and is intentionally not exposed as a flag. A --dry-run flag reports actions without removing state. This supports 'ec2-macos-init clean' delegating OS level cleanup to ec2-macos-utils by default.
aaljewarane
marked this pull request as draft
July 20, 2026 22:27
aaljewarane
marked this pull request as ready for review
July 20, 2026 22:44
…OS state list out of a hardcoded slice into a TOML config. A default config is embedded in the binary; an external file at /usr/local/aws/ec2-macos-utils/cleanup-state.toml, when present, replaces it entirely, letting the list grow and letting customers configure it without a rebuild. A config that cannot be read or parsed is an error so a broken config never silently skips cleanup.
Author
Validation on EC2 Mac hardwareValidated
Built from this branch's working tree. The real boot-generated External config path tested:
Sample output, case 4 (mac2): Sample output, case 7: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
ec2-macos-utils system cleanup-state, which removes well-known macOS state from the running system that must not be carried into an image (AMI) built from an instance. Initially this removes the macOS cached network interface configuration (/Library/Preferences/SystemConfiguration/NetworkInterfaces.plist), which affects startup health of networking on EC2 Mac instances launched from derived images.systemsubcommand group for system provisioning & helper utilities.cleanup-stateremoves each well-known state entry beneath the system root; absent state is skipped, removal continues through errors and reports them all, and a--dry-runflag reports actions without removing anything. Requires root.This supports
ec2-macos-init cleandelegating OS-level cleanup to ec2-macos-utils by default (companion PR in aws/ec2-macos-init).Testing
go vetclean; all unit tests pass.ec2-macos-init clean.