mirror of
https://github.com/containers/skopeo.git
synced 2025-07-13 14:34:44 +00:00
Merge pull request #1468 from jaikiran/1466
Introduce a --ignore option to allow "sync" command to continue syncing even after a particular image sync fails
This commit is contained in:
commit
2d5a00e833
@ -39,6 +39,7 @@ type syncOptions struct {
|
|||||||
destination string // Destination registry name
|
destination string // Destination registry name
|
||||||
scoped bool // When true, namespace copied images at destination using the source repository name
|
scoped bool // When true, namespace copied images at destination using the source repository name
|
||||||
all bool // Copy all of the images if an image in the source is a list
|
all bool // Copy all of the images if an image in the source is a list
|
||||||
|
keepGoing bool // Whether or not to abort the sync if there are any errors during syncing the images
|
||||||
}
|
}
|
||||||
|
|
||||||
// repoDescriptor contains information of a single repository used as a sync source.
|
// repoDescriptor contains information of a single repository used as a sync source.
|
||||||
@ -104,6 +105,7 @@ See skopeo-sync(1) for details.
|
|||||||
flags.StringVarP(&opts.destination, "dest", "d", "", "DESTINATION transport type")
|
flags.StringVarP(&opts.destination, "dest", "d", "", "DESTINATION transport type")
|
||||||
flags.BoolVar(&opts.scoped, "scoped", false, "Images at DESTINATION are prefix using the full source image path as scope")
|
flags.BoolVar(&opts.scoped, "scoped", false, "Images at DESTINATION are prefix using the full source image path as scope")
|
||||||
flags.BoolVarP(&opts.all, "all", "a", false, "Copy all images if SOURCE-IMAGE is a list")
|
flags.BoolVarP(&opts.all, "all", "a", false, "Copy all images if SOURCE-IMAGE is a list")
|
||||||
|
flags.BoolVarP(&opts.keepGoing, "keep-going", "", false, "Do not abort the sync if any image copy fails")
|
||||||
flags.AddFlagSet(&sharedFlags)
|
flags.AddFlagSet(&sharedFlags)
|
||||||
flags.AddFlagSet(&deprecatedTLSVerifyFlags)
|
flags.AddFlagSet(&deprecatedTLSVerifyFlags)
|
||||||
flags.AddFlagSet(&srcFlags)
|
flags.AddFlagSet(&srcFlags)
|
||||||
@ -568,7 +570,6 @@ func (opts *syncOptions) run(args []string, stdout io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
imagesNumber := 0
|
|
||||||
options := copy.Options{
|
options := copy.Options{
|
||||||
RemoveSignatures: opts.removeSignatures,
|
RemoveSignatures: opts.removeSignatures,
|
||||||
SignBy: opts.signByFingerprint,
|
SignBy: opts.signByFingerprint,
|
||||||
@ -578,7 +579,8 @@ func (opts *syncOptions) run(args []string, stdout io.Writer) error {
|
|||||||
OptimizeDestinationImageAlreadyExists: true,
|
OptimizeDestinationImageAlreadyExists: true,
|
||||||
ForceManifestMIMEType: manifestType,
|
ForceManifestMIMEType: manifestType,
|
||||||
}
|
}
|
||||||
|
errorsPresent := false
|
||||||
|
imagesNumber := 0
|
||||||
for _, srcRepo := range srcRepoList {
|
for _, srcRepo := range srcRepoList {
|
||||||
options.SourceCtx = srcRepo.Context
|
options.SourceCtx = srcRepo.Context
|
||||||
for counter, ref := range srcRepo.ImageRefs {
|
for counter, ref := range srcRepo.ImageRefs {
|
||||||
@ -614,12 +616,22 @@ func (opts *syncOptions) run(args []string, stdout io.Writer) error {
|
|||||||
_, err = copy.Image(ctx, policyContext, destRef, ref, &options)
|
_, err = copy.Image(ctx, policyContext, destRef, ref, &options)
|
||||||
return err
|
return err
|
||||||
}, opts.retryOpts); err != nil {
|
}, opts.retryOpts); err != nil {
|
||||||
|
if !opts.keepGoing {
|
||||||
return errors.Wrapf(err, "Error copying ref %q", transports.ImageName(ref))
|
return errors.Wrapf(err, "Error copying ref %q", transports.ImageName(ref))
|
||||||
}
|
}
|
||||||
|
// log the error, keep a note that there was a failure and move on to the next
|
||||||
|
// image ref
|
||||||
|
errorsPresent = true
|
||||||
|
logrus.WithError(err).Errorf("Error copying ref %q", transports.ImageName(ref))
|
||||||
|
continue
|
||||||
|
}
|
||||||
imagesNumber++
|
imagesNumber++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("Synced %d images from %d sources", imagesNumber, len(srcRepoList))
|
logrus.Infof("Synced %d images from %d sources", imagesNumber, len(srcRepoList))
|
||||||
|
if !errorsPresent {
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
|
return errors.New("Sync failed due to previous reported error(s) for one or more images")
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,7 @@ _skopeo_sync() {
|
|||||||
--scoped
|
--scoped
|
||||||
--src-no-creds
|
--src-no-creds
|
||||||
--src-tls-verify
|
--src-tls-verify
|
||||||
|
--keep-going
|
||||||
"
|
"
|
||||||
|
|
||||||
local transports
|
local transports
|
||||||
|
@ -88,6 +88,9 @@ Print usage statement.
|
|||||||
|
|
||||||
**--retry-times** the number of times to retry, retry wait time will be exponentially increased based on the number of failed attempts.
|
**--retry-times** the number of times to retry, retry wait time will be exponentially increased based on the number of failed attempts.
|
||||||
|
|
||||||
|
**--keep-going**
|
||||||
|
If any errors occur during copying of images, those errors are logged and the process continues syncing rest of the images and finally fails at the end.
|
||||||
|
|
||||||
## EXAMPLES
|
## EXAMPLES
|
||||||
|
|
||||||
### Synchronizing to a local directory
|
### Synchronizing to a local directory
|
||||||
|
Loading…
Reference in New Issue
Block a user