kubernetes: Graceful node shutdown conflicts with unattended-upgrades package

What happened:

setting shutdownGracePeriod: “60s” and shutdownGracePeriodCriticalPods: “30s” in /etc/kubernetes/kubelet-config.yaml results in /var/log/kubelet.log messages like: Jun 2 19:41:48 test-c2rtl5620bsn3hi5voeg-kublettest1-default-0000042f kubelet.service[7402]: E0602 19:41:48.214662 7402 kubelet.go:1404] “Failed to start node shutdown manager” err=“node shutdown manager was unable to update logind InhibitDelayMaxSec to 1m0s (ShutdownGracePeriod), current value of InhibitDelayMaxSec (30s) is less than requested ShutdownGracePeriod”

What you expected to happen:

I expected the graceful node shutdown configuration settings to take precedence.

How to reproduce it (as minimally and precisely as possible):

configure graceful node shutdown (shutdownGracePeriod: “60s” and shutdownGracePeriodCriticalPods: “30s” ) on a node with the unattended-upgrades package installed

check the log for messages indicating “node shutdown manager was unable to update logind InhibitDelayMaxSec …”

Anything else we need to know?:

unattended-upgrades writes /usr/lib/systemd/logind.conf.d/unattended-upgrades-logind-maxdelay.conf containing InhibitDelayMaxSec=30

the Kubernetes code writes /etc/systemd/logind.conf.d/99-kubelet.conf which contains a definition of InhibitDelayMaxSec ultimately based on the values in /etc/kubernetes/kubelet-config.yaml

/usr/lib/systemd/logind.conf.d/unattended-upgrades-logind-maxdelay.conf has a higher precedence than /etc/systemd/logind.conf.d/99-kubelet.conf so the InhibitDelayMaxSec value in /usr/lib/systemd/logind.conf.d/unattended-upgrades-logind-maxdelay.conf is used.

for any value other than 30 seconds … the Kubernetes implementation of GracefulNodeShutdown is incompatible with the unattended-upgrades package

Environment:

  • Kubernetes version (use kubectl version): kubectl version Client Version: version.Info{Major:“1”, Minor:“21”, GitVersion:“v1.21.1+IKS”, GitCommit:“04e16b9d6c7af21e462f7ac675c34b667cd6149e”, GitTreeState:“clean”, BuildDate:“2021-05-24T08:21:44Z”, GoVersion:“go1.16.4”, Compiler:“gc”, Platform:“linux/amd64”} Server Version: version.Info{Major:“1”, Minor:“21”, GitVersion:“v1.21.1+IKS”, GitCommit:“04e16b9d6c7af21e462f7ac675c34b667cd6149e”, GitTreeState:“clean”, BuildDate:“2021-05-24T08:19:13Z”, GoVersion:“go1.16.4”, Compiler:“gc”, Platform:“linux/amd64”}

  • Cloud provider or hardware configuration: IBM Cloud

  • OS (e.g: cat /etc/os-release): cat /etc/os-release NAME=“Ubuntu” VERSION=“16.04.7 LTS (Xenial Xerus)” ID=ubuntu ID_LIKE=debian PRETTY_NAME=“Ubuntu 16.04.7 LTS” VERSION_ID=“16.04” HOME_URL=“http://www.ubuntu.com/” SUPPORT_URL=“http://help.ubuntu.com/” BUG_REPORT_URL=“http://bugs.launchpad.net/ubuntu/” VERSION_CODENAME=xenial UBUNTU_CODENAME=xenial

  • Kernel (e.g. uname -a): uname -a Linux test-c2v7ef52068f5kndi8s0-testcluster-default-000002f4.iks.ibm 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

  • Install tools:

  • Network plugin and version (if this is a network-related bug):

  • Others:

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 34 (17 by maintainers)

Most upvoted comments

@iscultas Thank you for the investigation analysis.

This issue took me an evening to crack, but I seem to have figured it out. The problem resides not in Kubernetes but in the unattended-upgrades package itself.

As stated in logind.conf documentation,

Files in the *.conf.d/ configuration subdirectories are sorted by their filename in lexicographic order, regardless of in which of the subdirectories they reside.

and

When multiple files specify the same option, for options which accept just a single value, the entry in the file sorted last takes precedence.

In short, logind.conf.d directories are treated as a single directory, and the option value of the last of sorted files prevails.

What is happening?

  • Kubernetes creates its InhibitDelayMaxSec local override at /etc/systemd/logind.conf.d/99-kubelet.conf.
  • unattended-upgrades creates its InhibitDelayMaxSec local override at /usr/lib/systemd/logind.conf.d/unattended-upgrades-logind-maxdelay.conf.
  • When sorted, unattended-upgrades-logind-maxdelay.conf becomes the last of sorted files and overrides 99-kubelet.conf.

By ignoring login.conf documentation recommendation

to use the range 10-40 for drop-ins in /usr/ and the range 60-90 for drop-ins in /etc/ and /run/, to make sure that local and transient drop-ins take priority over drop-ins shipped by the OS vendor,

unattended-upgrades package caused this and probably some other issues where InhibitDelayMaxSec overrides were needed.

How this issue can be resolved?

For the current setups

To disable a configuration file supplied by the vendor, the recommended way is to place a symlink to /dev/null in the configuration directory in /etc/, with the same filename as the vendor configuration file.

e. g. create /etc/systemd/logind.conf.d/unattended-upgrades-logind-maxdelay.conf -> /dev/null symlink.

In the long run

unattended-upgrades package must change its logind.conf local override to include the prefix recommended above (e. g. 10-unattended-upgrades-logind-maxdelay.conf).