Skip to content

Commit

Permalink
quadlet: Use the new podman create volume --ignore
Browse files Browse the repository at this point in the history
This way we don't have to use the `ExecCondition=podman volume exist`,
which saves one process start.

Signed-off-by: Alexander Larsson <[email protected]>
  • Loading branch information
alexlarsson committed Oct 24, 2022
1 parent 734c435 commit b7f05ce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
5 changes: 1 addition & 4 deletions pkg/systemd/quadlet/quadlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,11 +659,9 @@ func ConvertVolume(volume *parser.UnitFile, name string) (*parser.UnitFile, erro
// Need the containers filesystem mounted to start podman
service.Add(UnitGroup, "RequiresMountsFor", "%t/containers")

execCond := fmt.Sprintf("/usr/bin/bash -c \"! /usr/bin/podman volume exists %s\"", volumeName)

labels := volume.LookupAllKeyVal(VolumeGroup, "Label")

podman := NewPodmanCmdline("volume", "create")
podman := NewPodmanCmdline("volume", "create", "--ignore")

var opts strings.Builder
opts.WriteString("o=")
Expand Down Expand Up @@ -696,7 +694,6 @@ func ConvertVolume(volume *parser.UnitFile, name string) (*parser.UnitFile, erro
service.Setv(ServiceGroup,
"Type", "oneshot",
"RemainAfterExit", "yes",
"ExecCondition", execCond,

// The default syslog identifier is the exec basename (podman) which isn't very useful here
"SyslogIdentifier", "%N")
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/quadlet/basic.volume
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
## assert-key-is Unit RequiresMountsFor "%t/containers"
## assert-key-is Service Type oneshot
## assert-key-is Service RemainAfterExit yes
## assert-key-is Service ExecCondition '/usr/bin/bash -c "! /usr/bin/podman volume exists systemd-basic"'
## assert-key-is Service ExecStart "/usr/bin/podman volume create systemd-basic"
## assert-key-is Service ExecStart "/usr/bin/podman volume create --ignore systemd-basic"
## assert-key-is Service SyslogIdentifier "%N"

[Volume]

0 comments on commit b7f05ce

Please sign in to comment.