Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#2156620) Allow drop-ins for transient units #381

Merged

Conversation

dtardon
Copy link
Member

@dtardon dtardon commented Apr 13, 2023

Resolves: #2156620

@mergify mergify bot added the pr/needs-ci Formerly needs-ci label Apr 13, 2023
@systemd-rhel-bot systemd-rhel-bot added the pr/needs-review Formerly needs-review label Apr 13, 2023
@systemd-rhel-bot systemd-rhel-bot changed the title Allow drop-ins for transient units (#2156620) Allow drop-ins for transient units Apr 13, 2023
@systemd-rhel-bot systemd-rhel-bot added the tracker/unapproved Formerly needs-acks label Apr 13, 2023
@dtardon dtardon force-pushed the bz2156620-drop-ins-transient branch 4 times, most recently from d2e4327 to 5a2cf2a Compare April 20, 2023 13:08
@systemd-rhel-bot systemd-rhel-bot added tracker/unapproved Formerly needs-acks and removed tracker/unapproved Formerly needs-acks labels May 18, 2023
@systemd-rhel-bot systemd-rhel-bot added tracker/unapproved Formerly needs-acks and removed tracker/unapproved Formerly needs-acks labels May 28, 2023
@systemd-rhel-bot systemd-rhel-bot added tracker/unapproved Formerly needs-acks and removed tracker/unapproved Formerly needs-acks labels Jun 5, 2023
@msekletar
Copy link
Member

@dtardon CI failures seem unrelated but please rerun, I'd feel better to give LGTM on this one once everything is green.

(cherry picked from commit e6627f2)

Related: #2156620
…dden by more specific dropins

(cherry picked from commit f5dd6e5)

Related: #2156620
@dtardon dtardon force-pushed the bz2156620-drop-ins-transient branch from 5a2cf2a to 57ea65a Compare June 15, 2023 11:41
@github-actions
Copy link

github-actions bot commented Jun 15, 2023

Tracker - 2156620

The following commits meet all requirements

commit upstream
db14dec - unit drop-in: Fix ordering of special type.d drop-ins systemd/systemd@e6627f2
systemd/systemd-stable@e6627f2
f9dcc06 - Add failing test to show service.d global drop-in does not get overrid… systemd/systemd@f5dd6e5
systemd/systemd-stable@f5dd6e5
f7b0d9d - test: set indentation to 4 spaces RHEL-only
7c9f16f - test/TEST-15: remove all created unit files systemd/systemd@4e2ac45
systemd/systemd-stable@4e2ac45
0548d91 - test: use quotes where necessary systemd/systemd@3882526
systemd/systemd-stable@3882526
a175e11 - tree-wide: drop manually-crafted message for missing variables systemd/systemd@d7ff524
systemd/systemd-stable@d7ff524
ccbf58f - manager: reformat boolean expression in unit_is_pristine() systemd/systemd@b146a73
systemd/systemd-stable@b146a73
93daeac - manager: allow transient units to have drop-ins systemd/systemd@1f83244
systemd/systemd-stable@1f83244
f133ef6 - TEST-15: allow helper functions to accept other unit types systemd/systemd@5731e13
systemd/systemd-stable@5731e13
8f185c9 - TEST-15: also test hierarchical drop-ins for slices systemd/systemd@f80c874
systemd/systemd-stable@f80c874
97d75f7 - TEST-15: add test for transient units with drop-ins systemd/systemd@6854434
systemd/systemd-stable@6854434
b565b04 - TEST-15: add one more test for drop-in precedence systemd/systemd@c3fa408
systemd/systemd-stable@c3fa408

@mergify mergify bot removed the pr/needs-ci Formerly needs-ci label Jun 15, 2023
@msekletar
Copy link
Member

@dtardon can you please fix the issue reported by the GH action, i.e. missing upstream reference.

dtardon and others added 8 commits July 13, 2023 09:24
This is what upstream commit cc5549c
has done, but just for a single shell file.

RHEL-only

Related: #2156620
We would miss anything created under a template instance.

(cherry picked from commit 4e2ac45)

Related: #2156620
to avoid possible word splitting.

[dtardon: Dropped changes to other files.]

(cherry picked from commit 3882526)

Related: #2156620
Bash will generate a very nice message for us:
/tmp/ff.sh: line 1: SOMEVAR: parameter null or not set

Let's save some keystrokes by not replacing this with our own inferior
messages.

[dtardon: Dropped changes to other files.]

(cherry picked from commit d7ff524)

Related: #2156620
Not not IN_SET(…) is just too much for my poor brain. Let's invert
the expression to make it easier to undertand.

(cherry picked from commit b146a7345b69de16e88347acadb3783ffeeaad9d)

Related: #2156620
In containers/podman#16107, starting of a transient
slice unit fails because there's a "global" drop-in
/usr/lib/systemd/user/slice.d/10-oomd-per-slice-defaults.conf (provided by
systemd-oomd-defaults package to install some default oomd policy). This means
that the unit_is_pristine() check fails and starting of the unit is forbidden.

It seems pretty clear to me that dropins at any other level then the unit
should be ignored in this check: we now have multiple layers of drop-ins
(for each level of the cgroup path, and also "global" ones for a specific
unit type). If we install a "global" drop-in, we wouldn't be able to start
any transient units of that type, which seems undesired.

In principle we could reject dropins at the unit level, but I don't think that
is useful. The whole reason for drop-ins is that they are "add ons", and there
isn't any particular reason to disallow them for transient units. It would also
make things harder to implement and describe: one place for drop-ins is good,
but another is bad. (And as a corner case: for instanciated units, a drop-in
in the template would be acceptable, but a instance-specific drop-in bad?)

Thus, $subject.

While at it, adjust the message. All the conditions in unit_is_pristine()
essentially mean that it wasn't loaded (e.g. it might be in an error state),
and that it doesn't have a fragment path (now that drop-ins are acceptable).
If there's a job for it, it necessarilly must have been loaded. If it is
merged into another unit, it also was loaded and found to be an alias.
Based on the discussion in the bugs, it seems that the current message
is far from obvious ;)

