Add support for Retry= and RetryDelay= to Podman Quadlet.

This commit adds new Retry= and RetryDelay= options
to quadlet.go which result in --retry and --retry-delay
usage in podman run, image and build commands.

This allows configuring the retry logic in the systemd
files.

Fixes: #25109

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
Jan Kaluza
2025-03-25 12:50:41 +01:00
parent ffcad3c36d
commit 08a1c6d91e
6 changed files with 73 additions and 4 deletions

View File

@ -332,6 +332,8 @@ Valid options for `[Container]` are listed below:
| Pull=never | --pull never |
| ReadOnly=true | --read-only |
| ReadOnlyTmpfs=true | --read-only-tmpfs |
| Retry=5 | --retry=5 |
| RetryDelay=5s | --retry-delay=5s |
| Rootfs=/var/lib/rootfs | --rootfs /var/lib/rootfs |
| RunInit=true | --init |
| SeccompProfile=/tmp/s.json | --security-opt seccomp=/tmp/s.json |
@ -781,6 +783,14 @@ If enabled, makes the image read-only.
If ReadOnly is set to `true`, mount a read-write tmpfs on /dev, /dev/shm, /run, /tmp, and /var/tmp.
### `Retry=`
Number of times to retry the image pull when a HTTP error occurs. Equivalent to the Podman `--retry` option.
### `RetryDelay=`
Delay between retries. Equivalent to the Podman `--retry-delay` option.
### `Rootfs=`
The rootfs to use for the container. Rootfs points to a directory on the system that contains the content to be run within the container. This option conflicts with the `Image` option.
@ -1611,6 +1621,8 @@ Valid options for `[Build]` are listed below:
| Network=host | --network=host |
| PodmanArgs=--pull never | --pull never |
| Pull=never | --pull never |
| Retry=5 | --retry=5 |
| RetryDelay=10s | --retry-delay=10s |
| Secret=secret | --secret=id=mysecret,src=path |
| SetWorkingDirectory=unit | Set `WorkingDirectory` of systemd unit file |
| Target=my-app | --target=my-app |
@ -1757,6 +1769,14 @@ Set the image pull policy.
This is equivalent to the `--pull` option of `podman build`.
### `Retry=`
Number of times to retry the image pull when a HTTP error occurs. Equivalent to the Podman `--retry` option.
### `RetryDelay=`
Delay between retries. Equivalent to the Podman `--retry-delay` option.
### `Secret=`
Pass secret information used in Containerfile build stages in a safe way.
@ -1843,6 +1863,8 @@ Valid options for `[Image]` are listed below:
| ImageTag=quay\.io/centos/centos:latest | Use this name when resolving `.image` references |
| OS=windows | --os=windows |
| PodmanArgs=--os=linux | --os=linux |
| Retry=5 | --retry=5 |
| RetryDelay=10s | --retry-delay=10s |
| TLSVerify=false | --tls-verify=false |
| Variant=arm/v7 | --variant=arm/v7 |
@ -1941,6 +1963,14 @@ escaped to allow inclusion of whitespace and other control characters.
This key can be listed multiple times.
### `Retry=`
Number of times to retry the image pull when a HTTP error occurs. Equivalent to the Podman `--retry` option.
### `RetryDelay=`
Delay between retries. Equivalent to the Podman `--retry-delay` option.
### `TLSVerify=`
Require HTTPS and verification of certificates when contacting registries.

View File

