Skip to content

Commit

Permalink
Config for Retry and RetryDelay for pulling images
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Feb 20, 2024
1 parent 66a4ad1 commit 2e7c317
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/containers.conf.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 an image in case of failure.

**retry_delay** = "2s"

Delay between retries in case pulling an image fails.

**runtime**=""

Default OCI specific runtime in runtimes that will be used by default. Must
Expand Down
6 changes: 6 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ type EngineConfig struct {
// Indicates whether the application should be running in Remote mode
Remote bool `toml:"remote,omitempty"`

// Number of times to retry pulling an image in case of failure
Retry uint `toml:"retry,omitempty"`

// Delay between retries in case pulling an image fails.
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"`
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("2s"))
})

It("should succeed with devices", func() {
Expand Down Expand Up @@ -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() {
Expand Down
8 changes: 8 additions & 0 deletions pkg/config/containers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,14 @@ default_sysctls = [
#
#remote = false

# Number of times to retry pulling an image in case of failure
#
#retry = 3

# Delay between retries in case pulling an image fails
#
#retry_delay = "2s"

# Default OCI runtime
#
#runtime = "crun"
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ func defaultEngineConfig() (*EngineConfig, error) {
c.PodmanshTimeout = uint(30)
c.ExitCommandDelay = uint(5 * 60)
c.Remote = isRemote()
c.Retry = 3
c.RetryDelay = "2s"
c.OCIRuntimes = map[string][]string{
"crun": {
"/usr/bin/crun",
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/testdata/containers_default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ helper_binaries_dir = [
"/somepath",
]

remote=5
remote_delay="10s"

# Path to OCI hooks directories for automatically executed hooks.
hooks_dir = [
Expand Down

0 comments on commit 2e7c317

Please sign in to comment.