Closed siegfriedweber closed 3 years ago
Systemd units where the corresponding pod is terminating, are removed now.
I extended the test script with the function setup_unit_with_terminating_pod
.
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:
[2021-09-24T11:54:43Z INFO stackable_agent::provider::cleanup] The systemd unit [default-cleanup-test-terminating-noop-service.service] will be removed because the corresponding pod is terminating.
[2021-09-24T11:54:45Z INFO stackable_agent::provider::states::pod::terminated] Pod default-cleanup-test-terminating was terminated
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.
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