mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-09-30 12:55:09 +02:00
Improve retry behavior for push operation (#1578)
* Update go-containerregistry to 0.4 * Implement --push-retry argument
This commit is contained in:
@@ -263,12 +263,18 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error {
|
||||
tr := newRetry(util.MakeTransport(opts.RegistryOptions, registryName))
|
||||
rt := &withUserAgent{t: tr}
|
||||
|
||||
if err := remote.Write(destRef, image, remote.WithAuth(pushAuth), remote.WithTransport(rt)); err != nil {
|
||||
logrus.Infof("Pushing image to %s", destRef.String())
|
||||
|
||||
retryFunc := func() error {
|
||||
return remote.Write(destRef, image, remote.WithAuth(pushAuth), remote.WithTransport(rt))
|
||||
}
|
||||
|
||||
if err := util.Retry(retryFunc, opts.PushRetry, 1000); err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to push to destination %s", destRef))
|
||||
}
|
||||
}
|
||||
timing.DefaultRun.Stop(t)
|
||||
logrus.Infof("Pushed images to %d destinations", len(destRefs))
|
||||
logrus.Infof("Pushed image to %d destinations", len(destRefs))
|
||||
return writeImageOutputs(image, destRefs)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user