mirror of
https://github.com/systemd/systemd.git
synced 2024-11-27 12:13:33 +08:00
unit: get rid of gnoreDependencyFailure= instead treat ConflictedBy= as weaker counterpart of Conflicts=, similar to Wants= vs. Requires=
This commit is contained in:
parent
9ed81015f0
commit
ead8e4788e
@ -543,20 +543,6 @@
|
||||
ones.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>IgnoreDependencyFailure=</varname></term>
|
||||
|
||||
<listitem><para>Takes a boolean
|
||||
argument. If <option>true</option> and
|
||||
a requirement dependency of this unit
|
||||
fails to start up this unit will be
|
||||
started nonetheless, ignoring that
|
||||
failure. If <option>false</option>
|
||||
(the default) and a dependency unit
|
||||
fails the unit will immediately fail
|
||||
too and the job is removed.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>JobTimeoutSec=</varname></term>
|
||||
|
||||
|
@ -154,7 +154,7 @@ static int automount_add_default_dependencies(Automount *a) {
|
||||
|
||||
if (a->meta.manager->running_as == MANAGER_SYSTEM) {
|
||||
|
||||
if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
|
||||
if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
|
17
src/job.c
17
src/job.c
@ -500,16 +500,14 @@ int job_finish_and_invalidate(Job *j, bool success) {
|
||||
t == JOB_RELOAD_OR_START) {
|
||||
|
||||
SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i)
|
||||
if (!other->meta.ignore_dependency_failure &&
|
||||
other->meta.job &&
|
||||
if (other->meta.job &&
|
||||
(other->meta.job->type == JOB_START ||
|
||||
other->meta.job->type == JOB_VERIFY_ACTIVE ||
|
||||
other->meta.job->type == JOB_RELOAD_OR_START))
|
||||
job_finish_and_invalidate(other->meta.job, false);
|
||||
|
||||
SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i)
|
||||
if (!other->meta.ignore_dependency_failure &&
|
||||
other->meta.job &&
|
||||
if (other->meta.job &&
|
||||
!other->meta.job->override &&
|
||||
(other->meta.job->type == JOB_START ||
|
||||
other->meta.job->type == JOB_VERIFY_ACTIVE ||
|
||||
@ -519,16 +517,7 @@ int job_finish_and_invalidate(Job *j, bool success) {
|
||||
} else if (t == JOB_STOP) {
|
||||
|
||||
SET_FOREACH(other, u->meta.dependencies[UNIT_CONFLICTS], i)
|
||||
if (!other->meta.ignore_dependency_failure &&
|
||||
other->meta.job &&
|
||||
(other->meta.job->type == JOB_START ||
|
||||
other->meta.job->type == JOB_VERIFY_ACTIVE ||
|
||||
other->meta.job->type == JOB_RELOAD_OR_START))
|
||||
job_finish_and_invalidate(other->meta.job, false);
|
||||
|
||||
SET_FOREACH(other, u->meta.dependencies[UNIT_CONFLICTED_BY], i)
|
||||
if (!other->meta.ignore_dependency_failure &&
|
||||
other->meta.job &&
|
||||
if (other->meta.job &&
|
||||
(other->meta.job->type == JOB_START ||
|
||||
other->meta.job->type == JOB_VERIFY_ACTIVE ||
|
||||
other->meta.job->type == JOB_RELOAD_OR_START))
|
||||
|
@ -1775,7 +1775,6 @@ static int load_from_path(Unit *u, const char *path) {
|
||||
{ "RefuseManualStop", config_parse_bool, &u->meta.refuse_manual_stop, "Unit" },
|
||||
{ "AllowIsolate", config_parse_bool, &u->meta.allow_isolate, "Unit" },
|
||||
{ "DefaultDependencies", config_parse_bool, &u->meta.default_dependencies, "Unit" },
|
||||
{ "IgnoreDependencyFailure",config_parse_bool, &u->meta.ignore_dependency_failure, "Unit" },
|
||||
{ "JobTimeoutSec", config_parse_usec, &u->meta.job_timeout, "Unit" },
|
||||
{ "ConditionPathExists", config_parse_condition_path, u, "Unit" },
|
||||
{ "ConditionKernelCommandLine", config_parse_condition_kernel, u, "Unit" },
|
||||
|
@ -1483,7 +1483,7 @@ static int transaction_add_job_and_dependencies(
|
||||
goto fail;
|
||||
|
||||
SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_CONFLICTED_BY], i)
|
||||
if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, true, override, false, e, NULL)) < 0 && r != -EBADR)
|
||||
if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, false, override, false, e, NULL)) < 0 && r != -EBADR)
|
||||
goto fail;
|
||||
|
||||
} else if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_RESTART) {
|
||||
|
@ -398,7 +398,7 @@ static int mount_add_default_dependencies(Mount *m) {
|
||||
if ((r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, SPECIAL_QUOTACHECK_SERVICE, NULL, true)) < 0)
|
||||
return r;
|
||||
|
||||
if ((r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
|
||||
if ((r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ static int path_add_default_dependencies(Path *p) {
|
||||
if ((r = unit_add_two_dependencies_by_name(UNIT(p), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
|
||||
return r;
|
||||
|
||||
return unit_add_two_dependencies_by_name(UNIT(p), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true);
|
||||
return unit_add_two_dependencies_by_name(UNIT(p), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
|
||||
}
|
||||
|
||||
static int path_load(Unit *u) {
|
||||
|
@ -1021,7 +1021,7 @@ static int service_add_default_dependencies(Service *s) {
|
||||
}
|
||||
|
||||
/* Second, activate normal shutdown */
|
||||
return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true);
|
||||
return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
|
||||
}
|
||||
|
||||
static int service_load(Unit *u) {
|
||||
@ -3017,7 +3017,7 @@ static int service_enumerate(Manager *m) {
|
||||
if (service->meta.fragment_path)
|
||||
continue;
|
||||
|
||||
if ((r = unit_add_two_dependencies_by_name_inverse(service, UNIT_AFTER, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true)) < 0)
|
||||
if ((r = unit_add_two_dependencies_by_name(service, UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true)) < 0)
|
||||
goto finish;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ static int socket_add_default_dependencies(Socket *s) {
|
||||
if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
|
||||
return r;
|
||||
|
||||
return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true);
|
||||
return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
|
||||
}
|
||||
|
||||
static int socket_load(Unit *u) {
|
||||
|
@ -211,7 +211,7 @@ static int swap_add_default_dependencies(Swap *s) {
|
||||
|
||||
if (s->meta.manager->running_as == MANAGER_SYSTEM) {
|
||||
|
||||
if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
|
||||
if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ static int target_add_default_dependencies(Target *t) {
|
||||
return r;
|
||||
|
||||
/* Make sure targets are unloaded on shutdown */
|
||||
return unit_add_dependency_by_name(UNIT(t), UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true);
|
||||
return unit_add_dependency_by_name(UNIT(t), UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
|
||||
}
|
||||
|
||||
static int target_add_getty_dependencies(Target *t) {
|
||||
|
@ -82,7 +82,7 @@ static int timer_add_default_dependencies(Timer *t) {
|
||||
if ((r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
|
||||
return r;
|
||||
|
||||
return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true);
|
||||
return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
|
||||
}
|
||||
|
||||
static int timer_load(Unit *u) {
|
||||
|
@ -655,13 +655,11 @@ 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\tIgnoreDependencyFailure: %s\n",
|
||||
"%s\tDefaultDependencies: %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.ignore_dependency_failure));
|
||||
prefix, yes_no(u->meta.default_dependencies));
|
||||
|
||||
LIST_FOREACH(by_unit, b, u->meta.cgroup_bondings)
|
||||
fprintf(f, "%s\tControlGroup: %s:%s\n",
|
||||
|
@ -199,9 +199,6 @@ struct Meta {
|
||||
/* Create default depedencies */
|
||||
bool default_dependencies;
|
||||
|
||||
/* Bring up this unit even if a dependency fails to start */
|
||||
bool ignore_dependency_failure;
|
||||
|
||||
/* Refuse manual starting, allow starting only indirectly via dependency. */
|
||||
bool refuse_manual_start;
|
||||
|
||||
|
@ -11,5 +11,4 @@
|
||||
Description=Final Step
|
||||
DefaultDependencies=no
|
||||
RefuseManualStart=yes
|
||||
IgnoreDependencyFailure=yes
|
||||
After=shutdown.target umount.target
|
||||
|
@ -11,4 +11,3 @@
|
||||
Description=Shutdown
|
||||
DefaultDependencies=no
|
||||
RefuseManualStart=yes
|
||||
IgnoreDependencyFailure=yes
|
||||
|
@ -11,4 +11,3 @@
|
||||
Description=Unmount All Filesystems
|
||||
DefaultDependencies=no
|
||||
RefuseManualStart=yes
|
||||
IgnoreDependencyFailure=yes
|
||||
|
Loading…
Reference in New Issue
Block a user