Config for Retry and RetryDelay for pulling images

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh 2024-02-20 09:45:53 -05:00
parent 630b65d1b3
commit c580f4054c
6 changed files with 33 additions and 0 deletions

View File

@ -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 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. --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**="" **runtime**=""
Default OCI specific runtime in runtimes that will be used by default. Must Default OCI specific runtime in runtimes that will be used by default. Must

View File

@ -421,6 +421,14 @@ type EngineConfig struct {
// Indicates whether the application should be running in Remote mode // Indicates whether the application should be running in Remote mode
Remote bool `toml:"remote,omitempty"` 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 is deprecated, see ActiveService
// RemoteURI containers connection information used to connect to remote system. // RemoteURI containers connection information used to connect to remote system.
RemoteURI string `toml:"remote_uri,omitempty"` RemoteURI string `toml:"remote_uri,omitempty"`

View File

@ -47,6 +47,8 @@ var _ = Describe("Config", func() {
path, err := defaultConfig.ImageCopyTmpDir() path, err := defaultConfig.ImageCopyTmpDir()
gomega.Expect(err).To(gomega.BeNil()) gomega.Expect(err).To(gomega.BeNil())
gomega.Expect(path).To(gomega.BeEquivalentTo("/var/tmp")) 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() { It("should succeed with devices", func() {
@ -312,6 +314,8 @@ image_copy_tmp_dir="storage"`
gomega.Expect(err).To(gomega.BeNil()) gomega.Expect(err).To(gomega.BeNil())
gomega.Expect(newV).To(gomega.BeEquivalentTo(newVolumes)) 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() { It("test GetDefaultEnvEx", func() {

View File

@ -656,6 +656,16 @@ default_sysctls = [
# #
#remote = false #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 # Default OCI runtime
# #
#runtime = "crun" #runtime = "crun"

View File

@ -354,6 +354,7 @@ func defaultEngineConfig() (*EngineConfig, error) {
c.PodmanshTimeout = uint(30) c.PodmanshTimeout = uint(30)
c.ExitCommandDelay = uint(5 * 60) c.ExitCommandDelay = uint(5 * 60)
c.Remote = isRemote() c.Remote = isRemote()
c.Retry = 3
c.OCIRuntimes = map[string][]string{ c.OCIRuntimes = map[string][]string{
"crun": { "crun": {
"/usr/bin/crun", "/usr/bin/crun",

View File

@ -220,6 +220,8 @@ helper_binaries_dir = [
"/somepath", "/somepath",
] ]
retry=5
retry_delay="10s"
# Path to OCI hooks directories for automatically executed hooks. # Path to OCI hooks directories for automatically executed hooks.
hooks_dir = [ hooks_dir = [