From: Lennart Poettering Date: Mon, 16 Jun 2025 08:46:37 +0000 (+0200) Subject: nspawn: slightly beef up READY= logic in nspawn X-Git-Tag: v258-rc1~79^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f63ca4fc1489590b1d70e8dba13d63762f7eb5b5;p=thirdparty%2Fsystemd.git nspawn: slightly beef up READY= logic in nspawn Let's also send out a STATUS= message when we get READY=1 if it didn't come with a STATUS= message itself. Also, let's initially say the container is "started", and only once the READY=1 is seen claim it was "running". --- diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 805dd91389c..8f18d2fc60e 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -4612,15 +4612,18 @@ static int nspawn_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t r log_debug("Got sd_notify() message: %s", strnull(joined)); } + char *status = strv_find_startswith(tags, "STATUS="); + if (status) + (void) sd_notifyf(/* unset_environment= */ false, "STATUS=Container running: %s", status); + if (strv_contains(tags, "READY=1")) { - r = sd_notify(false, "READY=1\n"); + r = sd_notify(/* unset_environment= */ false, "READY=1\n"); if (r < 0) log_warning_errno(r, "Failed to send readiness notification, ignoring: %m"); - } - char *p = strv_find_startswith(tags, "STATUS="); - if (p) - (void) sd_notifyf(false, "STATUS=Container running: %s", p); + if (!status) + (void) sd_notifyf(/* unset_environment= */ false, "STATUS=Container running."); + } return 0; } @@ -5632,11 +5635,11 @@ static int run_container( * will make them appear in getpwuid(), thus we can release the /etc/passwd lock. */ etc_passwd_lock = safe_close(etc_passwd_lock); - (void) sd_notifyf(false, - "STATUS=Container running.\n" + (void) sd_notifyf(/* unset_environment= */ false, + "STATUS=Container started.\n" "X_NSPAWN_LEADER_PID=" PID_FMT, pid->pid); if (!arg_notify_ready) { - r = sd_notify(false, "READY=1\n"); + r = sd_notify(/* unset_environment= */ false, "READY=1\n"); if (r < 0) log_warning_errno(r, "Failed to send readiness notification, ignoring: %m"); }