Commit 222ae6a8 authored by Lennart Poettering's avatar Lennart Poettering
Browse files

unit: introduce OnFailureIsolate=

parent 51b4af2c
......@@ -12,9 +12,11 @@ F15:
* ntpd should pull in time-sync.target. (PENDING)
* bluetooth should be possible to disable (PENDING)
* add fstab fields to add wait timeouts, change Wants to Requires by local-fs.target
* hook emergency.target into local-fs.target in some way as OnFailure with isolate
* hook emergency.target into local-fs.target in some way as OnFailure with isolate, add warning log message
* bind mounts are ignored
https://bugzilla.redhat.com/show_bug.cgi?id=682662
......@@ -22,12 +24,10 @@ F15:
* 0595f9a1c182a84581749823ef47c5f292e545f9 is borked, freezes shutdown
(path: after installing inotify watches, recheck file again to fix race)
* bluetooth should be possible to disable
Features:
* fix alsa mixer restore to not print error when no config is stored
Features:
* don't trim empty cgroups
https://bugzilla.redhat.com/show_bug.cgi?id=678555
......@@ -49,7 +49,7 @@ Features:
* introduce /usr/lib/binfmt.d/, /usr/lib/tmpfiles.d/
* in pam_systemd: don't rely on /proc/self/loginuid in a container
* in pam_systemd: don't rely on /proc/self/loginuid in a container (check if audit caps are there)
* take BSD file lock on tty devices when using them?
......
......@@ -444,6 +444,22 @@
state.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>OnFailureIsolate=</varname></term>
<listitem><para>Takes a boolean
argument. If <option>true</option> the
unit listed in
<varname>OnFailure=</varname> will be
enqueued in isolation mode, i.e. all
units that are not its dependency will
be stopped. If this is set only a
single unit may be listed in
<varname>OnFailure=</varname>. Defaults
to
<option>false</option>.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>StopWhenUnneeded=</varname></term>
......
......@@ -148,6 +148,7 @@
{ "org.freedesktop.systemd1.Unit", "RefuseManualStop", bus_property_append_bool, "b", &u->meta.refuse_manual_stop }, \
{ "org.freedesktop.systemd1.Unit", "AllowIsolate", bus_property_append_bool, "b", &u->meta.allow_isolate }, \
{ "org.freedesktop.systemd1.Unit", "DefaultDependencies", bus_property_append_bool, "b", &u->meta.default_dependencies }, \
{ "org.freedesktop.systemd1.Unit", "OnFailureIsolate", bus_property_append_bool, "b", &u->meta.on_failure_isolate }, \
{ "org.freedesktop.systemd1.Unit", "DefaultControlGroup", bus_unit_append_default_cgroup, "s", u }, \
{ "org.freedesktop.systemd1.Unit", "ControlGroup", bus_unit_append_cgroups, "as", u }, \
{ "org.freedesktop.systemd1.Unit", "NeedDaemonReload", bus_unit_append_need_daemon_reload, "b", u }, \
......
......@@ -563,8 +563,14 @@ int job_finish_and_invalidate(Job *j, JobResult result) {
* the unit itself. We don't tread JOB_CANCELED as failure in
* this context. And JOB_FAILURE is already handled by the
* unit itself. */
if (result == JOB_TIMEOUT || result == JOB_DEPENDENCY)
if (result == JOB_TIMEOUT || result == JOB_DEPENDENCY) {
log_notice("Job %s/%s failed with result '%s'.",
u->meta.id,
job_type_to_string(t),
job_result_to_string(result));
unit_trigger_on_failure(u);
}
/* Try to start the next jobs that can be started */
SET_FOREACH(other, u->meta.dependencies[UNIT_AFTER], i)
......
......@@ -1851,6 +1851,7 @@ static int load_from_path(Unit *u, const char *path) {
{ "RefuseManualStop", config_parse_bool, 0, &u->meta.refuse_manual_stop, "Unit" },
{ "AllowIsolate", config_parse_bool, 0, &u->meta.allow_isolate, "Unit" },
{ "DefaultDependencies", config_parse_bool, 0, &u->meta.default_dependencies, "Unit" },
{ "OnFailureIsolate", config_parse_bool, 0, &u->meta.on_failure_isolate, "Unit" },
{ "JobTimeoutSec", config_parse_usec, 0, &u->meta.job_timeout, "Unit" },
{ "ConditionPathExists", config_parse_condition_path, CONDITION_PATH_EXISTS, u, "Unit" },
{ "ConditionPathIsDirectory", config_parse_condition_path, CONDITION_PATH_IS_DIRECTORY, u, "Unit" },
......
......@@ -666,11 +666,13 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
"%s\tStopWhenUnneeded: %s\n"
"%s\tRefuseManualStart: %s\n"
"%s\tRefuseManualStop: %s\n"
"%s\tDefaultDependencies: %s\n",
"%s\tDefaultDependencies: %s\n"
"%s\rOnFailureIsolate: %s\n",
prefix, yes_no(u->meta.stop_when_unneeded),
prefix, yes_no(u->meta.refuse_manual_start),
prefix, yes_no(u->meta.refuse_manual_stop),
prefix, yes_no(u->meta.default_dependencies));
prefix, yes_no(u->meta.default_dependencies),
prefix, yes_no(u->meta.on_failure_isolate));
LIST_FOREACH(by_unit, b, u->meta.cgroup_bondings)
fprintf(f, "%s\tControlGroup: %s:%s\n",
......@@ -1096,8 +1098,17 @@ void unit_trigger_on_failure(Unit *u) {
assert(u);
SET_FOREACH(other, u->meta.dependencies[UNIT_ON_FAILURE], i)
manager_add_job(u->meta.manager, JOB_START, other, JOB_REPLACE, true, NULL, NULL);
if (set_size(u->meta.dependencies[UNIT_ON_FAILURE]) <= 0)
return;
log_info("Triggering OnFailure= dependencies of %s.", u->meta.id);
SET_FOREACH(other, u->meta.dependencies[UNIT_ON_FAILURE], i) {
int r;
if ((r = manager_add_job(u->meta.manager, JOB_START, other, u->meta.on_failure_isolate ? JOB_ISOLATE : JOB_REPLACE, true, NULL, NULL)) < 0)
log_error("Failed to enqueue OnFailure= job: %s", strerror(-r));
}
}
void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_success) {
......
......@@ -207,6 +207,9 @@ struct Meta {
/* Allow isolation requests */
bool allow_isolate;
/* Isolate OnFailure unit */
bool on_failure_isolate;
/* Did the last condition check suceed? */
bool condition_result;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment