/usr/bin/cloud-init 的多个实例占用大量 CPU

/usr/bin/cloud-init 的多个实例占用大量 CPU

我有一台运行 Ubuntu Server 20.04.3 的家庭服务器,我用它来托管 Docker Swarm 和几个 KVM 客户机。昨天我重启了它(我之前已经多次重启过),从那时起我注意到风扇声音很大。

刚才(大约 24 小时后)我top查看了一下,发现了以下命令的 10 个实例:

/usr/bin/python3 /usr/bin/cloud-init devel hotplug-hook -s net query

它们各自占用 30.8% 到 73.8% 的 CPU,总共占用 466% 的 CPU。每个进程运行的时间都不足一分钟,但只要一个进程终止,另一个进程就会取而代之。

回顾过去/var/log/cloud-init.log,下列语句不断重复:

2021-11-19 10:19:58,268 - hotplug_hook.py[DEBUG]: hotplug-hook called with the following arguments: {hotplug_action: query, subsystem: net, udevaction: None, devpath: None}
2021-11-19 10:19:58,268 - handlers.py[DEBUG]: start: hotplug-hook: Handle reconfiguration on hotplug events
2021-11-19 10:19:58,268 - hotplug_hook.py[DEBUG]: Fetching datasource
2021-11-19 10:19:58,269 - handlers.py[DEBUG]: start: hotplug-hook/check-cache: attempting to read from cache [trust]
2021-11-19 10:19:58,269 - util.py[DEBUG]: Reading from /var/lib/cloud/instance/obj.pkl (quiet=False)
2021-11-19 10:19:58,269 - util.py[DEBUG]: Read 14682 bytes from /var/lib/cloud/instance/obj.pkl
2021-11-19 10:19:58,272 - util.py[DEBUG]: Reading from /run/cloud-init/.instance-id (quiet=False)
2021-11-19 10:19:58,272 - util.py[DEBUG]: Read 37 bytes from /run/cloud-init/.instance-id
2021-11-19 10:19:58,272 - stages.py[DEBUG]: restored from cache with run check: DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]
2021-11-19 10:19:58,272 - handlers.py[DEBUG]: finish: hotplug-hook/check-cache: SUCCESS: restored from cache with run check: DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]
2021-11-19 10:19:58,272 - hotplug_hook.py[DEBUG]: hotplug not supported for event of type net
2021-11-19 10:19:58,272 - handlers.py[DEBUG]: finish: hotplug-hook: SUCCESS: Handle reconfiguration on hotplug events
2021-11-19 10:19:58,273 - hotplug_hook.py[DEBUG]: Exiting hotplug handler
2021-11-19 10:19:58,273 - util.py[DEBUG]: Reading from /proc/uptime (quiet=False)
2021-11-19 10:19:58,273 - util.py[DEBUG]: Read 21 bytes from /proc/uptime
2021-11-19 10:19:58,273 - util.py[DEBUG]: cloud-init mode 'hotplug-hook' took 0.042 seconds (0.04)

据我所知,hotplug-hook 旨在响应硬件的添加/移除。什么原因会导致它像这样反复触发?

答案1

这是 cloud-init 21.3 中的一个错误,已在 cloud-init 21.4 中修复:

https://bugs.launchpad.net/cloud-init/+bug/1946003

您可以安全地rm /etc/udev/rules.d/10-cloud-init-hook-hotplug.rules对受影响的实例采取解决方法。

相关内容