From c580f4054c24afd5df3d930ea2a21f27b8f2094b Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 20 Feb 2024 09:45:53 -0500 Subject: [PATCH] Config for Retry and RetryDelay for pulling images Signed-off-by: Daniel J Walsh --- common/docs/containers.conf.5.md | 8 ++++++++ common/pkg/config/config.go | 8 ++++++++ common/pkg/config/config_test.go | 4 ++++ common/pkg/config/containers.conf | 10 ++++++++++ common/pkg/config/default.go | 1 + common/pkg/config/testdata/containers_default.conf | 2 ++ 6 files changed, 33 insertions(+) diff --git a/common/docs/containers.conf.5.md b/common/docs/containers.conf.5.md index 88f29e1a2d..39c5593a8b 100644 --- a/common/docs/containers.conf.5.md +++ b/common/docs/containers.conf.5.md @@ -764,6 +764,14 @@ Pull image before running or creating a container. The default is **missing**. Indicates whether the application should be running in remote mode. This flag modifies the --remote option on container engines. Setting the flag to true will default `podman --remote=true` for access to the remote Podman service. +**retry** = 3 + +Number of times to retry pulling/pushing images in case of failure. + +**retry_delay** = "" + +Delay between retries in case pulling/pushing image fails. If set, container engines will retry at the set interval, otherwise they delay 2 seconds and then exponentially back off. + **runtime**="" Default OCI specific runtime in runtimes that will be used by default. Must diff --git a/common/pkg/config/config.go b/common/pkg/config/config.go index d52187a00c..f3a174907d 100644 --- a/common/pkg/config/config.go +++ b/common/pkg/config/config.go @@ -421,6 +421,14 @@ type EngineConfig struct { // Indicates whether the application should be running in Remote mode Remote bool `toml:"remote,omitempty"` + // Number of times to retry pulling/pushing images in case of failure + Retry uint `toml:"retry,omitempty"` + + // Delay between retries in case pulling/pushing image fails + // If set, container engines will retry at the set interval, + // otherwise they delay 2 seconds and then exponentially back off. + RetryDelay string `toml:"retry_delay,omitempty"` + // RemoteURI is deprecated, see ActiveService // RemoteURI containers connection information used to connect to remote system. RemoteURI string `toml:"remote_uri,omitempty"` diff --git a/common/pkg/config/config_test.go b/common/pkg/config/config_test.go index 8a4cd2fdd7..044c5ad0e7 100644 --- a/common/pkg/config/config_test.go +++ b/common/pkg/config/config_test.go @@ -47,6 +47,8 @@ var _ = Describe("Config", func() { path, err := defaultConfig.ImageCopyTmpDir() gomega.Expect(err).To(gomega.BeNil()) gomega.Expect(path).To(gomega.BeEquivalentTo("/var/tmp")) + gomega.Expect(defaultConfig.Engine.Retry).To(gomega.BeEquivalentTo(3)) + gomega.Expect(defaultConfig.Engine.RetryDelay).To(gomega.Equal("")) }) It("should succeed with devices", func() { @@ -312,6 +314,8 @@ image_copy_tmp_dir="storage"` gomega.Expect(err).To(gomega.BeNil()) gomega.Expect(newV).To(gomega.BeEquivalentTo(newVolumes)) } + gomega.Expect(defaultConfig.Engine.Retry).To(gomega.BeEquivalentTo(5)) + gomega.Expect(defaultConfig.Engine.RetryDelay).To(gomega.Equal("10s")) }) It("test GetDefaultEnvEx", func() { diff --git a/common/pkg/config/containers.conf b/common/pkg/config/containers.conf index bddc5e68e3..072235c757 100644 --- a/common/pkg/config/containers.conf +++ b/common/pkg/config/containers.conf @@ -656,6 +656,16 @@ default_sysctls = [ # #remote = false +# Number of times to retry pulling/pushing images in case of failure +# +#retry = 3 + +# Delay between retries in case pulling/pushing image fails. +# If set, container engines will retry at the set interval, +# otherwise they delay 2 seconds and then exponentially back off. +# +#retry_delay = "2s" + # Default OCI runtime # #runtime = "crun" diff --git a/common/pkg/config/default.go b/common/pkg/config/default.go index caccace8a9..5fbdc43df0 100644 --- a/common/pkg/config/default.go +++ b/common/pkg/config/default.go @@ -354,6 +354,7 @@ func defaultEngineConfig() (*EngineConfig, error) { c.PodmanshTimeout = uint(30) c.ExitCommandDelay = uint(5 * 60) c.Remote = isRemote() + c.Retry = 3 c.OCIRuntimes = map[string][]string{ "crun": { "/usr/bin/crun", diff --git a/common/pkg/config/testdata/containers_default.conf b/common/pkg/config/testdata/containers_default.conf index 4643772117..c46afbd450 100644 --- a/common/pkg/config/testdata/containers_default.conf +++ b/common/pkg/config/testdata/containers_default.conf @@ -220,6 +220,8 @@ helper_binaries_dir = [ "/somepath", ] +retry=5 +retry_delay="10s" # Path to OCI hooks directories for automatically executed hooks. hooks_dir = [