Merge pull request #17487 from vrothberg/quadlet-stop

quadlet: add ExecStop
This commit is contained in:
OpenShift Merge Robot 2023-02-13 13:45:40 -05:00 committed by GitHub
commit 4debbd108b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -287,13 +287,15 @@ func ConvertContainer(container *parser.UnitFile, isUser bool) (*parser.UnitFile
// Need the containers filesystem mounted to start podman
service.Add(UnitGroup, "RequiresMountsFor", "%t/containers")
// If the conman exited uncleanly it may not have removed the container, so force it,
// -i makes it ignore non-existing files.
// If conmon exited uncleanly it may not have removed the container, so
// force it, -i makes it ignore non-existing files.
service.Add(ServiceGroup, "ExecStop", podmanBinary()+" rm -f -i --cidfile=%t/%N.cid")
// The ExecStopPost is needed when the main PID (i.e., conmon) gets killed.
// In that case, ExecStop is not executed but *Post only. If both are
// fired in sequence, *Post will exit when detecting that the --cidfile
// has already been removed by the previous `rm`..
service.Add(ServiceGroup, "ExecStopPost", "-"+podmanBinary()+" rm -f -i --cidfile=%t/%N.cid")
// Remove the cid file, to avoid confusion as the container is no longer running.
service.Add(ServiceGroup, "ExecStopPost", "-rm -f %t/%N.cid")
podman := NewPodmanCmdline("run")
podman.addf("--name=%s", containerName)

View File

@ -14,7 +14,8 @@
## assert-key-is "Service" "Type" "notify"
## assert-key-is "Service" "NotifyAccess" "all"
## assert-key-is "Service" "SyslogIdentifier" "%N"
## assert-key-is-regex "Service" "ExecStopPost" "-.*/podman rm -f -i --cidfile=%t/%N.cid" "-rm -f %t/%N.cid"
## assert-key-is-regex "Service" "ExecStopPost" "-.*/podman rm -f -i --cidfile=%t/%N.cid"
## assert-key-is-regex "Service" "ExecStop" ".*/podman rm -f -i --cidfile=%t/%N.cid"
## assert-key-is "Service" "Environment" "PODMAN_SYSTEMD_UNIT=%n"
[Container]