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

Commits on Jun 15, 2023

  1. unit drop-in: Fix ordering of special type.d drop-ins

    (cherry picked from commit e6627f2)
    
    Related: #2156620
    GothAck authored and dtardon committed Jun 15, 2023
    Configuration menu
    Copy the full SHA
    db14dec View commit details
    Browse the repository at this point in the history
  2. Add failing test to show service.d global drop-in does not get overri…

    …dden by more specific dropins
    
    (cherry picked from commit f5dd6e5)
    
    Related: #2156620
    GothAck authored and dtardon committed Jun 15, 2023
    Configuration menu
    Copy the full SHA
    f9dcc06 View commit details
    Browse the repository at this point in the history

Commits on Jul 13, 2023

  1. test: set indentation to 4 spaces

    This is what upstream commit cc5549c
    has done, but just for a single shell file.
    
    RHEL-only
    
    Related: #2156620
    dtardon committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    f7b0d9d View commit details
    Browse the repository at this point in the history
  2. test/TEST-15: remove all created unit files

    We would miss anything created under a template instance.
    
    (cherry picked from commit 4e2ac45)
    
    Related: #2156620
    keszybz authored and dtardon committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    7c9f16f View commit details
    Browse the repository at this point in the history
  3. test: use quotes where necessary

    to avoid possible word splitting.
    
    [dtardon: Dropped changes to other files.]
    
    (cherry picked from commit 3882526)
    
    Related: #2156620
    mrc0mmand authored and dtardon committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    0548d91 View commit details
    Browse the repository at this point in the history
  4. tree-wide: drop manually-crafted message for missing variables

    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
    keszybz authored and dtardon committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    a175e11 View commit details
    Browse the repository at this point in the history
  5. manager: reformat boolean expression in unit_is_pristine()

    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
    keszybz authored and dtardon committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    ccbf58f View commit details
    Browse the repository at this point in the history
  6. manager: allow transient units to have drop-ins

    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
    keszybz authored and dtardon committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    93daeac View commit details
    Browse the repository at this point in the history
  7. TEST-15: allow helper functions to accept other unit types

    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
    keszybz authored and dtardon committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    f133ef6 View commit details
    Browse the repository at this point in the history
  8. TEST-15: also test hierarchical drop-ins for slices

    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
    keszybz authored and dtardon committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    8f185c9 View commit details
    Browse the repository at this point in the history
  9. TEST-15: add test for transient units with drop-ins

    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
    keszybz authored and dtardon committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    97d75f7 View commit details
    Browse the repository at this point in the history
  10. TEST-15: add one more test for drop-in precedence

    (cherry picked from commit c3fa408dcc03bb6dbd11f180540fb9e684893c39)
    
    Related: #2156620
    keszybz authored and dtardon committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    b565b04 View commit details
    Browse the repository at this point in the history