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

Retry extracting filesystem from image #1685

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ _If you are interested in contributing to kaniko, see [DEVELOPMENT.md](DEVELOPME
- [--verbosity](#--verbosity)
- [--ignore-var-run](#--ignore-var-run)
- [--ignore-path](#--ignore-path)
- [--image-fs-extract-retry](#--image-fs-extract-retry)
- [Debug Image](#debug-image)
- [Security](#security)
- [Verifying Signed Kaniko Images](#verifying-signed-kaniko-images)
Expand Down Expand Up @@ -753,6 +754,10 @@ Ignore /var/run when taking image snapshot. Set it to false to preserve /var/run

Set this flag as `--ignore-path=<path>` to ignore path when taking an image snapshot. Set it multiple times for multiple ignore paths.

### --image-fs-extract-retry

Set this flag to the number of retries that should happen for the extracting an image filesystem. Defaults to `0`.

### Debug Image

The kaniko executor image is based on scratch and doesn't contain a shell.
Expand Down
1 change: 1 addition & 0 deletions cmd/executor/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func addKanikoOptionsFlags() {
RootCmd.PersistentFlags().BoolVarP(&opts.InsecurePull, "insecure-pull", "", false, "Pull from insecure registry using plain HTTP")
RootCmd.PersistentFlags().BoolVarP(&opts.SkipTLSVerifyPull, "skip-tls-verify-pull", "", false, "Pull from insecure registry ignoring TLS verify")
RootCmd.PersistentFlags().IntVar(&opts.PushRetry, "push-retry", 0, "Number of retries for the push operation")
RootCmd.PersistentFlags().IntVar(&opts.ImageFSExtractRetry, "image-fs-extract-retry", 0, "Number of retries for image FS extraction")
RootCmd.PersistentFlags().StringVarP(&opts.TarPath, "tarPath", "", "", "Path to save the image in as a tarball instead of pushing")
RootCmd.PersistentFlags().BoolVarP(&opts.SingleSnapshot, "single-snapshot", "", false, "Take a single snapshot at the end of the build.")
RootCmd.PersistentFlags().BoolVarP(&opts.Reproducible, "reproducible", "", false, "Strip timestamps out of the image to make it reproducible")
Expand Down
1 change: 1 addition & 0 deletions pkg/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type KanikoOptions struct {
CacheCopyLayers bool
Git KanikoGitOptions
IgnorePaths multiArg
ImageFSExtractRetry int
}

type KanikoGitOptions struct {
Expand Down
7 changes: 6 additions & 1 deletion pkg/executor/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,12 @@ func (s *stageBuilder) build() error {
if shouldUnpack {
t := timing.Start("FS Unpacking")

if _, err := util.GetFSFromImage(config.RootDir, s.image, util.ExtractFile); err != nil {
retryFunc := func() error {
_, err := util.GetFSFromImage(config.RootDir, s.image, util.ExtractFile)
return err
}

if err := util.Retry(retryFunc, s.opts.ImageFSExtractRetry, 1000); err != nil {
return errors.Wrap(err, "failed to get filesystem from image")
}

Expand Down