Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move cleanup to separate provisioner, remove cleanup_image var #1036

Merged
merged 1 commit into from
Sep 29, 2022

Conversation

cartermckinnon
Copy link
Member

@cartermckinnon cartermckinnon commented Sep 28, 2022

Description of changes:

Performing the cleanup steps within install-worker.sh is problematic, because they can only be skipped -- they can't be invoked separately from the rest of install-worker.sh. This is a pain for our GPU AMI template, for example.

The cleanup_image var was added to the packer template in #522. The value is passed to install-worker.sh as an environment variable, CLEANUP_IMAGE, which toggles the removal of various bits from the resulting AMI.

However, this variable doesn't actually work with our packer template; if you set its value to false, the build will fail. This is because validate.sh requires the cleanup steps to be run. This toggle would only make sense if you were using install-worker.sh in a custom packer template (which I assume is what folks are doing). However, I don't think it makes sense to allow cleanup to be disabled in the packer template that we publish, because validate.sh should never be optional in this template.

Removing the variable from our template won't break users who are using install-worker.sh in a custom template and setting CLEANUP_IMAGE=false. These users wouldn't include the new cleanup.sh provisioner; so there is no functional change.

This could break users who are directly modifying our packer template at build-time, such as setting cleanup_image to false and then deleting the validate.sh provisioner. This type of usage is inherently fragile and we can't always avoid breaking it. It shouldn't be difficult to resolve.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Testing Done

Before this change, this will fail:

# cleanup_image was never added to PACKER_VARIABLES in the Makefile, so just setting it here
> echo $(jq '.variables.cleanup_image = "false"' eks-worker-al2.json) > eks-worker-al2.json
> make 1.23
...
2022-09-28T14:57:52-07:00: ==> amazon-ebs: Provisioning with shell script: /var/folders/5t/c97ylshx62gb8ctzrmbtbv4h0000gs/T/tmp.AUBkWKrX/amazon-eks-ami/scripts/validate.sh
2022-09-28T14:57:52-07:00:     amazon-ebs: /etc/hostname shouldn't exists
...

After this change, this succeeds:

> make 1.23

@cartermckinnon cartermckinnon added the bug Something isn't working label Sep 28, 2022
@cartermckinnon
Copy link
Member Author

@ericlarssen-wf if you can add details about how you've used cleanup_image, it'd be helpful.

Comment on lines -380 to -381
CLEANUP_IMAGE="${CLEANUP_IMAGE:-true}"
if [[ "$CLEANUP_IMAGE" == "true" ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

Is this an important thing?

Copy link
Member

Choose a reason for hiding this comment

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

NVM, looks like you address in your description.

Comment on lines -380 to -381
CLEANUP_IMAGE="${CLEANUP_IMAGE:-true}"
if [[ "$CLEANUP_IMAGE" == "true" ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

NVM, looks like you address in your description.

@cartermckinnon cartermckinnon merged commit c3c8326 into master Sep 29, 2022
@cartermckinnon cartermckinnon deleted the move-cleanup branch September 29, 2022 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants