From b7f05cef0bae389745f831d1328c7279e848a00f Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 21 Oct 2022 09:17:28 +0200 Subject: [PATCH] quadlet: Use the new podman create volume --ignore This way we don't have to use the `ExecCondition=podman volume exist`, which saves one process start. Signed-off-by: Alexander Larsson --- pkg/systemd/quadlet/quadlet.go | 5 +---- test/e2e/quadlet/basic.volume | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/systemd/quadlet/quadlet.go b/pkg/systemd/quadlet/quadlet.go index b1869cca23..8bb5a30e75 100644 --- a/pkg/systemd/quadlet/quadlet.go +++ b/pkg/systemd/quadlet/quadlet.go @@ -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=") @@ -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") diff --git a/test/e2e/quadlet/basic.volume b/test/e2e/quadlet/basic.volume index ce8dbbed57..3bc5213737 100644 --- a/test/e2e/quadlet/basic.volume +++ b/test/e2e/quadlet/basic.volume @@ -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]