我正在启动一个新的 Ubuntu 18.04 云服务器并使用 acloud-init
来安装 docker。通过检查文件,我可以看到该cloud-init
进程运行并且显然完成得很好/var/log/cloud-init-output.log
。但我发现几个cloud-init
进程在此之后仍在运行很长时间,并耗尽了 CPU:
这些cloud-init
进程大约每 30 秒出现在top
列表中,然后消失,然后再次返回。有什么方法可以进一步诊断这个问题...为什么cloud-init
在它明显完成后仍然运行,以及为什么有这么多进程?
我还看到一个 CPU 跟踪,它具有规则的峰值,似乎遵循相同的模式:
看看/var/log/cloud-init.log
,我发现它每 30 秒左右就会疯狂一次,输出以下内容,并一遍又一遍地重复少量行:
2021-11-13 19:21:25,927 - hotplug_hook.py[DEBUG]: hotplug-hook called with the following arguments: {hotplug_action: query, subsystem: net, udevaction: None, devpath: None}
2021-11-13 19:21:25,928 - handlers.py[DEBUG]: start: hotplug-hook: Handle reconfiguration on hotplug events
2021-11-13 19:21:25,928 - hotplug_hook.py[DEBUG]: Fetching datasource
2021-11-13 19:21:25,928 - handlers.py[DEBUG]: start: hotplug-hook/check-cache: attempting to read from cache [trust]
2021-11-13 19:21:25,928 - util.py[DEBUG]: Reading from /var/lib/cloud/instance/obj.pkl (quiet=False)
2021-11-13 19:21:25,928 - util.py[DEBUG]: Read 18131 bytes from /var/lib/cloud/instance/obj.pkl
2021-11-13 19:21:25,931 - util.py[DEBUG]: Reading from /run/cloud-init/.instance-id (quiet=False)
2021-11-13 19:21:25,932 - util.py[DEBUG]: Read 9 bytes from /run/cloud-init/.instance-id
2021-11-13 19:21:25,932 - stages.py[DEBUG]: restored from cache with run check: DataSourceHetzner
2021-11-13 19:21:25,932 - handlers.py[DEBUG]: finish: hotplug-hook/check-cache: SUCCESS: restored from cache with run check: DataSourceHetzner
2021-11-13 19:21:25,932 - hotplug_hook.py[DEBUG]: hotplug not supported for event of type net
2021-11-13 19:21:25,932 - handlers.py[DEBUG]: finish: hotplug-hook: SUCCESS: Handle reconfiguration on hotplug events
2021-11-13 19:21:25,932 - hotplug_hook.py[DEBUG]: Exiting hotplug handler
2021-11-13 19:21:25,932 - util.py[DEBUG]: Reading from /proc/uptime (quiet=False)
2021-11-13 19:21:25,932 - util.py[DEBUG]: Read 17 bytes from /proc/uptime
2021-11-13 19:21:25,932 - util.py[DEBUG]: cloud-init mode 'hotplug-hook' took 0.058 seconds (0.06)
2021-11-13 19:21:26,035 - hotplug_hook.py[DEBUG]: hotplug-hook called with the following arguments: {hotplug_action: query, subsystem: net, udevaction: None, devpath: None}
2021-11-13 19:21:26,035 - handlers.py[DEBUG]: start: hotplug-hook: Handle reconfiguration on hotplug events
2021-11-13 19:21:26,035 - hotplug_hook.py[DEBUG]: Fetching datasource
2021-11-13 19:21:26,035 - handlers.py[DEBUG]: start: hotplug-hook/check-cache: attempting to read from cache [trust]
2021-11-13 19:21:26,036 - util.py[DEBUG]: Reading from /var/lib/cloud/instance/obj.pkl (quiet=False)
2021-11-13 19:21:26,036 - util.py[DEBUG]: Read 18131 bytes from /var/lib/cloud/instance/obj.pkl
2021-11-13 19:21:26,039 - util.py[DEBUG]: Reading from /run/cloud-init/.instance-id (quiet=False)
2021-11-13 19:21:26,039 - util.py[DEBUG]: Read 9 bytes from /run/cloud-init/.instance-id
2021-11-13 19:21:26,039 - stages.py[DEBUG]: restored from cache with run check: DataSourceHetzner
2021-11-13 19:21:26,039 - handlers.py[DEBUG]: finish: hotplug-hook/check-cache: SUCCESS: restored from cache with run check: DataSourceHetzner
2021-11-13 19:21:26,039 - hotplug_hook.py[DEBUG]: hotplug not supported for event of type net
2021-11-13 19:21:26,040 - handlers.py[DEBUG]: finish: hotplug-hook: SUCCESS: Handle reconfiguration on hotplug events
2021-11-13 19:21:26,040 - hotplug_hook.py[DEBUG]: Exiting hotplug handler
2021-11-13 19:21:26,040 - util.py[DEBUG]: Reading from /proc/uptime (quiet=False)
2021-11-13 19:21:26,040 - util.py[DEBUG]: Read 17 bytes from /proc/uptime
2021-11-13 19:21:26,040 - util.py[DEBUG]: cloud-init mode 'hotplug-hook' took 0.054 seconds (0.06)
2021-11-13 19:21:26,054 - hotplug_hook.py[DEBUG]: hotplug-hook called with the following arguments: {hotplug_action: query, subsystem: net, udevaction: None, devpath: None}
2021-11-13 19:21:26,054 - handlers.py[DEBUG]: start: hotplug-hook: Handle reconfiguration on hotplug events
2021-11-13 19:21:26,054 - hotplug_hook.py[DEBUG]: Fetching datasource
2021-11-13 19:21:26,054 - handlers.py[DEBUG]: start: hotplug-hook/check-cache: attempting to read from cache [trust]
2021-11-13 19:21:26,055 - util.py[DEBUG]: Reading from /var/lib/cloud/instance/obj.pkl (quiet=False)
2021-11-13 19:21:26,055 - util.py[DEBUG]: Read 18131 bytes from /var/lib/cloud/instance/obj.pkl
2021-11-13 19:21:26,058 - util.py[DEBUG]: Reading from /run/cloud-init/.instance-id (quiet=False)
2021-11-13 19:21:26,058 - util.py[DEBUG]: Read 9 bytes from /run/cloud-init/.instance-id
2021-11-13 19:21:26,058 - stages.py[DEBUG]: restored from cache with run check: DataSourceHetzner
2021-11-13 19:21:26,058 - handlers.py[DEBUG]: finish: hotplug-hook/check-cache: SUCCESS: restored from cache with run check: DataSourceHetzner
2021-11-13 19:21:26,058 - hotplug_hook.py[DEBUG]: hotplug not supported for event of type net
2021-11-13 19:21:26,058 - handlers.py[DEBUG]: finish: hotplug-hook: SUCCESS: Handle reconfiguration on hotplug events
2021-11-13 19:21:26,059 - hotplug_hook.py[DEBUG]: Exiting hotplug handler
2021-11-13 19:21:26,059 - util.py[DEBUG]: Reading from /proc/uptime (quiet=False)
2021-11-13 19:21:26,059 - util.py[DEBUG]: Read 17 bytes from /proc/uptime
2021-11-13 19:21:26,059 - util.py[DEBUG]: cloud-init mode 'hotplug-hook' took 0.057 seconds (0.05)
答案1
从 #cloud-init IRC 频道上的有用聊天来看,这显然与 cloud-init 版本 21.3 的问题有关,该问题已在几天后发布的 21.4 中修复。
在那之前,修复方法是:
rm -f /lib/udev/rules.d/10-cloud-init-hook-hotplug.rules
sudo udevadm control --reload-rules