From 79e21b5b162d3c2d3fb274b20bfe180c15284893 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Mon, 8 Aug 2022 11:44:52 +0200 Subject: kube play: sd-notify integration Integrate sd-notify policies into `kube play`. The policies can be configured for all contianers via the `io.containers.sdnotify` annotation or for indidivual containers via the `io.containers.sdnotify/$name` annotation. The `kube play` process will wait for all containers to be ready by waiting for the individual `READY=1` messages which are received via the `pkg/systemd/notifyproxy` proxy mechanism. Also update the simple "container" sd-notify test as it did not fully test the expected behavior which became obvious when adding the new tests. Signed-off-by: Valentin Rothberg --- pkg/systemd/notifyproxy/notifyproxy.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pkg/systemd/notifyproxy') diff --git a/pkg/systemd/notifyproxy/notifyproxy.go b/pkg/systemd/notifyproxy/notifyproxy.go index b9f5737f7..9e6eb4cf0 100644 --- a/pkg/systemd/notifyproxy/notifyproxy.go +++ b/pkg/systemd/notifyproxy/notifyproxy.go @@ -12,7 +12,15 @@ import ( ) // SendMessage sends the specified message to the specified socket. +// No message is sent if no socketPath is provided and the NOTIFY_SOCKET +// variable is not set either. func SendMessage(socketPath string, message string) error { + if socketPath == "" { + socketPath, _ = os.LookupEnv("NOTIFY_SOCKET") + if socketPath == "" { + return nil + } + } socketAddr := &net.UnixAddr{ Name: socketPath, Net: "unixgram", -- cgit v1.2.3-54-g00ecf