From f7d972a70f91a85a5630186e448e7012dc0b8c53 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sat, 10 Nov 2018 21:49:33 +0100 Subject: test: fix test for NOTIFY_SOCKET do not make any assumption on the path inside of the container. Signed-off-by: Giuseppe Scrivano --- test/e2e/run_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 4ed1fbed7..85f8df246 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -292,8 +292,7 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "NOTIFY_SOCKET"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ := session.GrepString(sock) - Expect(match).Should(BeTrue()) + Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) os.Unsetenv("NOTIFY_SOCKET") }) -- cgit v1.2.3-54-g00ecf From fe919e4914657d197adfb1be9e6885dbac82d310 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sat, 10 Nov 2018 21:43:57 +0100 Subject: oci: propagate NOTIFY_SOCKET on runtime start with https://github.com/opencontainers/runc/pull/1807 we moved the systemd notify initialization from "create" to "start", so that the OCI runtime doesn't hang while waiting on reading from the notify socket. This means we also need to set the correct NOTIFY_SOCKET when start'ing the container. Closes: https://github.com/containers/libpod/issues/746 Signed-off-by: Giuseppe Scrivano --- libpod/oci.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libpod/oci.go b/libpod/oci.go index a8013aa47..6ca3ef2e6 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -591,6 +591,9 @@ func (r *OCIRuntime) startContainer(ctr *Container) error { return err } env := []string{fmt.Sprintf("XDG_RUNTIME_DIR=%s", runtimeDir)} + if notify, ok := os.LookupEnv("NOTIFY_SOCKET"); ok { + env = append(env, fmt.Sprintf("NOTIFY_SOCKET=%s", notify)) + } if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, env, r.path, "start", ctr.ID()); err != nil { return err } -- cgit v1.2.3-54-g00ecf From 180d0c6f62af8fb18da2ddb0e929392ae3d389e6 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 28 Nov 2018 12:46:39 +0100 Subject: tests: fix NOTIFY_SOCKET test Signed-off-by: Giuseppe Scrivano --- test/e2e/run_test.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 85f8df246..38504828b 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -3,6 +3,7 @@ package integration import ( "fmt" "io/ioutil" + "net" "os" "path/filepath" "strings" @@ -287,13 +288,27 @@ var _ = Describe("Podman run", func() { }) It("podman run notify_socket", func() { - sock := "/run/notify" + host := GetHostDistributionInfo() + if host.Distribution != "rhel" && host.Distribution != "centos" && host.Distribution != "fedora" { + Skip("this test requires a working runc") + } + sock := filepath.Join(podmanTest.TempDir, "notify") + addr := net.UnixAddr{ + Name: sock, + Net: "unixgram", + } + socket, err := net.ListenUnixgram("unixgram", &addr) + Expect(err).To(BeNil()) + defer os.Remove(sock) + defer socket.Close() + os.Setenv("NOTIFY_SOCKET", sock) + defer os.Unsetenv("NOTIFY_SOCKET") + session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "NOTIFY_SOCKET"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) - os.Unsetenv("NOTIFY_SOCKET") }) It("podman run log-opt", func() { -- cgit v1.2.3-54-g00ecf