Description of problem:
For nested slices, stopping of the parent results in the parent slice entering a "dead" state. Upstream releases result in the child and parent slices being removed without a "dead" state.
Version-Release number of selected component (if applicable):
systemd-219-62.el7_6.7.x86_64
How reproducible:
Easily
Steps to Reproduce:
1. Start a few nested slices using "systemd-run"
# systemd-run --slice first-second-third echo test
2. Verify that all are active
# systemctl list-units --type slice --all first*
3. Stop the "first-second" slice
# systemctl stop first-second.slice
4. Verify the slice states
# systemctl list-units --type slice --all first*
Actual results:
# systemd-run --slice first-second-third echo test
Running as unit run-5416.service.
# systemctl list-units --type slice --all first*
UNIT LOAD ACTIVE SUB DESCRIPTION
first-second-third.slice loaded active active first-second-third.slice
first-second.slice loaded active active first-second.slice
first.slice loaded active active first.slice
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
3 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
# systemctl stop first-second.slice
# systemctl list-units --type slice --all first*
UNIT LOAD ACTIVE SUB DESCRIPTION
first-second-third.slice loaded active active first-second-third.slice
first-second.slice loaded inactive dead first-second.slice
first.slice loaded active active first.slice
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
3 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
Expected results:
# systemd-run --slice first-second-third.slice echo "test"
Running as unit: run-rfa7d23674bad47259b4d31ea38911c15.service
# systemctl list-units --type slice --all first*
UNIT LOAD ACTIVE SUB DESCRIPTION
first-second-third.slice loaded active active first-second-third.slice
first-second.slice loaded active active first-second.slice
first.slice loaded active active first.slice
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
3 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
# systemctl stop first-second.slice
# systemctl list-units --type slice --all first*
UNIT LOAD ACTIVE SUB DESCRIPTION
first.slice loaded active active first.slice
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
1 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
Additional info:
I initially suspected that the following commit was responsible:
commit 8c8da0e0cb498245c765732cf9caa081a70c560f
Author: Lennart Poettering <lennart>
Date: Tue Sep 29 13:06:28 2015 +0200
core: add a "Requires=" dependency between units and the slices they are located in
We place the processes we fork off in the cgroup anyway, and we probably
shouldn't be able to get that far if we couldn't set up the slice due to
resource problems or unmet conditions. Hence upgrade the dependency
between units and the slices they are located in from Wants= to
Requires=.
Test outcome with the above patch results in the 3rd generation slice being stopped, but the 2nd generation remains in the "dead" state:
# systemctl list-units --type slice --all first*
UNIT LOAD ACTIVE SUB DESCRIPTION
first-second.slice loaded inactive dead first-second.slice
first.slice loaded active active first.slice
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
2 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
This did have the effect of stopping the child slice, but it still left the parent in the dead state. The failure condition here is needing to be addressed as OpenShift workloads will issue stop operations on slices without necessarily stopping the child slices. This is necessary to avoid a unit leakage condition that will _eventually_ result in E2BIG due to MANAGER_MAX_NAMES.
Yeah. Units with cyclic references are not garbage collected properly. This was fixed by https://github.com/systemd/systemd/pull/8175 . It doesn't look too hard to backport, so I'll give it a try...
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2020:1117
Description of problem: For nested slices, stopping of the parent results in the parent slice entering a "dead" state. Upstream releases result in the child and parent slices being removed without a "dead" state. Version-Release number of selected component (if applicable): systemd-219-62.el7_6.7.x86_64 How reproducible: Easily Steps to Reproduce: 1. Start a few nested slices using "systemd-run" # systemd-run --slice first-second-third echo test 2. Verify that all are active # systemctl list-units --type slice --all first* 3. Stop the "first-second" slice # systemctl stop first-second.slice 4. Verify the slice states # systemctl list-units --type slice --all first* Actual results: # systemd-run --slice first-second-third echo test Running as unit run-5416.service. # systemctl list-units --type slice --all first* UNIT LOAD ACTIVE SUB DESCRIPTION first-second-third.slice loaded active active first-second-third.slice first-second.slice loaded active active first-second.slice first.slice loaded active active first.slice LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 3 loaded units listed. To show all installed unit files use 'systemctl list-unit-files'. # systemctl stop first-second.slice # systemctl list-units --type slice --all first* UNIT LOAD ACTIVE SUB DESCRIPTION first-second-third.slice loaded active active first-second-third.slice first-second.slice loaded inactive dead first-second.slice first.slice loaded active active first.slice LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 3 loaded units listed. To show all installed unit files use 'systemctl list-unit-files'. Expected results: # systemd-run --slice first-second-third.slice echo "test" Running as unit: run-rfa7d23674bad47259b4d31ea38911c15.service # systemctl list-units --type slice --all first* UNIT LOAD ACTIVE SUB DESCRIPTION first-second-third.slice loaded active active first-second-third.slice first-second.slice loaded active active first-second.slice first.slice loaded active active first.slice LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 3 loaded units listed. To show all installed unit files use 'systemctl list-unit-files'. # systemctl stop first-second.slice # systemctl list-units --type slice --all first* UNIT LOAD ACTIVE SUB DESCRIPTION first.slice loaded active active first.slice LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 1 loaded units listed. To show all installed unit files use 'systemctl list-unit-files'. Additional info: I initially suspected that the following commit was responsible: commit 8c8da0e0cb498245c765732cf9caa081a70c560f Author: Lennart Poettering <lennart> Date: Tue Sep 29 13:06:28 2015 +0200 core: add a "Requires=" dependency between units and the slices they are located in We place the processes we fork off in the cgroup anyway, and we probably shouldn't be able to get that far if we couldn't set up the slice due to resource problems or unmet conditions. Hence upgrade the dependency between units and the slices they are located in from Wants= to Requires=. Test outcome with the above patch results in the 3rd generation slice being stopped, but the 2nd generation remains in the "dead" state: # systemctl list-units --type slice --all first* UNIT LOAD ACTIVE SUB DESCRIPTION first-second.slice loaded inactive dead first-second.slice first.slice loaded active active first.slice LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 2 loaded units listed. To show all installed unit files use 'systemctl list-unit-files'. This did have the effect of stopping the child slice, but it still left the parent in the dead state. The failure condition here is needing to be addressed as OpenShift workloads will issue stop operations on slices without necessarily stopping the child slices. This is necessary to avoid a unit leakage condition that will _eventually_ result in E2BIG due to MANAGER_MAX_NAMES.