tree-wide: warn when sd_notify fails with READY=1 or FDSTOREREMOVE=1
Most sd_notify() calls are like log_info() — the result is only informative and if they fail, it's best ignore this. But if a call with READY=1 fails, the unit may enter a failed state, so we should warn about this. Similarly for FSTOREREMOVE=1: the manager may be left with a stale fd, at least wasting resources.
This commit is contained in:
+11
-4
@@ -4205,6 +4205,7 @@ static int nspawn_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t r
|
||||
ssize_t n;
|
||||
pid_t inner_child_pid;
|
||||
_cleanup_strv_free_ char **tags = NULL;
|
||||
int r;
|
||||
|
||||
assert(userdata);
|
||||
|
||||
@@ -4243,8 +4244,11 @@ static int nspawn_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t r
|
||||
if (!tags)
|
||||
return log_oom();
|
||||
|
||||
if (strv_find(tags, "READY=1"))
|
||||
(void) sd_notifyf(false, "READY=1\n");
|
||||
if (strv_find(tags, "READY=1")) {
|
||||
r = sd_notifyf(false, "READY=1\n");
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
}
|
||||
|
||||
p = strv_find_startswith(tags, "STATUS=");
|
||||
if (p)
|
||||
@@ -5134,8 +5138,11 @@ static int run_container(
|
||||
(void) sd_notifyf(false,
|
||||
"STATUS=Container running.\n"
|
||||
"X_NSPAWN_LEADER_PID=" PID_FMT, *pid);
|
||||
if (!arg_notify_ready)
|
||||
(void) sd_notify(false, "READY=1\n");
|
||||
if (!arg_notify_ready) {
|
||||
r = sd_notify(false, "READY=1\n");
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
}
|
||||
|
||||
if (arg_kill_signal > 0) {
|
||||
/* Try to kill the init system on SIGINT or SIGTERM */
|
||||
|
||||
Reference in New Issue
Block a user