Skip to content

Commit

Permalink
Retry extracting filesystem from image (#1685)
Browse files Browse the repository at this point in the history
* Retry extracting filesystem from image

* Add flag image-fs-extract-retry

* Add --image-fs-extract-retry documentation
  • Loading branch information
josedonizetti authored Jul 8, 2021
1 parent 094fe52 commit 5b3fb84
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
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

0 comments on commit 5b3fb84

Please sign in to comment.