Fixes containers/podman#16107,
https://bugzilla.redhat.com/show_bug.cgi?id=2133792.

(cherry picked from commit 1f83244641f13a9cb28fdac7e3c17c5446242dfb)

Resolves: #2156620
clear_services() is renamed to clear_units() and now takes a full
unit name including the suffix as an argument.

_clear_service() is renamed to clear_unit() and changed likewise.
create_service() didn't have the same underscore prefix, and I don't think
it's useful or needed for a local function, so it is removed.

No functional change.

(cherry picked from commit 5731e1378ad6256e34f3da33ee993343f025c075)

Related: #2156620
Slices are worth testing too, because they don't need a fragment path so they
behave slightly differently than service units. I'm making this a separate
patch from the actual tests that I wanted to add later because it's complex
enough on its own.

(cherry picked from commit f80c874af376052b6b81f47cbbc43d7fecd98cd6)

Related: #2156620
We want to test four things:
- that the transient units are successfully started when drop-ins exist
- that the transient setings override the defaults
- the drop-ins override the transient settings (the same as for a normal unit)
- that things are the same before and after a reload

To make things more fun, we start and stop units in two different ways: via
systemctl and via a direct busctl invocation. This gives us a bit more coverage
of different code paths.

(cherry picked from commit 6854434cfb5dda10c07d95835c38b75e5e71c2b5)

Related: #2156620
(cherry picked from commit c3fa408dcc03bb6dbd11f180540fb9e684893c39)

Related: #2156620
@dtardon dtardon force-pushed the bz2156620-drop-ins-transient branch from 57ea65a to b565b04 Compare July 13, 2023 07:24
@mergify mergify bot added pr/needs-ci Formerly needs-ci and removed pr/needs-ci Formerly needs-ci labels Jul 13, 2023
@systemd-rhel-bot systemd-rhel-bot changed the title (#2156620) Allow drop-ins for transient units (#2156620) (#2156620) Allow drop-ins for transient units Jul 25, 2023
@dtardon dtardon changed the title (#2156620) (#2156620) Allow drop-ins for transient units (#2156620) Allow drop-ins for transient units Aug 16, 2023
Copy link
Member

@msekletar msekletar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@systemd-rhel-bot systemd-rhel-bot removed the pr/needs-review Formerly needs-review label Aug 22, 2023
@systemd-rhel-bot systemd-rhel-bot merged commit 832ceb7 into redhat-plumbers:main Aug 22, 2023
10 checks passed
@dtardon dtardon deleted the bz2156620-drop-ins-transient branch August 23, 2023 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants