mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
Merge pull request #27673 from YHNdnzj/restartsteps-transient
core,bus-unit-util: add missing RestartSteps and RestartMaxDelaySec to bus_append_service_property
This commit is contained in:
commit
837dfea5ed
@ -2573,7 +2573,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||
readonly u RestartSteps = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||
readonly t RestartUSecMax = ...;
|
||||
readonly t RestartMaxDelayUSec = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t RestartUSecNext = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||
@ -3213,7 +3213,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
|
||||
|
||||
<!--property RestartSteps is not documented!-->
|
||||
|
||||
<!--property RestartUSecMax is not documented!-->
|
||||
<!--property RestartMaxDelayUSec is not documented!-->
|
||||
|
||||
<!--property RestartUSecNext is not documented!-->
|
||||
|
||||
@ -3787,7 +3787,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="RestartSteps"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="RestartUSecMax"/>
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="RestartMaxDelayUSec"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="RestartUSecNext"/>
|
||||
|
||||
|
@ -550,14 +550,14 @@
|
||||
<varlistentry>
|
||||
<term><varname>RestartSteps=</varname></term>
|
||||
<listitem><para>Configures the number of steps to take to increase the interval
|
||||
of auto-restarts from <varname>RestartSec=</varname> to <varname>RestartSecMax=</varname>.
|
||||
of auto-restarts from <varname>RestartSec=</varname> to <varname>RestartMaxDelaySec=</varname>.
|
||||
Takes a positive integer or 0 to disable it. Defaults to 0.</para>
|
||||
|
||||
<para>This setting is effective only if <varname>RestartSecMax=</varname> is also set.</para></listitem>
|
||||
<para>This setting is effective only if <varname>RestartMaxDelaySec=</varname> is also set.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>RestartSecMax=</varname></term>
|
||||
<term><varname>RestartMaxDelaySec=</varname></term>
|
||||
<listitem><para>Configures the longest time to sleep before restarting a service
|
||||
as the interval goes up with <varname>RestartSteps=</varname>. Takes a value
|
||||
in the same format as <varname>RestartSec=</varname>, or <literal>infinity</literal>
|
||||
|
@ -326,7 +326,7 @@ const sd_bus_vtable bus_service_vtable[] = {
|
||||
SD_BUS_PROPERTY("NotifyAccess", "s", property_get_notify_access, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("RestartUSec", "t", bus_property_get_usec, offsetof(Service, restart_usec), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("RestartSteps", "u", bus_property_get_unsigned, offsetof(Service, restart_steps), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("RestartUSecMax", "t", bus_property_get_usec, offsetof(Service, restart_usec_max), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("RestartMaxDelayUSec", "t", bus_property_get_usec, offsetof(Service, restart_max_delay_usec), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("RestartUSecNext", "t", property_get_restart_usec_next, 0, 0),
|
||||
SD_BUS_PROPERTY("TimeoutStartUSec", "t", bus_property_get_usec, offsetof(Service, timeout_start_usec), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("TimeoutStopUSec", "t", bus_property_get_usec, offsetof(Service, timeout_stop_usec), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
@ -561,8 +561,8 @@ static int bus_service_set_transient_property(
|
||||
if (streq(name, "RestartSteps"))
|
||||
return bus_set_transient_unsigned(u, name, &s->restart_steps, message, flags, error);
|
||||
|
||||
if (streq(name, "RestartUSecMax"))
|
||||
return bus_set_transient_usec(u, name, &s->restart_usec_max, message, flags, error);
|
||||
if (streq(name, "RestartMaxDelayUSec"))
|
||||
return bus_set_transient_usec(u, name, &s->restart_max_delay_usec, message, flags, error);
|
||||
|
||||
if (streq(name, "TimeoutStartUSec")) {
|
||||
r = bus_set_transient_usec(u, name, &s->timeout_start_usec, message, flags, error);
|
||||
|
@ -405,7 +405,7 @@ Service.ExecStop, config_parse_exec,
|
||||
Service.ExecStopPost, config_parse_exec, SERVICE_EXEC_STOP_POST, offsetof(Service, exec_command)
|
||||
Service.RestartSec, config_parse_sec, 0, offsetof(Service, restart_usec)
|
||||
Service.RestartSteps, config_parse_unsigned, 0, offsetof(Service, restart_steps)
|
||||
Service.RestartSecMax, config_parse_sec, 0, offsetof(Service, restart_usec_max)
|
||||
Service.RestartMaxDelaySec, config_parse_sec, 0, offsetof(Service, restart_max_delay_usec)
|
||||
Service.TimeoutSec, config_parse_service_timeout, 0, 0
|
||||
Service.TimeoutStartSec, config_parse_service_timeout, 0, 0
|
||||
Service.TimeoutStopSec, config_parse_sec_fix_0, 0, offsetof(Service, timeout_stop_usec)
|
||||
|
@ -122,7 +122,7 @@ static void service_init(Unit *u) {
|
||||
s->timeout_abort_usec = u->manager->default_timeout_abort_usec;
|
||||
s->timeout_abort_set = u->manager->default_timeout_abort_set;
|
||||
s->restart_usec = u->manager->default_restart_usec;
|
||||
s->restart_usec_max = USEC_INFINITY;
|
||||
s->restart_max_delay_usec = USEC_INFINITY;
|
||||
s->runtime_max_usec = USEC_INFINITY;
|
||||
s->type = _SERVICE_TYPE_INVALID;
|
||||
s->socket_fd = -EBADF;
|
||||
@ -293,18 +293,18 @@ usec_t service_restart_usec_next(Service *s) {
|
||||
|
||||
if (n_restarts_next <= 1 ||
|
||||
s->restart_steps == 0 ||
|
||||
s->restart_usec_max == USEC_INFINITY ||
|
||||
s->restart_usec >= s->restart_usec_max)
|
||||
s->restart_max_delay_usec == USEC_INFINITY ||
|
||||
s->restart_usec >= s->restart_max_delay_usec)
|
||||
value = s->restart_usec;
|
||||
else if (n_restarts_next > s->restart_steps)
|
||||
value = s->restart_usec_max;
|
||||
value = s->restart_max_delay_usec;
|
||||
else {
|
||||
/* Enforced in service_verify() and above */
|
||||
assert(s->restart_usec_max > s->restart_usec);
|
||||
assert(s->restart_max_delay_usec > s->restart_usec);
|
||||
|
||||
/* ((restart_usec_max - restart_usec)^(1/restart_steps))^(n_restart_next - 1) */
|
||||
value = usec_add(s->restart_usec,
|
||||
(usec_t) powl(s->restart_usec_max - s->restart_usec,
|
||||
(usec_t) powl(s->restart_max_delay_usec - s->restart_usec,
|
||||
(long double) (n_restarts_next - 1) / s->restart_steps));
|
||||
}
|
||||
|
||||
@ -689,15 +689,15 @@ static int service_verify(Service *s) {
|
||||
if (s->exit_type == SERVICE_EXIT_CGROUP && cg_unified() < CGROUP_UNIFIED_SYSTEMD)
|
||||
log_unit_warning(UNIT(s), "Service has ExitType=cgroup set, but we are running with legacy cgroups v1, which might not work correctly. Continuing.");
|
||||
|
||||
if (s->restart_usec_max == USEC_INFINITY && s->restart_steps > 0)
|
||||
log_unit_warning(UNIT(s), "Service has RestartSteps= but no RestartSecMax= setting. Ignoring.");
|
||||
if (s->restart_max_delay_usec == USEC_INFINITY && s->restart_steps > 0)
|
||||
log_unit_warning(UNIT(s), "Service has RestartSteps= but no RestartMaxDelaySec= setting. Ignoring.");
|
||||
|
||||
if (s->restart_usec_max != USEC_INFINITY && s->restart_steps == 0)
|
||||
log_unit_warning(UNIT(s), "Service has RestartSecMax= but no RestartSteps= setting. Ignoring.");
|
||||
if (s->restart_max_delay_usec != USEC_INFINITY && s->restart_steps == 0)
|
||||
log_unit_warning(UNIT(s), "Service has RestartMaxDelaySec= but no RestartSteps= setting. Ignoring.");
|
||||
|
||||
if (s->restart_usec_max < s->restart_usec) {
|
||||
log_unit_warning(UNIT(s), "RestartSecMax= has a value smaller than RestartSec=, resetting RestartSec= to RestartSecMax=.");
|
||||
s->restart_usec = s->restart_usec_max;
|
||||
if (s->restart_max_delay_usec < s->restart_usec) {
|
||||
log_unit_warning(UNIT(s), "RestartMaxDelaySec= has a value smaller than RestartSec=, resetting RestartSec= to RestartMaxDelaySec=.");
|
||||
s->restart_usec = s->restart_max_delay_usec;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -991,14 +991,14 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
|
||||
fprintf(f,
|
||||
"%sRestartSec: %s\n"
|
||||
"%sRestartSteps: %u\n"
|
||||
"%sRestartSecMax: %s\n"
|
||||
"%sRestartMaxDelaySec: %s\n"
|
||||
"%sTimeoutStartSec: %s\n"
|
||||
"%sTimeoutStopSec: %s\n"
|
||||
"%sTimeoutStartFailureMode: %s\n"
|
||||
"%sTimeoutStopFailureMode: %s\n",
|
||||
prefix, FORMAT_TIMESPAN(s->restart_usec, USEC_PER_SEC),
|
||||
prefix, s->restart_steps,
|
||||
prefix, FORMAT_TIMESPAN(s->restart_usec_max, USEC_PER_SEC),
|
||||
prefix, FORMAT_TIMESPAN(s->restart_max_delay_usec, USEC_PER_SEC),
|
||||
prefix, FORMAT_TIMESPAN(s->timeout_start_usec, USEC_PER_SEC),
|
||||
prefix, FORMAT_TIMESPAN(s->timeout_stop_usec, USEC_PER_SEC),
|
||||
prefix, service_timeout_failure_mode_to_string(s->timeout_start_failure_mode),
|
||||
|
@ -117,7 +117,7 @@ struct Service {
|
||||
|
||||
usec_t restart_usec;
|
||||
unsigned restart_steps;
|
||||
usec_t restart_usec_max;
|
||||
usec_t restart_max_delay_usec;
|
||||
usec_t timeout_start_usec;
|
||||
usec_t timeout_stop_usec;
|
||||
usec_t timeout_abort_usec;
|
||||
|
@ -2210,6 +2210,7 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con
|
||||
return bus_append_parse_boolean(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "RestartSec",
|
||||
"RestartMaxDelaySec",
|
||||
"TimeoutStartSec",
|
||||
"TimeoutStopSec",
|
||||
"TimeoutAbortSec",
|
||||
@ -2226,7 +2227,8 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con
|
||||
return bus_append_parse_sec_rename(m, "TimeoutStopSec", eq);
|
||||
}
|
||||
|
||||
if (streq(field, "FileDescriptorStoreMax"))
|
||||
if (STR_IN_SET(field, "FileDescriptorStoreMax",
|
||||
"RestartSteps"))
|
||||
return bus_append_safe_atou(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "ExecCondition",
|
||||
|
Loading…
Reference in New Issue
Block a user