Add retries to image push.
This uses the default provided retry transport by go-containerregistry as this originally had no retries built in. This is useful to avoid intermittent failures of image registries when returning a retryable status code.
This commit is contained in:
parent
cb11a9982c
commit
6978fab45c
|
|
@ -41,6 +41,7 @@ import (
|
|||
"github.com/google/go-containerregistry/pkg/v1/layout"
|
||||
"github.com/google/go-containerregistry/pkg/v1/mutate"
|
||||
"github.com/google/go-containerregistry/pkg/v1/remote"
|
||||
"github.com/google/go-containerregistry/pkg/v1/remote/transport"
|
||||
"github.com/google/go-containerregistry/pkg/v1/tarball"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
|
@ -311,7 +312,7 @@ func makeTransport(opts *config.KanikoOptions, registryName string, loader syste
|
|||
}
|
||||
}
|
||||
}
|
||||
return tr
|
||||
return transport.NewRetry(tr)
|
||||
}
|
||||
|
||||
// pushLayerToCache pushes layer (tagged with cacheKey) to opts.Cache
|
||||
|
|
|
|||
|
|
@ -283,6 +283,14 @@ func (m *mockedCertPool) append(path string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
type retryTransport struct {
|
||||
inner http.RoundTripper
|
||||
}
|
||||
|
||||
func (t *retryTransport) RoundTrip(in *http.Request) (out *http.Response, err error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func Test_makeTransport(t *testing.T) {
|
||||
registryName := "my.registry.name"
|
||||
|
||||
|
|
@ -347,7 +355,7 @@ func Test_makeTransport(t *testing.T) {
|
|||
return &certPool
|
||||
}
|
||||
transport := makeTransport(tt.opts, registryName, mockedSystemCertLoader)
|
||||
tt.check(transport.(*http.Transport).TLSClientConfig, &certPool)
|
||||
tt.check(transport.(*retryTransport).inner.(*http.Transport).TLSClientConfig, &certPool)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue