Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Add a new flag to cleanup the filesystem at the end#370

Merged
priyawadhwa merged 1 commit intoGoogleContainerTools:masterfrom
vbehar:cleanup-flag
Sep 28, 2018
Merged

Add a new flag to cleanup the filesystem at the end#370
priyawadhwa merged 1 commit intoGoogleContainerTools:masterfrom
vbehar:cleanup-flag

Conversation

@vbehar
Copy link
Copy Markdown
Contributor

@vbehar vbehar commented Sep 27, 2018

Currently, kaniko can only build a single image per container run, because the filesystem is full of the content of the first image.
When running kaniko in Jenkins, where we need to start the container "doing nothing" first (using the debug kaniko container), and then exec /kaniko/executor, this is a limitation because it means that if we want to build multiple images, we need to start multiple containers - see https://groups.google.com/forum/#!topic/kaniko-users/_7LivHdMdy0 for more details

A solution to fix this issue is to add a new flag to cleanup the filesystem at the end - the same way it is done between stages when building a multi-stages image. This way, the same (debug) container can be used to build multiple images.

@container-tools-bot
Copy link
Copy Markdown
Collaborator

Hi @vbehar. Thanks for your PR.

I'm waiting for a GoogleContainerTools member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@svalo
Copy link
Copy Markdown

svalo commented Sep 27, 2018

This would be awesome! I'm using GitLab CI, I need to build 2 images, the second depending on the first. To be able to use kaniko I had to create 2 stages because GitLab's jobs can't be sequential. If this gets merged everything could be achieved in a single job

Copy link
Copy Markdown
Contributor

@priyawadhwa priyawadhwa left a comment

Choose a reason for hiding this comment

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

Thanks for contributing this feature! Just had a few comments around organization.

Comment thread cmd/executor/cmd/root.go Outdated
opts = &config.KanikoOptions{}
logLevel string
force bool
cleanup bool
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.

Instead of creating a new variable here, could we add this to KanikoOptions? This should help with executing the comment below.

Comment thread cmd/executor/cmd/root.go Outdated
if err := executor.DoPush(image, opts); err != nil {
exit(errors.Wrap(err, "error pushing image"))
}
if cleanup {
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.

Instead of having this in root.go, I think it would be better placed in this if statement in build.go

If opts.Cleanup is true, then delete the filesystem before returning the image.

Currently, kaniko can only build a single image per container run, because the filesystem is full of the content of the first image.
When running kaniko in Jenkins, where we need to start the container "doing nothing" first (using the debug kaniko container), and then exec /kaniko/executor, this is a limitation because it means that if we want to build multiple images, we need to start multiple containers - see https://groups.google.com/forum/#!topic/kaniko-users/_7LivHdMdy0 for more details

A solution to fix this issue is to add a new flag to cleanup the filesystem at the end - the same way it is done between stages when building a multi-stages image. This way, the same (debug) container can be used to build multiple images.
@vbehar
Copy link
Copy Markdown
Contributor Author

vbehar commented Sep 28, 2018

@priyawadhwa ok, thanks for the review! I changed the implementation and squashed.

Copy link
Copy Markdown
Contributor

@priyawadhwa priyawadhwa left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for contributing this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants