bottlerocket-os/bottlerocket

eliminate use of `systemctl try-restart`

Open

#1,711 创建于 2021年8月14日

在 GitHub 查看
 (4 评论) (1 反应) (0 负责人)Rust (386 fork)batch import
area/corehelp wantedstatus/iceboxtype/bug

仓库指标

Star
 (6,938 star)
PR 合并指标
 (平均合并 7天 21小时) (30 天内合并 7 个 PR)

描述

Today we use systemctl try-restart to attempt a service restart after applying settings. Partly this is because we process settings early in the boot, when the affected services haven't been started yet and aren't intended to start.

However, this causes trouble when changing settings at runtime, because if the service isn't running, the command will do nothing.

Services might not be running for a few reasons:

  • they failed to start after bad settings were previously applied
  • they are starting after new settings are applied, but aren't yet started all the way

In a host container running at boot, @vignesh-goutham discovered the following race:

  • host container queries systemd for the status of kubelet
  • waits for it to finish activating (ActiveState=active and SubState=running)
  • issues apiclient set commands to reconfigure kubelet
  • apiserver executes restart commands
  • systemctl try-restart does nothing
  • systemd logs the first Started Kubelet around 1 second later

From this we can infer that two calls to apiclient set kubernetes.<blah> in quick succession will not always result in two kubelet restarts, leaving that service in an undefined state.

For changing settings at runtime, we really need something more like force-stop and force-start to ensure that the restart commands are fully enacted for each transaction.

贡献者指南