mirror of
https://github.com/systemd/systemd
synced 2026-04-10 00:54:51 +02:00
Compare commits
No commits in common. "2ed6297f71a04839f23e460095da126112f5626d" and "99f8a6d7f58c9edb00b3d214b685987444dc3931" have entirely different histories.
2ed6297f71
...
99f8a6d7f5
@ -37,10 +37,7 @@ manager, please consider supporting the following interfaces.
|
|||||||
in this context.)
|
in this context.)
|
||||||
|
|
||||||
3. Pre-mount `/dev/` as (container private) `tmpfs` for the container and bind
|
3. Pre-mount `/dev/` as (container private) `tmpfs` for the container and bind
|
||||||
mount some suitable TTY to `/dev/console`. If this is a pty, make sure to not
|
mount some suitable TTY to `/dev/console`. Also, make sure to create device
|
||||||
close the controling pty master during systemd's lifetime. PID1 will close ttys,
|
|
||||||
to avoid being killed by SAK. It only opens ttys for the time it
|
|
||||||
actually needs to print something. Also, make sure to create device
|
|
||||||
nodes for `/dev/null`, `/dev/zero`, `/dev/full`, `/dev/random`,
|
nodes for `/dev/null`, `/dev/zero`, `/dev/full`, `/dev/random`,
|
||||||
`/dev/urandom`, `/dev/tty`, `/dev/ptmx` in `/dev/`. It is not necessary to
|
`/dev/urandom`, `/dev/tty`, `/dev/ptmx` in `/dev/`. It is not necessary to
|
||||||
create `/dev/fd` or `/dev/stdout`, as systemd will do that on its own. Make
|
create `/dev/fd` or `/dev/stdout`, as systemd will do that on its own. Make
|
||||||
|
|||||||
@ -256,8 +256,8 @@
|
|||||||
<para>Specifies the policy for <command>systemd-networkd</command> managing the link
|
<para>Specifies the policy for <command>systemd-networkd</command> managing the link
|
||||||
administrative state. Specifically, this controls how <command>systemd-networkd</command>
|
administrative state. Specifically, this controls how <command>systemd-networkd</command>
|
||||||
changes the network device's <literal>IFF_UP</literal> flag, which is sometimes
|
changes the network device's <literal>IFF_UP</literal> flag, which is sometimes
|
||||||
controlled by system administrators by running e.g., <command>ip link set dev eth0 up</command>
|
controlled by system administrators by running e.g., <command>ip set dev eth0 up</command>
|
||||||
or <command>ip link set dev eth0 down</command>, and can also be changed with
|
or <command>ip set dev eth0 down</command>, and can also be changed with
|
||||||
<command>networkctl up eth0</command> or <command>networkctl down eth0</command>.</para>
|
<command>networkctl up eth0</command> or <command>networkctl down eth0</command>.</para>
|
||||||
|
|
||||||
<para>Takes one of <literal>up</literal>, <literal>always-up</literal>,
|
<para>Takes one of <literal>up</literal>, <literal>always-up</literal>,
|
||||||
|
|||||||
@ -1658,29 +1658,6 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><varname>ConditionMemoryPressure=</varname></term>
|
|
||||||
<term><varname>ConditionCPUPressure=</varname></term>
|
|
||||||
<term><varname>ConditionIOPressure=</varname></term>
|
|
||||||
|
|
||||||
<listitem><para>Verify that the overall system (memory, CPU or IO) pressure is below or equal to a threshold.
|
|
||||||
This setting takes a threshold value as argument. It can be specified as a simple percentage value,
|
|
||||||
suffixed with <literal>%</literal>, in which case the pressure will be measured as an average over the last
|
|
||||||
five minutes before the attempt to start the unit is performed.
|
|
||||||
Alternatively, the average timespan can also be specified using <literal>/</literal> as a separator, for
|
|
||||||
example: <literal>10%/1min</literal>. The supported timespans match what the kernel provides, and are
|
|
||||||
limited to <literal>10sec</literal>, <literal>1min</literal> and <literal>5min</literal>. The
|
|
||||||
<literal>full</literal> PSI will be checked first, and if not found <literal>some</literal> will be
|
|
||||||
checked. For more details, see the documentation on <ulink
|
|
||||||
url="https://www.kernel.org/doc/html/latest/accounting/psi.html">PSI (Pressure Stall Information)
|
|
||||||
</ulink>.</para>
|
|
||||||
|
|
||||||
<para>Optionally, the threshold value can be prefixed with the slice unit under which the pressure will be checked,
|
|
||||||
followed by a <literal>:</literal>. If the slice unit is not specified, the overall system pressure will be measured,
|
|
||||||
instead of a particular cgroup's.</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>AssertArchitecture=</varname></term>
|
<term><varname>AssertArchitecture=</varname></term>
|
||||||
<term><varname>AssertVirtualization=</varname></term>
|
<term><varname>AssertVirtualization=</varname></term>
|
||||||
@ -1709,9 +1686,6 @@
|
|||||||
<term><varname>AssertMemory=</varname></term>
|
<term><varname>AssertMemory=</varname></term>
|
||||||
<term><varname>AssertCPUs=</varname></term>
|
<term><varname>AssertCPUs=</varname></term>
|
||||||
<term><varname>AssertOSRelease=</varname></term>
|
<term><varname>AssertOSRelease=</varname></term>
|
||||||
<term><varname>AssertMemoryPressure=</varname></term>
|
|
||||||
<term><varname>AssertCPUPressure=</varname></term>
|
|
||||||
<term><varname>AssertIOPressure=</varname></term>
|
|
||||||
|
|
||||||
<listitem><para>Similar to the <varname>ConditionArchitecture=</varname>,
|
<listitem><para>Similar to the <varname>ConditionArchitecture=</varname>,
|
||||||
<varname>ConditionVirtualization=</varname>, …, condition settings described above, these settings
|
<varname>ConditionVirtualization=</varname>, …, condition settings described above, these settings
|
||||||
|
|||||||
@ -341,9 +341,6 @@ Unit.ConditionUser, config_parse_unit_condition_string,
|
|||||||
Unit.ConditionGroup, config_parse_unit_condition_string, CONDITION_GROUP, offsetof(Unit, conditions)
|
Unit.ConditionGroup, config_parse_unit_condition_string, CONDITION_GROUP, offsetof(Unit, conditions)
|
||||||
Unit.ConditionControlGroupController, config_parse_unit_condition_string, CONDITION_CONTROL_GROUP_CONTROLLER, offsetof(Unit, conditions)
|
Unit.ConditionControlGroupController, config_parse_unit_condition_string, CONDITION_CONTROL_GROUP_CONTROLLER, offsetof(Unit, conditions)
|
||||||
Unit.ConditionOSRelease, config_parse_unit_condition_string, CONDITION_OS_RELEASE, offsetof(Unit, conditions)
|
Unit.ConditionOSRelease, config_parse_unit_condition_string, CONDITION_OS_RELEASE, offsetof(Unit, conditions)
|
||||||
Unit.ConditionMemoryPressure, config_parse_unit_condition_string, CONDITION_MEMORY_PRESSURE, offsetof(Unit, conditions)
|
|
||||||
Unit.ConditionCPUPressure, config_parse_unit_condition_string, CONDITION_CPU_PRESSURE, offsetof(Unit, conditions)
|
|
||||||
Unit.ConditionIOPressure, config_parse_unit_condition_string, CONDITION_IO_PRESSURE, offsetof(Unit, conditions)
|
|
||||||
Unit.AssertPathExists, config_parse_unit_condition_path, CONDITION_PATH_EXISTS, offsetof(Unit, asserts)
|
Unit.AssertPathExists, config_parse_unit_condition_path, CONDITION_PATH_EXISTS, offsetof(Unit, asserts)
|
||||||
Unit.AssertPathExistsGlob, config_parse_unit_condition_path, CONDITION_PATH_EXISTS_GLOB, offsetof(Unit, asserts)
|
Unit.AssertPathExistsGlob, config_parse_unit_condition_path, CONDITION_PATH_EXISTS_GLOB, offsetof(Unit, asserts)
|
||||||
Unit.AssertPathIsDirectory, config_parse_unit_condition_path, CONDITION_PATH_IS_DIRECTORY, offsetof(Unit, asserts)
|
Unit.AssertPathIsDirectory, config_parse_unit_condition_path, CONDITION_PATH_IS_DIRECTORY, offsetof(Unit, asserts)
|
||||||
@ -371,9 +368,6 @@ Unit.AssertUser, config_parse_unit_condition_string,
|
|||||||
Unit.AssertGroup, config_parse_unit_condition_string, CONDITION_GROUP, offsetof(Unit, asserts)
|
Unit.AssertGroup, config_parse_unit_condition_string, CONDITION_GROUP, offsetof(Unit, asserts)
|
||||||
Unit.AssertControlGroupController, config_parse_unit_condition_string, CONDITION_CONTROL_GROUP_CONTROLLER, offsetof(Unit, asserts)
|
Unit.AssertControlGroupController, config_parse_unit_condition_string, CONDITION_CONTROL_GROUP_CONTROLLER, offsetof(Unit, asserts)
|
||||||
Unit.AssertOSRelease, config_parse_unit_condition_string, CONDITION_OS_RELEASE, offsetof(Unit, asserts)
|
Unit.AssertOSRelease, config_parse_unit_condition_string, CONDITION_OS_RELEASE, offsetof(Unit, asserts)
|
||||||
Unit.AssertMemoryPressure, config_parse_unit_condition_string, CONDITION_MEMORY_PRESSURE, offsetof(Unit, asserts)
|
|
||||||
Unit.AssertCPUPressure, config_parse_unit_condition_string, CONDITION_CPU_PRESSURE, offsetof(Unit, asserts)
|
|
||||||
Unit.AssertIOPressure, config_parse_unit_condition_string, CONDITION_IO_PRESSURE, offsetof(Unit, asserts)
|
|
||||||
Unit.CollectMode, config_parse_collect_mode, 0, offsetof(Unit, collect_mode)
|
Unit.CollectMode, config_parse_collect_mode, 0, offsetof(Unit, collect_mode)
|
||||||
Service.PIDFile, config_parse_pid_file, 0, offsetof(Service, pid_file)
|
Service.PIDFile, config_parse_pid_file, 0, offsetof(Service, pid_file)
|
||||||
Service.ExecCondition, config_parse_exec, SERVICE_EXEC_CONDITION, offsetof(Service, exec_command)
|
Service.ExecCondition, config_parse_exec, SERVICE_EXEC_CONDITION, offsetof(Service, exec_command)
|
||||||
|
|||||||
@ -39,10 +39,8 @@
|
|||||||
#include "os-util.h"
|
#include "os-util.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
#include "percent-util.h"
|
|
||||||
#include "proc-cmdline.h"
|
#include "proc-cmdline.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "psi-util.h"
|
|
||||||
#include "selinux-util.h"
|
#include "selinux-util.h"
|
||||||
#include "smack-util.h"
|
#include "smack-util.h"
|
||||||
#include "stat-util.h"
|
#include "stat-util.h"
|
||||||
@ -964,131 +962,6 @@ static int condition_test_file_is_executable(Condition *c, char **env) {
|
|||||||
(st.st_mode & 0111));
|
(st.st_mode & 0111));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int condition_test_psi(Condition *c, char **env) {
|
|
||||||
_cleanup_free_ char *first = NULL, *second = NULL, *third = NULL, *fourth = NULL, *pressure_path = NULL;
|
|
||||||
const char *p, *value, *pressure_type;
|
|
||||||
loadavg_t *current, limit;
|
|
||||||
ResourcePressure pressure;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(c);
|
|
||||||
assert(c->parameter);
|
|
||||||
assert(IN_SET(c->type, CONDITION_MEMORY_PRESSURE, CONDITION_CPU_PRESSURE, CONDITION_IO_PRESSURE));
|
|
||||||
|
|
||||||
if (!is_pressure_supported()) {
|
|
||||||
log_debug("Pressure Stall Information (PSI) is not supported, skipping.");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pressure_type = c->type == CONDITION_MEMORY_PRESSURE ? "memory" :
|
|
||||||
c->type == CONDITION_CPU_PRESSURE ? "cpu" :
|
|
||||||
"io";
|
|
||||||
|
|
||||||
p = c->parameter;
|
|
||||||
r = extract_many_words(&p, ":", 0, &first, &second, NULL);
|
|
||||||
if (r <= 0)
|
|
||||||
return log_debug_errno(r < 0 ? r : SYNTHETIC_ERRNO(EINVAL), "Failed to parse condition parameter %s: %m", c->parameter);
|
|
||||||
/* If only one parameter is passed, then we look at the global system pressure rather than a specific cgroup. */
|
|
||||||
if (r == 1) {
|
|
||||||
pressure_path = path_join("/proc/pressure", pressure_type);
|
|
||||||
if (!pressure_path)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
value = first;
|
|
||||||
} else {
|
|
||||||
const char *controller = strjoina(pressure_type, ".pressure");
|
|
||||||
_cleanup_free_ char *slice_path = NULL;
|
|
||||||
CGroupMask mask, required_mask;
|
|
||||||
char *slice;
|
|
||||||
|
|
||||||
required_mask = c->type == CONDITION_MEMORY_PRESSURE ? CGROUP_MASK_MEMORY :
|
|
||||||
c->type == CONDITION_CPU_PRESSURE ? CGROUP_MASK_CPU :
|
|
||||||
CGROUP_MASK_IO;
|
|
||||||
|
|
||||||
slice = strstrip(first);
|
|
||||||
if (!slice)
|
|
||||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse condition parameter %s: %m", c->parameter);
|
|
||||||
|
|
||||||
r = cg_all_unified();
|
|
||||||
if (r < 0)
|
|
||||||
return log_debug_errno(r, "Failed to determine whether the unified cgroups hierarchy is used: %m");
|
|
||||||
if (r == 0) {
|
|
||||||
log_debug("PSI condition check requires the unified cgroups hierarchy, skipping.");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = cg_mask_supported(&mask);
|
|
||||||
if (r < 0)
|
|
||||||
return log_debug_errno(r, "Failed to get supported cgroup controllers: %m");
|
|
||||||
|
|
||||||
if (!FLAGS_SET(mask, required_mask)) {
|
|
||||||
log_debug("Cgroup %s controller not available, skipping PSI condition check.", pressure_type);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = cg_slice_to_path(slice, &slice_path);
|
|
||||||
if (r < 0)
|
|
||||||
return log_debug_errno(r, "Cannot determine slice \"%s\" cgroup path: %m", slice);
|
|
||||||
|
|
||||||
r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, slice_path, controller, &pressure_path);
|
|
||||||
if (r < 0)
|
|
||||||
return log_debug_errno(r, "Error getting cgroup pressure path from %s: %m", slice_path);
|
|
||||||
|
|
||||||
value = second;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If a value including a specific timespan (in the intervals allowed by the kernel),
|
|
||||||
* parse it, otherwise we assume just a plain percentage that will be checked if it is
|
|
||||||
* smaller or equal to the current pressure average over 5 minutes. */
|
|
||||||
r = extract_many_words(&value, "/", 0, &third, &fourth, NULL);
|
|
||||||
if (r <= 0)
|
|
||||||
return log_debug_errno(r < 0 ? r : SYNTHETIC_ERRNO(EINVAL), "Failed to parse condition parameter %s: %m", c->parameter);
|
|
||||||
if (r == 1)
|
|
||||||
current = &pressure.avg300;
|
|
||||||
else {
|
|
||||||
const char *timespan;
|
|
||||||
|
|
||||||
timespan = skip_leading_chars(fourth, NULL);
|
|
||||||
if (!timespan)
|
|
||||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse condition parameter %s: %m", c->parameter);
|
|
||||||
|
|
||||||
if (startswith(timespan, "10sec"))
|
|
||||||
current = &pressure.avg10;
|
|
||||||
else if (startswith(timespan, "1min"))
|
|
||||||
current = &pressure.avg60;
|
|
||||||
else if (startswith(timespan, "5min"))
|
|
||||||
current = &pressure.avg300;
|
|
||||||
else
|
|
||||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse condition parameter %s: %m", c->parameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
value = strstrip(third);
|
|
||||||
if (!value)
|
|
||||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse condition parameter %s: %m", c->parameter);
|
|
||||||
|
|
||||||
r = parse_permyriad(value);
|
|
||||||
if (r < 0)
|
|
||||||
return log_debug_errno(r, "Failed to parse permyriad: %s", c->parameter);
|
|
||||||
|
|
||||||
r = store_loadavg_fixed_point(r / 100LU, r % 100LU, &limit);
|
|
||||||
if (r < 0)
|
|
||||||
return log_debug_errno(r, "Failed to parse loadavg: %s", c->parameter);
|
|
||||||
|
|
||||||
r = read_resource_pressure(pressure_path, PRESSURE_TYPE_FULL, &pressure);
|
|
||||||
if (r == -ENODATA) /* cpu.pressure 'full' was added recently, fall back to 'some'. */
|
|
||||||
r = read_resource_pressure(pressure_path, PRESSURE_TYPE_SOME, &pressure);
|
|
||||||
if (r == -ENOENT) {
|
|
||||||
/* We already checked that /proc/pressure exists, so this means we were given a cgroup
|
|
||||||
* that doesn't exist or doesn't exist any longer. */
|
|
||||||
log_debug("\"%s\" not found, skipping PSI check.", pressure_path);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (r < 0)
|
|
||||||
return log_debug_errno(r, "Error parsing pressure from %s: %m", pressure_path);
|
|
||||||
|
|
||||||
return *current <= limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
int condition_test(Condition *c, char **env) {
|
int condition_test(Condition *c, char **env) {
|
||||||
|
|
||||||
static int (*const condition_tests[_CONDITION_TYPE_MAX])(Condition *c, char **env) = {
|
static int (*const condition_tests[_CONDITION_TYPE_MAX])(Condition *c, char **env) = {
|
||||||
@ -1121,9 +994,6 @@ int condition_test(Condition *c, char **env) {
|
|||||||
[CONDITION_ENVIRONMENT] = condition_test_environment,
|
[CONDITION_ENVIRONMENT] = condition_test_environment,
|
||||||
[CONDITION_CPU_FEATURE] = condition_test_cpufeature,
|
[CONDITION_CPU_FEATURE] = condition_test_cpufeature,
|
||||||
[CONDITION_OS_RELEASE] = condition_test_osrelease,
|
[CONDITION_OS_RELEASE] = condition_test_osrelease,
|
||||||
[CONDITION_MEMORY_PRESSURE] = condition_test_psi,
|
|
||||||
[CONDITION_CPU_PRESSURE] = condition_test_psi,
|
|
||||||
[CONDITION_IO_PRESSURE] = condition_test_psi,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int r, b;
|
int r, b;
|
||||||
@ -1249,9 +1119,6 @@ static const char* const condition_type_table[_CONDITION_TYPE_MAX] = {
|
|||||||
[CONDITION_ENVIRONMENT] = "ConditionEnvironment",
|
[CONDITION_ENVIRONMENT] = "ConditionEnvironment",
|
||||||
[CONDITION_CPU_FEATURE] = "ConditionCPUFeature",
|
[CONDITION_CPU_FEATURE] = "ConditionCPUFeature",
|
||||||
[CONDITION_OS_RELEASE] = "ConditionOSRelease",
|
[CONDITION_OS_RELEASE] = "ConditionOSRelease",
|
||||||
[CONDITION_MEMORY_PRESSURE] = "ConditionMemoryPressure",
|
|
||||||
[CONDITION_CPU_PRESSURE] = "ConditionCPUPressure",
|
|
||||||
[CONDITION_IO_PRESSURE] = "ConditionIOPressure",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_STRING_TABLE_LOOKUP(condition_type, ConditionType);
|
DEFINE_STRING_TABLE_LOOKUP(condition_type, ConditionType);
|
||||||
@ -1286,9 +1153,6 @@ static const char* const assert_type_table[_CONDITION_TYPE_MAX] = {
|
|||||||
[CONDITION_ENVIRONMENT] = "AssertEnvironment",
|
[CONDITION_ENVIRONMENT] = "AssertEnvironment",
|
||||||
[CONDITION_CPU_FEATURE] = "AssertCPUFeature",
|
[CONDITION_CPU_FEATURE] = "AssertCPUFeature",
|
||||||
[CONDITION_OS_RELEASE] = "AssertOSRelease",
|
[CONDITION_OS_RELEASE] = "AssertOSRelease",
|
||||||
[CONDITION_MEMORY_PRESSURE] = "AssertMemoryPressure",
|
|
||||||
[CONDITION_CPU_PRESSURE] = "AssertCPUPressure",
|
|
||||||
[CONDITION_IO_PRESSURE] = "AssertIOPressure",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_STRING_TABLE_LOOKUP(assert_type, ConditionType);
|
DEFINE_STRING_TABLE_LOOKUP(assert_type, ConditionType);
|
||||||
|
|||||||
@ -22,9 +22,6 @@ typedef enum ConditionType {
|
|||||||
CONDITION_ENVIRONMENT,
|
CONDITION_ENVIRONMENT,
|
||||||
CONDITION_CPU_FEATURE,
|
CONDITION_CPU_FEATURE,
|
||||||
CONDITION_OS_RELEASE,
|
CONDITION_OS_RELEASE,
|
||||||
CONDITION_MEMORY_PRESSURE,
|
|
||||||
CONDITION_CPU_PRESSURE,
|
|
||||||
CONDITION_IO_PRESSURE,
|
|
||||||
|
|
||||||
CONDITION_NEEDS_UPDATE,
|
CONDITION_NEEDS_UPDATE,
|
||||||
CONDITION_FIRST_BOOT,
|
CONDITION_FIRST_BOOT,
|
||||||
|
|||||||
@ -25,7 +25,6 @@
|
|||||||
#include "nulstr-util.h"
|
#include "nulstr-util.h"
|
||||||
#include "os-util.h"
|
#include "os-util.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "psi-util.h"
|
|
||||||
#include "selinux-util.h"
|
#include "selinux-util.h"
|
||||||
#include "set.h"
|
#include "set.h"
|
||||||
#include "smack-util.h"
|
#include "smack-util.h"
|
||||||
@ -1032,158 +1031,4 @@ TEST(condition_test_os_release) {
|
|||||||
condition_free(condition);
|
condition_free(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(condition_test_psi) {
|
|
||||||
Condition *condition;
|
|
||||||
CGroupMask mask;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
if (!is_pressure_supported())
|
|
||||||
return (void) log_notice("Pressure Stall Information (PSI) is not supported, skipping %s", __func__);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_MEMORY_PRESSURE, "", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) < 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "sbarabau", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) < 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_MEMORY_PRESSURE, "10%sbarabau", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) < 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "10% sbarabau", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) < 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "-10", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) < 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "10%/10min", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) < 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "10min/10%", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) < 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "10% 5min", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) < 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "/5min", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) < 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_IO_PRESSURE, "10s / ", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) < 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_MEMORY_PRESSURE, "100%", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_MEMORY_PRESSURE, "0%", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_MEMORY_PRESSURE, "0.0%", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "100%", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "0%", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "0.0%", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "0.01%", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "0.0%/10sec", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "100.0% / 1min", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_IO_PRESSURE, "50.0% / 1min", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
r = cg_all_unified();
|
|
||||||
if (r < 0)
|
|
||||||
return (void) log_notice("Failed to determine whether the unified cgroups hierarchy is used, skipping %s", __func__);
|
|
||||||
if (r == 0)
|
|
||||||
return (void) log_notice("Requires the unified cgroups hierarchy, skipping %s", __func__);
|
|
||||||
|
|
||||||
if (cg_mask_supported(&mask) < 0)
|
|
||||||
return (void) log_notice("Failed to get supported cgroup controllers, skipping %s", __func__);
|
|
||||||
|
|
||||||
if (!FLAGS_SET(mask, CGROUP_MASK_MEMORY))
|
|
||||||
return (void) log_notice("Requires the cgroup memory controller, skipping %s", __func__);
|
|
||||||
|
|
||||||
if (!FLAGS_SET(mask, CGROUP_MASK_CPU))
|
|
||||||
return (void) log_notice("Requires the cgroup CPU controller, skipping %s", __func__);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_MEMORY_PRESSURE, " : / ", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) < 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "hopefullythisisnotarealone.slice:100% / 10sec", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) > 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_CPU_PRESSURE, "-.slice:100.0% / 1min", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_MEMORY_PRESSURE, "-.slice:0.0%/5min", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_MEMORY_PRESSURE, "-.slice:100.0%", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
|
|
||||||
condition = condition_new(CONDITION_IO_PRESSURE, "-.slice:0.0%", false, false);
|
|
||||||
assert_se(condition);
|
|
||||||
assert_se(condition_test(condition, environ) >= 0);
|
|
||||||
condition_free(condition);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_TEST_MAIN(LOG_DEBUG);
|
DEFINE_TEST_MAIN(LOG_DEBUG);
|
||||||
|
|||||||
@ -12,17 +12,14 @@ AssertACPower=
|
|||||||
AssertArchitecture=
|
AssertArchitecture=
|
||||||
AssertCapability=
|
AssertCapability=
|
||||||
AssertControlGroupController=
|
AssertControlGroupController=
|
||||||
AssertCPUPressure=
|
|
||||||
AssertDirectoryNotEmpty=
|
AssertDirectoryNotEmpty=
|
||||||
AssertFileIsExecutable=
|
AssertFileIsExecutable=
|
||||||
AssertFileNotEmpty=
|
AssertFileNotEmpty=
|
||||||
AssertFirstBoot=
|
AssertFirstBoot=
|
||||||
AssertGroup=
|
AssertGroup=
|
||||||
AssertHost=
|
AssertHost=
|
||||||
AssertIOPressure=
|
|
||||||
AssertKernelCommandLine=
|
AssertKernelCommandLine=
|
||||||
AssertKernelVersion=
|
AssertKernelVersion=
|
||||||
AssertMemoryPressure=
|
|
||||||
AssertNeedsUpdate=
|
AssertNeedsUpdate=
|
||||||
AssertOSRelease=
|
AssertOSRelease=
|
||||||
AssertPathExists=
|
AssertPathExists=
|
||||||
@ -59,17 +56,14 @@ ConditionACPower=
|
|||||||
ConditionArchitecture=
|
ConditionArchitecture=
|
||||||
ConditionCapability=
|
ConditionCapability=
|
||||||
ConditionControlGroupController=
|
ConditionControlGroupController=
|
||||||
ConditionCPUPressure=
|
|
||||||
ConditionDirectoryNotEmpty=
|
ConditionDirectoryNotEmpty=
|
||||||
ConditionFileIsExecutable=
|
ConditionFileIsExecutable=
|
||||||
ConditionFileNotEmpty=
|
ConditionFileNotEmpty=
|
||||||
ConditionFirstBoot=
|
ConditionFirstBoot=
|
||||||
ConditionGroup=
|
ConditionGroup=
|
||||||
ConditionHost=
|
ConditionHost=
|
||||||
ConditionIOPressure=
|
|
||||||
ConditionKernelCommandLine=
|
ConditionKernelCommandLine=
|
||||||
ConditionKernelVersion=
|
ConditionKernelVersion=
|
||||||
ConditionMemoryPressure=
|
|
||||||
ConditionNeedsUpdate=
|
ConditionNeedsUpdate=
|
||||||
ConditionOSRelease=
|
ConditionOSRelease=
|
||||||
ConditionPathExists=
|
ConditionPathExists=
|
||||||
|
|||||||
@ -4,7 +4,6 @@ After=
|
|||||||
AllowIsolate=
|
AllowIsolate=
|
||||||
AssertACPower=
|
AssertACPower=
|
||||||
AssertArchitecture=
|
AssertArchitecture=
|
||||||
AssertCPUPressure=
|
|
||||||
AssertCPUs=
|
AssertCPUs=
|
||||||
AssertCapability=
|
AssertCapability=
|
||||||
AssertControlGroupController=
|
AssertControlGroupController=
|
||||||
@ -15,11 +14,9 @@ AssertFileNotEmpty=
|
|||||||
AssertFirstBoot=
|
AssertFirstBoot=
|
||||||
AssertGroup=
|
AssertGroup=
|
||||||
AssertHost=
|
AssertHost=
|
||||||
AssertIOPressure=
|
|
||||||
AssertKernelCommandLine=
|
AssertKernelCommandLine=
|
||||||
AssertKernelVersion=
|
AssertKernelVersion=
|
||||||
AssertMemory=
|
AssertMemory=
|
||||||
AssertMemoryPressure=
|
|
||||||
AssertNeedsUpdate=
|
AssertNeedsUpdate=
|
||||||
AssertOSRelease=
|
AssertOSRelease=
|
||||||
AssertPathExists=
|
AssertPathExists=
|
||||||
@ -40,7 +37,6 @@ BindsTo=
|
|||||||
CollectMode=
|
CollectMode=
|
||||||
ConditionACPower=
|
ConditionACPower=
|
||||||
ConditionArchitecture=
|
ConditionArchitecture=
|
||||||
ConditionCPUPressure=
|
|
||||||
ConditionCPUs=
|
ConditionCPUs=
|
||||||
ConditionFirmware=
|
ConditionFirmware=
|
||||||
ConditionCapability=
|
ConditionCapability=
|
||||||
@ -52,11 +48,9 @@ ConditionFileNotEmpty=
|
|||||||
ConditionFirstBoot=
|
ConditionFirstBoot=
|
||||||
ConditionGroup=
|
ConditionGroup=
|
||||||
ConditionHost=
|
ConditionHost=
|
||||||
ConditionIOPressure=
|
|
||||||
ConditionKernelCommandLine=
|
ConditionKernelCommandLine=
|
||||||
ConditionKernelVersion=
|
ConditionKernelVersion=
|
||||||
ConditionMemory=
|
ConditionMemory=
|
||||||
ConditionMemoryPressure=
|
|
||||||
ConditionNeedsUpdate=
|
ConditionNeedsUpdate=
|
||||||
ConditionOSRelease=
|
ConditionOSRelease=
|
||||||
ConditionPathExists=
|
ConditionPathExists=
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user