diff --git a/README.md b/README.md index a458116741..1f70a79d14 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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=` 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. diff --git a/cmd/executor/cmd/root.go b/cmd/executor/cmd/root.go index ac1a5318b0..f8313b3d39 100644 --- a/cmd/executor/cmd/root.go +++ b/cmd/executor/cmd/root.go @@ -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") diff --git a/pkg/config/options.go b/pkg/config/options.go index 26697a0e40..5fd1addb82 100644 --- a/pkg/config/options.go +++ b/pkg/config/options.go @@ -73,6 +73,7 @@ type KanikoOptions struct { CacheCopyLayers bool Git KanikoGitOptions IgnorePaths multiArg + ImageFSExtractRetry int } type KanikoGitOptions struct { diff --git a/pkg/executor/build.go b/pkg/executor/build.go index 17291f10e2..ae58708385 100644 --- a/pkg/executor/build.go +++ b/pkg/executor/build.go @@ -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") }