Skip to content

Commit 35b11c0

Browse files
author
Jan Kaluza
committed
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 <[email protected]>
1 parent ffcad3c commit 35b11c0

File tree

6 files changed

+53
-4
lines changed

6 files changed

+53
-4
lines changed

docs/source/markdown/podman-systemd.unit.5.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ Valid options for `[Container]` are listed below:
332332
| Pull=never | --pull never |
333333
| ReadOnly=true | --read-only |
334334
| ReadOnlyTmpfs=true | --read-only-tmpfs |
335+
| Retry=5 | --retry=5 |
336+
| RetryDelay=5s | --retry-delay=5s |
335337
| Rootfs=/var/lib/rootfs | --rootfs /var/lib/rootfs |
336338
| RunInit=true | --init |
337339
| SeccompProfile=/tmp/s.json | --security-opt seccomp=/tmp/s.json |
@@ -781,6 +783,14 @@ If enabled, makes the image read-only.
781783

782784
If ReadOnly is set to `true`, mount a read-write tmpfs on /dev, /dev/shm, /run, /tmp, and /var/tmp.
783785

786+
### `Retry=`
787+
788+
Number of times to retry the image pull when a HTTP error occurs. Equivalent to the Podman `--retry` option.
789+
790+
### `RetryDelay=`
791+
792+
Delay between retries. Equivalent to the Podman `--retry-delay` option.
793+
784794
### `Rootfs=`
785795

786796
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.

pkg/systemd/quadlet/quadlet.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ const (
143143
KeyRemapUid = "RemapUid" //nolint:stylecheck // deprecated
144144
KeyRemapUidSize = "RemapUidSize" //nolint:stylecheck // deprecated
145145
KeyRemapUsers = "RemapUsers" // deprecated
146+
KeyRetry = "Retry"
147+
KeyRetryDelay = "RetryDelay"
146148
KeyRootfs = "Rootfs"
147149
KeyRunInit = "RunInit"
148150
KeySeccompProfile = "SeccompProfile"
@@ -258,6 +260,8 @@ var (
258260
KeyRemapUid: true,
259261
KeyRemapUidSize: true,
260262
KeyRemapUsers: true,
263+
KeyRetry: true,
264+
KeyRetryDelay: true,
261265
KeyRootfs: true,
262266
KeyRunInit: true,
263267
KeySeccompProfile: true,
@@ -362,6 +366,8 @@ var (
362366
KeyImageTag: true,
363367
KeyOS: true,
364368
KeyPodmanArgs: true,
369+
KeyRetry: true,
370+
KeyRetryDelay: true,
365371
KeyServiceName: true,
366372
KeyTLSVerify: true,
367373
KeyVariant: true,
@@ -386,6 +392,8 @@ var (
386392
KeyNetwork: true,
387393
KeyPodmanArgs: true,
388394
KeyPull: true,
395+
KeyRetry: true,
396+
KeyRetryDelay: true,
389397
KeySecret: true,
390398
KeyServiceName: true,
391399
KeySetWorkingDirectory: true,
@@ -641,6 +649,8 @@ func ConvertContainer(container *parser.UnitFile, isUser bool, unitsInfoMap map[
641649
KeyStopTimeout: "--stop-timeout",
642650
KeyPull: "--pull",
643651
KeyMemory: "--memory",
652+
KeyRetry: "--retry",
653+
KeyRetryDelay: "--retry-delay",
644654
}
645655
lookupAndAddString(container, ContainerGroup, stringKeys, podman)
646656

@@ -1365,6 +1375,8 @@ func ConvertImage(image *parser.UnitFile, unitsInfoMap map[string]*UnitInfo, isU
13651375
KeyDecryptionKey: "--decryption-key",
13661376
KeyOS: "--os",
13671377
KeyVariant: "--variant",
1378+
KeyRetry: "--retry",
1379+
KeyRetryDelay: "--retry-delay",
13681380
}
13691381
lookupAndAddString(image, ImageGroup, stringKeys, podman)
13701382

@@ -1437,10 +1449,12 @@ func ConvertBuild(build *parser.UnitFile, unitsInfoMap map[string]*UnitInfo, isU
14371449
}
14381450

14391451
stringKeys := map[string]string{
1440-
KeyArch: "--arch",
1441-
KeyAuthFile: "--authfile",
1442-
KeyTarget: "--target",
1443-
KeyVariant: "--variant",
1452+
KeyArch: "--arch",
1453+
KeyAuthFile: "--authfile",
1454+
KeyTarget: "--target",
1455+
KeyVariant: "--variant",
1456+
KeyRetry: "--retry",
1457+
KeyRetryDelay: "--retry-delay",
14441458
}
14451459
lookupAndAddString(build, BuildGroup, stringKeys, podman)
14461460

test/e2e/quadlet/retry.build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## assert-podman-args "--retry" "5"
2+
## assert-podman-args "--retry-delay" "10s"
3+
4+
[Build]
5+
ImageTag=localhost/imagename
6+
SetWorkingDirectory=unit
7+
Retry=5
8+
RetryDelay=10s

test/e2e/quadlet/retry.container

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## assert-podman-args "--retry" "5"
2+
## assert-podman-args "--retry-delay" "10s"
3+
4+
[Container]
5+
Image=localhost/imagename
6+
Retry=5
7+
RetryDelay=10s

test/e2e/quadlet/retry.image

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## assert-podman-args "--retry" "5"
2+
## assert-podman-args "--retry-delay" "10s"
3+
4+
[Image]
5+
Image=localhost/imagename
6+
Retry=5
7+
RetryDelay=10s

test/e2e/quadlet_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@ BOGUS=foo
925925
Entry("NetworkAlias", "network-alias.container"),
926926
Entry("CgroupMode", "cgroups-mode.container"),
927927
Entry("Container - No Default Dependencies", "no_deps.container"),
928+
Entry("retry.container", "retry.container"),
928929

929930
Entry("basic.volume", "basic.volume"),
930931
Entry("device-copy.volume", "device-copy.volume"),
@@ -994,6 +995,7 @@ BOGUS=foo
994995
Entry("Image - Containers Conf Modules", "containersconfmodule.image"),
995996
Entry("Image - Unit After Override", "unit-after-override.image"),
996997
Entry("Image - No Default Dependencies", "no_deps.image"),
998+
Entry("Image - Retry", "retry.image"),
997999

9981000
Entry("Build - Basic", "basic.build"),
9991001
Entry("Build - Annotation Key", "annotation.build"),
@@ -1028,6 +1030,7 @@ BOGUS=foo
10281030
Entry("Build - TLSVerify Key", "tls-verify.build"),
10291031
Entry("Build - Variant Key", "variant.build"),
10301032
Entry("Build - No Default Dependencies", "no_deps.build"),
1033+
Entry("Build - Retry", "retry.build"),
10311034

10321035
Entry("Pod - Basic", "basic.pod"),
10331036
Entry("Pod - DNS", "dns.pod"),

0 commit comments

Comments
 (0)