mz440: cleanup kaniko dir #453
Open
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.
Fixes #440
Description
Kaniko is not designed to run multiple times in the same pod, so adding retries around its execution causes hard failures. While Kaniko provides a --cleanup option, it only removes the filesystem created during the build and only on success. This change extends the cleanup to also remove Kaniko’s working directory, which stores intermediate build output, and ensures cleanup happens even when the build fails.
The following new directories are removed:
DockerfilePath: The dockerfile we're building, it will be overwritten anywaysKanikoIntermediateStagesDir: Where we store stages as tarball/ociBuildContextDir<- this was the root cause of the issueKanikoInterStageDepsDir: Files that are copied between stagesKanikoLayersDir: Where we store tarball/oci snapshots of individial layersKanikoSecretsDir: Where secrets are copied to, it would be wrong to reuse themWe specifically do not remove:
KanikoCacheDir: We might want to reuse cache dirs, but you could argue that this is dangerous tooKanikoSwapDir: This directory must be empty anywaysDockerConfigDir: This is not created by kanikoIt's a bit a debate which directories should be reusable, as it depends on whether we rebuild the same dockerfile, same target etc etc. I know that a handful of people build multiple targets in the same pod using this strategy, we eventually want to support that out of the box in a single run.
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Reviewer Notes
Release Notes
Describe any changes here so maintainer can include it in the release notes, or delete this block.