Retry extracting filesystem from image (#1685)

* Retry extracting filesystem from image

* Add flag image-fs-extract-retry

* Add --image-fs-extract-retry documentation
This commit is contained in:
Jose Donizetti 2021-07-08 16:00:22 -03:00 committed by GitHub
parent 094fe52b37
commit 5b3fb84a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 1 deletions

View File

@ -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=<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.

View File

@ -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")

View File

@ -73,6 +73,7 @@ type KanikoOptions struct {
CacheCopyLayers bool
Git KanikoGitOptions
IgnorePaths multiArg
ImageFSExtractRetry int
}
type KanikoGitOptions struct {

View File

@ -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")
}