Skip to content

Commit 90baef2

Browse files
authored
fix: prewarm containerd in boothook (#8604)
1 parent 99aa2a7 commit 90baef2

18 files changed

Lines changed: 89 additions & 14 deletions

parts/linux/cloud-init/artifacts/cse_config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ EOF
868868
}
869869

870870
ensureSnapshotUpdate() {
871-
systemctlEnableAndStart snapshot-update.timer 30 || exit $ERR_SNAPSHOT_UPDATE_START_FAIL
871+
systemctlEnableAndStartNoBlock snapshot-update.timer 30 || exit $ERR_SNAPSHOT_UPDATE_START_FAIL
872872
}
873873

874874
ensureMigPartition(){

parts/linux/cloud-init/artifacts/cse_main.sh

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ function basePrep {
199199
fi
200200
setupCNIDirs
201201

202-
# pre-warm containerd by checking its version.
203-
nohup /bin/sh -c '/usr/bin/containerd --version >/dev/null 2>&1' >/dev/null 2>&1 &
204-
205202
# Network plugin already installed on Azure Linux OS Guard
206203
if ! isAzureLinuxOSGuard "$OS" "$OS_VARIANT"; then
207204
logs_to_events "AKS.CSE.installNetworkPlugin" installNetworkPlugin
@@ -346,12 +343,6 @@ EOF
346343
disableVulnerableKernelModule "rxrpc" "DirtyFrag (RxRPC page-cache write, bypasses AppArmor userns)"
347344
fi
348345

349-
if ! isAzureLinuxOSGuard "$OS" "$OS_VARIANT"; then
350-
if [ "$OS" = "$UBUNTU_OS_NAME" ] || isMarinerOrAzureLinux "$OS"; then
351-
logs_to_events "AKS.CSE.ubuntuSnapshotUpdate" ensureSnapshotUpdate
352-
fi
353-
fi
354-
355346
if [ "$FULL_INSTALL_REQUIRED" = "true" ]; then
356347
if [ "$OS" = "$UBUNTU_OS_NAME" ]; then
357348
# mitigation for bug https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1676635
@@ -587,10 +578,16 @@ function nodePrep {
587578
checkServiceHealth kubelet || exit $ERR_KUBELET_FAIL
588579

589580
if systemctl cat aks-log-collector.timer &>/dev/null; then
590-
systemctlEnableAndStartNoBlock aks-log-collector.timer 30 || echo "Warning: Could not start aks-log-collector.timer"
591-
else
592-
echo "aks-log-collector.timer not found on this VHD, skipping"
593-
fi
581+
systemctlEnableAndStartNoBlock aks-log-collector.timer 30 || echo "Warning: Could not start aks-log-collector.timer"
582+
else
583+
echo "aks-log-collector.timer not found on this VHD, skipping"
584+
fi
585+
586+
if ! isAzureLinuxOSGuard "$OS" "$OS_VARIANT"; then
587+
if [ "$OS" = "$UBUNTU_OS_NAME" ] || isMarinerOrAzureLinux "$OS"; then
588+
logs_to_events "AKS.CSE.ubuntuSnapshotUpdate" ensureSnapshotUpdate
589+
fi
590+
fi
594591

595592
if $REBOOTREQUIRED; then
596593
echo 'reboot required, rebooting node in 1 minute'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# cse_preload.sh warms binaries and containerd caches needed by CSE early in
4+
# boot so that node provisioning runs against an already-warm page cache.
5+
# This is best-effort: every command is backgrounded and its output and exit
6+
# status are intentionally ignored. It must never block or fail provisioning.
7+
8+
/usr/bin/containerd --version >/dev/null 2>&1 &
9+
cat /var/lib/containerd/io.containerd.metadata.v1.bolt/meta.db >/dev/null 2>&1 &
10+
find /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots -maxdepth 1 >/dev/null 2>&1 &
11+
/sbin/modprobe overlay >/dev/null 2>&1 &
12+
13+
wait

pkg/agent/baker.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ logger -t aks-boothook "boothook start $(date -Ins)"
5252
5353
mkdir -p /opt/azure/containers
5454
55+
nohup /bin/bash /opt/azure/containers/provision_preload.sh >/dev/null 2>&1 &
56+
5557
cat <<'EOF' | base64 -d | gzip -d >%[1]s
5658
%[2]s
5759
EOF

pkg/agent/baker_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,7 @@ var _ = Describe("getLinuxNodeBootstrappingPayload", func() {
14861486
Expect(string(decodedPayload)).To(ContainSubstring(nodeCustomDataPath))
14871487
Expect(string(decodedPayload)).To(ContainSubstring(encodedNodeCustomData))
14881488
Expect(string(decodedPayload)).To(ContainSubstring(nbcCmdFilePath))
1489+
Expect(string(decodedPayload)).To(ContainSubstring("/opt/azure/containers/provision_preload.sh"))
14891490
})
14901491

14911492
It("should render initAKSCustomCloud file in scriptless custom data for default cloud with Ubuntu", func() {

vhdbuilder/packer/imagecustomizer/azlosguard/azlosguard.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ os:
8282
- source: /AgentBaker/parts/linux/cloud-init/artifacts/cse_main.sh
8383
destination: /opt/azure/containers/provision.sh
8484
permissions: 744
85+
- source: /AgentBaker/parts/linux/cloud-init/artifacts/cse_preload.sh
86+
destination: /opt/azure/containers/provision_preload.sh
87+
permissions: 744
8588
- source: /AgentBaker/parts/linux/cloud-init/artifacts/cse_start.sh
8689
destination: /opt/azure/containers/provision_start.sh
8790
permissions: 744

vhdbuilder/packer/packer_source.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ copyPackerFiles() {
241241
CSE_MAIN_DEST=/opt/azure/containers/provision.sh
242242
cpAndMode $CSE_MAIN_SRC $CSE_MAIN_DEST 0744
243243

244+
CSE_PRELOAD_SRC=/home/packer/provision_preload.sh
245+
CSE_PRELOAD_DEST=/opt/azure/containers/provision_preload.sh
246+
cpAndMode $CSE_PRELOAD_SRC $CSE_PRELOAD_DEST 0744
247+
244248
CSE_START_SRC=/home/packer/provision_start.sh
245249
CSE_START_DEST=/opt/azure/containers/provision_start.sh
246250
cpAndMode $CSE_START_SRC $CSE_START_DEST 0744

vhdbuilder/packer/vhd-image-builder-acl-arm64.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@
162162
"source": "parts/linux/cloud-init/artifacts/cse_main.sh",
163163
"destination": "/home/packer/provision.sh"
164164
},
165+
{
166+
"type": "file",
167+
"source": "parts/linux/cloud-init/artifacts/cse_preload.sh",
168+
"destination": "/home/packer/provision_preload.sh"
169+
},
165170
{
166171
"type": "file",
167172
"source": "parts/linux/cloud-init/artifacts/cse_start.sh",

vhdbuilder/packer/vhd-image-builder-acl.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@
162162
"source": "parts/linux/cloud-init/artifacts/cse_main.sh",
163163
"destination": "/home/packer/provision.sh"
164164
},
165+
{
166+
"type": "file",
167+
"source": "parts/linux/cloud-init/artifacts/cse_preload.sh",
168+
"destination": "/home/packer/provision_preload.sh"
169+
},
165170
{
166171
"type": "file",
167172
"source": "parts/linux/cloud-init/artifacts/cse_start.sh",

vhdbuilder/packer/vhd-image-builder-arm64-gb.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@
187187
"source": "parts/linux/cloud-init/artifacts/cse_main.sh",
188188
"destination": "/home/packer/provision.sh"
189189
},
190+
{
191+
"type": "file",
192+
"source": "parts/linux/cloud-init/artifacts/cse_preload.sh",
193+
"destination": "/home/packer/provision_preload.sh"
194+
},
190195
{
191196
"type": "file",
192197
"source": "parts/linux/cloud-init/artifacts/cse_start.sh",

0 commit comments

Comments
 (0)