|
|
b8c242 |
From b8358d4edf1896a821c9370c9ba31c2bb07c277a Mon Sep 17 00:00:00 2001
|
|
|
b8c242 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
b8c242 |
Date: Tue, 16 Oct 2018 15:24:44 +0200
|
|
|
b8c242 |
Subject: [PATCH] core: limit service-watchdogs=no to actual "watchdog"
|
|
|
b8c242 |
commands
|
|
|
b8c242 |
|
|
|
b8c242 |
The setting is now only looked at when considering an action for a job timeout
|
|
|
b8c242 |
or unit start limit. It is ignored for ctrl-alt-del, SuccessAction, SuccessFailure.
|
|
|
b8c242 |
|
|
|
b8c242 |
v2: turn the parameter into a flag field
|
|
|
b8c242 |
v3: rename Options to Flags
|
|
|
b8c242 |
(cherry picked from commit 1710d4beff6329cf6ae0767953cad09593517b2a)
|
|
|
b8c242 |
|
|
|
b8c242 |
Related: #1860899
|
|
|
b8c242 |
---
|
|
|
b8c242 |
src/core/emergency-action.c | 3 ++-
|
|
|
b8c242 |
src/core/emergency-action.h | 8 +++++++-
|
|
|
b8c242 |
src/core/job.c | 3 ++-
|
|
|
b8c242 |
src/core/manager.c | 2 +-
|
|
|
b8c242 |
src/core/unit.c | 9 ++++++---
|
|
|
b8c242 |
5 files changed, 18 insertions(+), 7 deletions(-)
|
|
|
b8c242 |
|
|
|
b8c242 |
diff --git a/src/core/emergency-action.c b/src/core/emergency-action.c
|
|
|
b8c242 |
index 00f5996317..e9e757dfa3 100644
|
|
|
b8c242 |
--- a/src/core/emergency-action.c
|
|
|
b8c242 |
+++ b/src/core/emergency-action.c
|
|
|
b8c242 |
@@ -24,6 +24,7 @@ static void log_and_status(Manager *m, const char *message, const char *reason)
|
|
|
b8c242 |
int emergency_action(
|
|
|
b8c242 |
Manager *m,
|
|
|
b8c242 |
EmergencyAction action,
|
|
|
b8c242 |
+ EmergencyActionFlags options,
|
|
|
b8c242 |
const char *reboot_arg,
|
|
|
b8c242 |
const char *reason) {
|
|
|
b8c242 |
|
|
|
b8c242 |
@@ -34,7 +35,7 @@ int emergency_action(
|
|
|
b8c242 |
if (action == EMERGENCY_ACTION_NONE)
|
|
|
b8c242 |
return -ECANCELED;
|
|
|
b8c242 |
|
|
|
b8c242 |
- if (!m->service_watchdogs) {
|
|
|
b8c242 |
+ if (FLAGS_SET(options, EMERGENCY_ACTION_IS_WATCHDOG) && !m->service_watchdogs) {
|
|
|
b8c242 |
log_warning("Watchdog disabled! Not acting on: %s", reason);
|
|
|
b8c242 |
return -ECANCELED;
|
|
|
b8c242 |
}
|
|
|
b8c242 |
diff --git a/src/core/emergency-action.h b/src/core/emergency-action.h
|
|
|
b8c242 |
index 646ccc4e6b..efbfaf6c6a 100644
|
|
|
b8c242 |
--- a/src/core/emergency-action.h
|
|
|
b8c242 |
+++ b/src/core/emergency-action.h
|
|
|
b8c242 |
@@ -20,10 +20,16 @@ typedef enum EmergencyAction {
|
|
|
b8c242 |
_EMERGENCY_ACTION_INVALID = -1
|
|
|
b8c242 |
} EmergencyAction;
|
|
|
b8c242 |
|
|
|
b8c242 |
+typedef enum EmergencyActionFlags {
|
|
|
b8c242 |
+ EMERGENCY_ACTION_IS_WATCHDOG = 1 << 0,
|
|
|
b8c242 |
+} EmergencyActionFlags;
|
|
|
b8c242 |
+
|
|
|
b8c242 |
#include "macro.h"
|
|
|
b8c242 |
#include "manager.h"
|
|
|
b8c242 |
|
|
|
b8c242 |
-int emergency_action(Manager *m, EmergencyAction action, const char *reboot_arg, const char *reason);
|
|
|
b8c242 |
+int emergency_action(Manager *m,
|
|
|
b8c242 |
+ EmergencyAction action, EmergencyActionFlags options,
|
|
|
b8c242 |
+ const char *reboot_arg, const char *reason);
|
|
|
b8c242 |
|
|
|
b8c242 |
const char* emergency_action_to_string(EmergencyAction i) _const_;
|
|
|
b8c242 |
EmergencyAction emergency_action_from_string(const char *s) _pure_;
|
|
|
b8c242 |
diff --git a/src/core/job.c b/src/core/job.c
|
|
|
b8c242 |
index 870ec0a387..d647aac42d 100644
|
|
|
b8c242 |
--- a/src/core/job.c
|
|
|
b8c242 |
+++ b/src/core/job.c
|
|
|
b8c242 |
@@ -1076,7 +1076,8 @@ static int job_dispatch_timer(sd_event_source *s, uint64_t monotonic, void *user
|
|
|
b8c242 |
u = j->unit;
|
|
|
b8c242 |
job_finish_and_invalidate(j, JOB_TIMEOUT, true, false);
|
|
|
b8c242 |
|
|
|
b8c242 |
- emergency_action(u->manager, u->job_timeout_action, u->job_timeout_reboot_arg, "job timed out");
|
|
|
b8c242 |
+ emergency_action(u->manager, u->job_timeout_action, EMERGENCY_ACTION_IS_WATCHDOG,
|
|
|
b8c242 |
+ u->job_timeout_reboot_arg, "job timed out");
|
|
|
b8c242 |
|
|
|
b8c242 |
return 0;
|
|
|
b8c242 |
}
|
|
|
b8c242 |
diff --git a/src/core/manager.c b/src/core/manager.c
|
|
|
b8c242 |
index 3c44ad3dbc..ac1b198b21 100644
|
|
|
b8c242 |
--- a/src/core/manager.c
|
|
|
b8c242 |
+++ b/src/core/manager.c
|
|
|
b8c242 |
@@ -2528,7 +2528,7 @@ static void manager_handle_ctrl_alt_del(Manager *m) {
|
|
|
b8c242 |
if (ratelimit_below(&m->ctrl_alt_del_ratelimit) || m->cad_burst_action == EMERGENCY_ACTION_NONE)
|
|
|
b8c242 |
manager_start_target(m, SPECIAL_CTRL_ALT_DEL_TARGET, JOB_REPLACE_IRREVERSIBLY);
|
|
|
b8c242 |
else
|
|
|
b8c242 |
- emergency_action(m, m->cad_burst_action, NULL,
|
|
|
b8c242 |
+ emergency_action(m, m->cad_burst_action, 0, NULL,
|
|
|
b8c242 |
"Ctrl-Alt-Del was pressed more than 7 times within 2s");
|
|
|
b8c242 |
}
|
|
|
b8c242 |
|
|
|
b8c242 |
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
|
b8c242 |
index 152a860d08..dc5c89c195 100644
|
|
|
b8c242 |
--- a/src/core/unit.c
|
|
|
b8c242 |
+++ b/src/core/unit.c
|
|
|
b8c242 |
@@ -1669,7 +1669,8 @@ int unit_start_limit_test(Unit *u) {
|
|
|
b8c242 |
log_unit_warning(u, "Start request repeated too quickly.");
|
|
|
b8c242 |
u->start_limit_hit = true;
|
|
|
b8c242 |
|
|
|
b8c242 |
- return emergency_action(u->manager, u->start_limit_action, u->reboot_arg, "unit failed");
|
|
|
b8c242 |
+ return emergency_action(u->manager, u->start_limit_action, EMERGENCY_ACTION_IS_WATCHDOG,
|
|
|
b8c242 |
+ u->reboot_arg, "unit failed");
|
|
|
b8c242 |
}
|
|
|
b8c242 |
|
|
|
b8c242 |
bool unit_shall_confirm_spawn(Unit *u) {
|
|
|
b8c242 |
@@ -2469,9 +2470,11 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlag
|
|
|
b8c242 |
unit_check_binds_to(u);
|
|
|
b8c242 |
|
|
|
b8c242 |
if (os != UNIT_FAILED && ns == UNIT_FAILED)
|
|
|
b8c242 |
- (void) emergency_action(u->manager, u->failure_action, u->reboot_arg, "unit failed");
|
|
|
b8c242 |
+ (void) emergency_action(u->manager, u->failure_action, 0,
|
|
|
b8c242 |
+ u->reboot_arg, "unit failed");
|
|
|
b8c242 |
else if (!UNIT_IS_INACTIVE_OR_FAILED(os) && ns == UNIT_INACTIVE)
|
|
|
b8c242 |
- (void) emergency_action(u->manager, u->success_action, u->reboot_arg, "unit succeeded");
|
|
|
b8c242 |
+ (void) emergency_action(u->manager, u->success_action, 0,
|
|
|
b8c242 |
+ u->reboot_arg, "unit succeeded");
|
|
|
b8c242 |
}
|
|
|
b8c242 |
|
|
|
b8c242 |
unit_add_to_dbus_queue(u);
|