1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00
Commit Graph

26 Commits

Author SHA1 Message Date
Frantisek Sumsal
a2dd592002 test: unify checking for user xattrs support in cgroupfs
Also, run the coredump forwarding test only if user xattrs are
supported.
2023-10-19 18:01:07 +01:00
Luca Boccassi
bb5232b6a3 core: add systemd-executor binary
Currently we spawn services by forking a child process, doing a bunch
of work, and then exec'ing the service executable.

There are some advantages to this approach:

- quick: we immediately have access to all the enourmous amount of
  state simply by virtue of sharing the memory with the parent
- easy to refactor and add features
- part of the same binary, will never be out of sync

There are however significant drawbacks:

- doing work after fork and before exec is against glibc's supported
  case for several APIs we call
- copy-on-write trap: anytime any memory is touched in either parent
  or child, a copy of that page will be triggered
- memory footprint of the child process will be memory footprint of
  PID1, but using the cgroup memory limits of the unit

The last issue is especially problematic on resource constrained
systems where hard memory caps are enforced and swap is not allowed.
As soon as PID1 is under load, with no page out due to no swap, and a
service with a low MemoryMax= tries to start, hilarity ensues.

Add a new systemd-executor binary, that is able to receive all the
required state via memfd, deserialize it, prepare the appropriate
data structures and call exec_child.

Use posix_spawn which uses CLONE_VM + CLONE_VFORK, to ensure there is
no copy-on-write (same address space will be used, and parent process
will be frozen, until exec).
The sd-executor binary is pinned by FD on startup, so that we can
guarantee there will be no incompatibilities during upgrades.
2023-10-12 15:01:51 +01:00
Frantisek Sumsal
07268394d6 test: unify /testok & /failed handling
And drop it where not necessary.
2023-07-12 16:03:40 +02:00
Luca Boccassi
f434f182cc TEST-55-OOMD: use swap file instead of partition
The partition seems not to work on Ubuntu for some reason, use a
swap file instead
2023-06-24 11:48:51 +01:00
Luca Boccassi
937e82cb7d TEST-55-OOMD: use 'stress' to create high pressure
The test fails on my machine, running Debian stable, because
testsuite-55-testbloat.service just swaps and never goes over the
limit, so it's not killed. Use 'stress' instead which seems to be
able to overwhelm the swap too.
2023-06-24 11:48:51 +01:00
Luca Boccassi
6acbb3f2fb TEST-55-OOMD: improve ephemeral configuration readability 2023-06-17 00:08:09 +01:00
Luca Boccassi
565b13f8b2 TEST-55-OOMD: use /run/ for configuration instead of /etc/
Make sure configuration is ephemeral if the image is reused
2023-06-17 00:08:09 +01:00
Luca Boccassi
020b2e41ea core: ensure init.scope is realized after drop-ins have been loaded
If we add a drop-in for init.scope (e.g.: to set some memory limit),
it will be loaded long after the cgroup has already been realized.
Do it again when creating the special unit.
2023-01-23 21:40:54 +01:00
Frantisek Sumsal
c84d1c9822 test: don't flush debug logs to the console
Let's keep the debug logs in the journal, while logging only
testsute-*.sh stdout/stderr to the console (ba7abf7). This should make
the test output log a bit more readable and potentially the tests itself
a bit faster by avoiding console oversaturation.

Also, it should significantly reduce the size of artifacts kept by CIs.
2022-06-17 15:06:59 +02:00
Michael Biebl
d338b1713a test: enable systemd-oomd.service
Enable the service to ensure dbus-org.freedesktop.oom1.service exists
and D-Bus activation works.

See #18469
2022-01-12 12:29:34 +01:00
Frantisek Sumsal
fd5e5a87fb test: explicitly configure oomd stuff via dropins
so we don't get overridden by distro-shipped ones.

Fixes: #22030
2022-01-09 17:56:57 +00:00
Anita Zhang
ddc57d0a83 test: make test-55-oomd less flaky
Make oomctl a bit less likely to race with systemd-oomd receiving the
managed oom cgroup info by checking oomctl output in a loop with
timeout.

Fixes #21146
2021-11-26 12:27:30 +01:00
Frantisek Sumsal
c83f126a41 test: drop the su wrapper and use systemctl directly
ASan is having a hard time to get its LD_PRELOAD= shenanigans straight
with all the shells flying around. Let's make it a bit easier by using
one of the nifty systemctl's features instead.
2021-11-22 22:12:41 +01:00
Zbigniew Jędrzejewski-Szmek
7b3cec95db tests: add spdx headers to scripts and Makefiles 2021-10-18 09:04:45 +02:00
Daan De Meyer
064a5c1438 oom: Add support for user unit ManagedOOM property updates
Compared to PID1 where systemd-oomd has to be the client to PID1
because PID1 is a more privileged process than systemd-oomd, systemd-oomd
is the more privileged process compared to a user manager so we have
user managers be the client whereas systemd-oomd is now the server.

The same varlink protocol is used between user managers and systemd-oomd
to deliver ManagedOOM property updates. systemd-oomd now sets up a varlink
server that user managers connect to to send ManagedOOM property updates.

We also add extra validation to make sure that non-root senders don't
send updates for cgroups they don't own.

The integration test was extended to repeat the chill/bloat test using
a user manager instead of PID1.
2021-09-20 13:53:11 +01:00
Anita Zhang
7417f06187 test: tweak parameters for TEST-55-OOMD
Pressure remains > 1% after a kill for some time and could cause
testchill to get killed. Bumping the limit from 1% to 20% should help
with this.

Fixes #20118
2021-09-12 19:16:18 +09:00
Yu Watanabe
7d5f4f1d4f test: also show the memory pressure of testchill.service
The memory pressure should be small, but let's log the value in
the journal of the test environment.
2021-07-03 05:05:36 +09:00
Yu Watanabe
fa7ff467b6 test: check memory pressure more frequently 2021-07-03 05:05:33 +09:00
Yu Watanabe
b7674ab206 test: enable debug logging of systemd-oomd 2021-07-03 05:04:59 +09:00
Frantisek Sumsal
3882526798 test: use quotes where necessary
to avoid possible word splitting.
2021-04-13 12:08:01 +02:00
Frantisek Sumsal
084575ff91 test: use set -eux and set -o pipefail everywhere
This should make the scripts more robust.
2021-04-13 12:08:01 +02:00
Zbigniew Jędrzejewski-Szmek
0ee994836c TEST-*: use spacing before redirection operator, but not after
<< EOF → <<EOF
> foo < bar → >foo <bar
2021-04-08 20:21:50 +02:00
Yu Watanabe
1ebcf47296 test: merge udev tests 2021-03-05 18:36:04 +09:00
Yu Watanabe
8d80f27530 sd-device: make TAGS= property prefixed and suffixed with ":"
The commit 6f3ac0d517 drops the prefix and
suffix in TAGS= property. But there exists several rules that have like
`TAGS=="*:tag:*"`. So, the property must be always prefixed and suffixed
with ":".

Fixes #17930.
2020-12-14 14:04:53 +09:00
Yu Watanabe
6f3ac0d517 sd-device: use set_strjoin()
This slightly changes TAGS= and CURRENT_TAGS= properties:

Before
E: TAGS=:aaa:bbb:

After
E: TAGS=aaa:bbb
2020-12-08 12:28:58 +09:00
Lennart Poettering
31abedbb03 test: add test for new "sticky" tags logic 2020-09-01 17:40:12 +02:00