summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoropenshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com>2022-06-15 16:18:18 +0000
committerGitHub <noreply@github.com>2022-06-15 16:18:18 +0000
commited755cb14e13e8391c1bb33cb0ff038178c4461d (patch)
tree225cbd12d322bbdf904c2bdce2ac428cb862f22e
parent08f35dab5a1dc961992430373415492cf7c1963a (diff)
parent751ba07a76a15ba2965886597c85152c541f3517 (diff)
downloadpodman-ed755cb14e13e8391c1bb33cb0ff038178c4461d.tar.gz
podman-ed755cb14e13e8391c1bb33cb0ff038178c4461d.tar.bz2
podman-ed755cb14e13e8391c1bb33cb0ff038178c4461d.zip
Merge pull request #14596 from giuseppe/move-conmon-different-cgroup-system-service
libpod: improve check to create conmon cgroup
-rw-r--r--libpod/oci_conmon_linux.go2
-rw-r--r--test/system/250-systemd.bats25
-rw-r--r--test/system/helpers.systemd.bash4
3 files changed, 30 insertions, 1 deletions
diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go
index 6cb38717a..fde8624b0 100644
--- a/libpod/oci_conmon_linux.go
+++ b/libpod/oci_conmon_linux.go
@@ -1435,7 +1435,7 @@ func (r *ConmonOCIRuntime) moveConmonToCgroupAndSignal(ctr *Container, cmd *exec
}
// $INVOCATION_ID is set by systemd when running as a service.
- if os.Getenv("INVOCATION_ID") != "" {
+ if ctr.runtime.RemoteURI() == "" && os.Getenv("INVOCATION_ID") != "" {
mustCreateCgroup = false
}
diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats
index 110d425d2..cf57d2589 100644
--- a/test/system/250-systemd.bats
+++ b/test/system/250-systemd.bats
@@ -362,4 +362,29 @@ EOF
run_podman 1 pod exists test_pod
}
+@test "podman-system-service containers survive service stop" {
+ skip_if_remote "N/A under podman-remote"
+
+ SERVICE_NAME=podman-service-$(random_string)
+ port=$(random_free_port)
+ URL=tcp://127.0.0.1:$port
+
+ systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0
+ wait_for_port 127.0.0.1 $port
+
+ # Start a long-running container.
+ cname=keeps-running
+ run_podman --url $URL run -d --name $cname $IMAGE top -d 2
+
+ run_podman container inspect -l --format "{{.State.Running}}"
+ is "$output" "true" "This should never fail"
+
+ systemctl stop $SERVICE_NAME
+
+ run_podman container inspect $cname --format "{{.State.Running}}"
+ is "$output" "true" "Container is still running after podman server stops"
+
+ run_podman rm -f -t 0 $cname
+}
+
# vim: filetype=sh
diff --git a/test/system/helpers.systemd.bash b/test/system/helpers.systemd.bash
index 4bde912a4..d9abc087d 100644
--- a/test/system/helpers.systemd.bash
+++ b/test/system/helpers.systemd.bash
@@ -28,3 +28,7 @@ systemctl() {
journalctl() {
command journalctl $_DASHUSER "$@"
}
+
+systemd-run() {
+ command systemd-run $_DASHUSER "$@";
+}