@ -143,6 +143,8 @@ const (
KeyRemapUid = "RemapUid" //nolint:stylecheck // deprecated
KeyRemapUidSize = "RemapUidSize" //nolint:stylecheck // deprecated
KeyRemapUsers = "RemapUsers" // deprecated
KeyRetry = "Retry"
KeyRetryDelay = "RetryDelay"
KeyRootfs = "Rootfs"
KeyRunInit = "RunInit"
KeySeccompProfile = "SeccompProfile"
@ -258,6 +260,8 @@ var (
KeyRemapUid: true,
KeyRemapUidSize: true,
KeyRemapUsers: true,
KeyRetry: true,
KeyRetryDelay: true,
KeyRootfs: true,
KeyRunInit: true,
KeySeccompProfile: true,
@ -362,6 +366,8 @@ var (
KeyImageTag: true,
KeyOS: true,
KeyPodmanArgs: true,
KeyRetry: true,
KeyRetryDelay: true,
KeyServiceName: true,
KeyTLSVerify: true,
KeyVariant: true,
@ -386,6 +392,8 @@ var (
KeyNetwork: true,
KeyPodmanArgs: true,
KeyPull: true,
KeyRetry: true,
KeyRetryDelay: true,
KeySecret: true,
KeyServiceName: true,
KeySetWorkingDirectory: true,
@ -641,6 +649,8 @@ func ConvertContainer(container *parser.UnitFile, isUser bool, unitsInfoMap map[
KeyStopTimeout: "--stop-timeout",
KeyPull: "--pull",
KeyMemory: "--memory",
KeyRetry: "--retry",
KeyRetryDelay: "--retry-delay",
}
lookupAndAddString(container, ContainerGroup, stringKeys, podman)
@ -1365,6 +1375,8 @@ func ConvertImage(image *parser.UnitFile, unitsInfoMap map[string]*UnitInfo, isU
KeyDecryptionKey: "--decryption-key",
KeyOS: "--os",
KeyVariant: "--variant",
KeyRetry: "--retry",
KeyRetryDelay: "--retry-delay",
}
lookupAndAddString(image, ImageGroup, stringKeys, podman)
@ -1437,10 +1449,12 @@ func ConvertBuild(build *parser.UnitFile, unitsInfoMap map[string]*UnitInfo, isU
}
stringKeys := map[string]string{
KeyArch: "--arch",
KeyAuthFile: "--authfile",
KeyTarget: "--target",
KeyVariant: "--variant",
KeyArch: "--arch",
KeyAuthFile: "--authfile",
KeyTarget: "--target",
KeyVariant: "--variant",
KeyRetry: "--retry",
KeyRetryDelay: "--retry-delay",
}
lookupAndAddString(build, BuildGroup, stringKeys, podman)

View File

@ -0,0 +1,8 @@
## assert-podman-args "--retry" "5"
## assert-podman-args "--retry-delay" "10s"
[Build]
ImageTag=localhost/imagename
SetWorkingDirectory=unit
Retry=5
RetryDelay=10s

View File

@ -0,0 +1,7 @@
## assert-podman-args "--retry" "5"
## assert-podman-args "--retry-delay" "10s"
[Container]
Image=localhost/imagename
Retry=5
RetryDelay=10s

View File

@ -0,0 +1,7 @@
## assert-podman-args "--retry" "5"
## assert-podman-args "--retry-delay" "10s"
[Image]
Image=localhost/imagename
Retry=5
RetryDelay=10s

View File

@ -925,6 +925,7 @@ BOGUS=foo
Entry("NetworkAlias", "network-alias.container"),
Entry("CgroupMode", "cgroups-mode.container"),
Entry("Container - No Default Dependencies", "no_deps.container"),
Entry("retry.container", "retry.container"),
Entry("basic.volume", "basic.volume"),
Entry("device-copy.volume", "device-copy.volume"),
@ -994,6 +995,7 @@ BOGUS=foo
Entry("Image - Containers Conf Modules", "containersconfmodule.image"),
Entry("Image - Unit After Override", "unit-after-override.image"),
Entry("Image - No Default Dependencies", "no_deps.image"),
Entry("Image - Retry", "retry.image"),
Entry("Build - Basic", "basic.build"),
Entry("Build - Annotation Key", "annotation.build"),
@ -1028,6 +1030,7 @@ BOGUS=foo
Entry("Build - TLSVerify Key", "tls-verify.build"),
Entry("Build - Variant Key", "variant.build"),
Entry("Build - No Default Dependencies", "no_deps.build"),
Entry("Build - Retry", "retry.build"),
Entry("Pod - Basic", "basic.pod"),
Entry("Pod - DNS", "dns.pod"),