File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -293,6 +293,30 @@ cat <<-EOF >/etc/rancher/k3s/config.yaml
293293 - "kube-reserved=cpu=1"
294294EOF
295295
296+ cat <<-'SCRIPT' >/usr/local/bin/5stack-cpu-state-check.sh
297+ #!/bin/bash
298+ STATE=/var/lib/kubelet/cpu_manager_state
299+ [ ! -f "$STATE" ] && exit 0
300+ CACHE="$(dirname "$STATE")/cpu_count"
301+ CURRENT=$(nproc)
302+ PREVIOUS=$(cat "$CACHE" 2>/dev/null || echo "$CURRENT")
303+ if [ "$CURRENT" != "$PREVIOUS" ]; then
304+ echo "CPU count changed from $PREVIOUS to $CURRENT, removing $STATE"
305+ rm -f "$STATE"
306+ fi
307+ echo "$CURRENT" > "$CACHE"
308+ SCRIPT
309+ chmod +x /usr/local/bin/5stack-cpu-state-check.sh
310+
311+ mkdir -p /etc/systemd/system/k3s-agent.service.d
312+
313+ cat <<-'DROPIN' >/etc/systemd/system/k3s-agent.service.d/cpu-state-check.conf
314+ [Service]
315+ ExecStartPre=/usr/local/bin/5stack-cpu-state-check.sh
316+ DROPIN
317+
318+ systemctl daemon-reload
319+
296320 rm -f /var/lib/kubelet/cpu_manager_state
297321
298322 systemctl restart k3s-agent
You can’t perform that action at this time.
0 commit comments