-
Notifications
You must be signed in to change notification settings - Fork 74
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
Run "rke2-killall.sh" before shutdown #270
Run "rke2-killall.sh" before shutdown #270
Conversation
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
package/harvester-os/files/etc/systemd/system/rke2-shutdown.service
Outdated
Show resolved
Hide resolved
Before=reboot.target halt.target shutdown.target poweroff.target umount.target final.target | ||
|
||
[Install] | ||
RequiredBy=reboot.target halt.target shutdown.target poweroff.target umount.target final.target |
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.
Test and work well.
Is this unit required to be run after rke2-agent or rke2-server service is stopped?
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.
I feel like if it's a user that stopped the service, the user should decide whether rke2-killall.sh
should be run.
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.
FWIW, I found some discussions about this issue, and seems like "stopping K3s/RKE2 does not stop running containers" is specifically designed to allow non-disruptive upgrade of K3s/RKE2.
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.
During an upgrade, we will always wait for RKE2 upgraded first and shut down later.
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=-/usr/local/bin/rke2-killall.sh |
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.
Also rke2-killall.sh
sends KILL (-9)
signals to processes, but rke2-server/agent's systemd services's ExecStopPost
option sends TERM
signals. Just wondering if it's safer to use TERM.
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.
using TERM might be a good idea to give the processes some time to clean up and terminate.
but we need to have another script to do it?
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.
Yes, using SIGTERM
would be much safer. Do you think maybe we should create a copy of rke2-killall.sh
and replace the -9
with -15
?
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.
If that's oneliner, we can also embed it in the systemd unit file. There are many cleanups in the rke2-killall.sh script, maybe some are unnecessary.
Create a service to run script `rke2-killall.sh` to stop all the running containers. Signed-off-by: John Liu <john.liu@suse.com>
28d5d53
to
1017d3c
Compare
Thanks, John. This was addressed in #480, so close it. |
Create a
rke2-shutdown.service
to run scriptrke2-killall.sh
to stop all the running pods (containers) before system shutdown or reboot. One of the benefits is that system shutdown and reboot would be much faster.The key component is the
Before=umount.target
so that the service will runrke2-killall.sh
before systems started to unmount everything, including those Pods' volumes.Test plan
F12
poweroff
and the shutdown process would be blocked for around 1 minute. With this PR, those messages will not show at all.
reboot
command or operation such as Press power button to initiate the graceful shutdown/reboot process, and they all shouldn't be affected by the message shown above.TODOs
rke2-shutdown.service
will be installed and enabled.Related
rke2-shutdown
service is inspired by thesystemd-unit.txt
provided by the author of the issue