This repository has been archived by the owner on Dec 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Remove systemd units without a corresponding pod #312
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On startup the systemd units in the system-stackable slice are compared to the pods assigned to this node. If a systemd unit is as expected then it is kept and the Stackable agent will take ownership again in a later stage. If there is no corresponding pod or the systemd unit differs from the pod specification then it is removed and the Stackable Agent will create a new systemd unit afterwards.
maltesander
previously approved these changes
Sep 23, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got similar output during testing. LGTM.
Systemd units where the corresponding pod is terminating, are removed now. I extended the test script with the function State before starting the Stackable Agent: # kubectl get pod cleanup-test-terminating
NAME READY STATUS RESTARTS AGE
cleanup-test-terminating 0/1 Terminating 0 14s
# systemctl status default-cleanup-test-terminating-noop-service.service
● default-cleanup-test-terminating-noop-service.service - default-cleanup-test-terminating-noop-service
Loaded: loaded (/usr/lib/systemd/system/default-cleanup-test-terminating-noop-service.service; enabled; vendor preset: disabled)
Drop-In: /run/systemd/system/default-cleanup-test-terminating-noop-service.service.d
└─zzz-lxc-service.conf
Active: active (running) since Fri 2021-09-24 11:52:10 UTC; 24s ago
Main PID: 27865 (start.sh)
CGroup: /system.slice/system-stackable.slice/default-cleanup-test-terminating-noop-service.service
├─27865 /bin/sh /opt/stackable/packages/noop-service-1.0.0/noop-service-1.0.0/start.sh
└─27866 sleep 1d
Sep 24 11:52:10 centos7 systemd[1]: Started default-cleanup-test-terminating-noop-service.
Sep 24 11:52:10 centos7 start.sh[27865]: test-service started Corresponding log output of the Stackable Agent:
State after starting the Stackable Agent: # kubectl get pod cleanup-test-terminating
Error from server (NotFound): pods "cleanup-test-terminating" not found
# systemctl status default-cleanup-test-terminating-noop-service.service
Unit default-cleanup-test-terminating-noop-service.service could not be found. |
soenkeliebau
approved these changes
Sep 24, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - gave the code a quick glance and tested it on a Debian T2 cluster
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
On startup the systemd units in the
system-stackable
slice are compared to the pods assigned to this node. If a systemd unit is as expected then it is kept and the Stackable Agent will take ownership again in a later stage. If there is no corresponding pod or the systemd unit differs from the pod specification then it is removed and the Stackable Agent will create a new systemd unit afterwards.Closes #180
Test
It is not possible to test this change with the agent-integration-tests because systemd units must be prepared and the Stackable Agent must be started afterwards, which is not possible over the Kubernetes API. Therefore it must be tested manually.
The following script can be used for manual testing:
The log output of the Stackable Agent should be:
Leftover
The implementation of
SystemDUnit
was adapted as far as necessary but a complete refactoring would be required. This will be done in #244.Review Checklist