Skip to content

Commit 99aca8a

Browse files
hanwen-clusterhanwen-pcluste
authored andcommitted
Simplify Ubuntu kernel pinning during build image OS update
Previously we were installing LTS kernel to pin the kernel. This is only valid when the base AMI has a kernel equal or older than the LTS kernel. If the base AMI has new kernels, the installed LTS kernel is not used and just taking disk space and possibly dissatisfies security scanning, although CVEs on not-in-use kernels are not exploitable. This commit simplifies the code and avoid installing a kernel that is not going to be used. This commit uses `--with-new-pkgs` to control if the kernel is upgraded. Because kernel upgrade usually requires `--with-new-pkgs` Signed-off-by: Hanwen <hanwenli@amazon.com>
1 parent c691623 commit 99aca8a

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,6 @@ phases:
215215
yum versionlock redhat-release
216216
fi
217217
echo "Kernel version locked"
218-
219-
elif [[ ${!PLATFORM} == DEBIAN ]]; then
220-
# Install LTS kernel packages
221-
# linux-aws-lts-22.04 depends on linux-image-aws-lts-22.04 and linux-headers-aws-lts-22.04
222-
# linux-image-aws-lts-22.04 depends on linux-image-5.15.0-10xx-aws, that depends on linux-modules-5.15.0-10xx-aws
223-
# linux-headers-aws-lts-22.04 depends on linux-headers-5.15.0-10xx-aws
224-
UBUNTU_VERSION=$(lsb_release -sr)
225-
DEBIAN_FRONTEND=noninteractive apt-get -y install linux-aws-lts-${!UBUNTU_VERSION}
226-
227-
# remove not updated meta-packages
228-
apt-get -y remove linux-image-aws linux-aws linux-headers-aws
229-
echo "Kernel updated to LTS version"
230218
fi
231219
fi
232220
@@ -238,6 +226,7 @@ phases:
238226
set -v
239227
OS='{{ build.OperatingSystemName.outputs.stdout }}'
240228
PLATFORM='{{ build.PlatformName.outputs.stdout }}'
229+
DISABLE_KERNEL_UPDATE='{{ build.DisableKernelUpdate.outputs.stdout }}'
241230
242231
if [[ ${!PLATFORM} == RHEL ]]; then
243232
yum -y update
@@ -251,7 +240,11 @@ phases:
251240
252241
elif [[ ${!PLATFORM} == DEBIAN ]]; then
253242
DEBIAN_FRONTEND=noninteractive apt-get -y update
254-
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --with-new-pkgs upgrade
243+
if [[ ${!DISABLE_KERNEL_UPDATE} == true ]]; then
244+
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
245+
else
246+
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --with-new-pkgs upgrade
247+
fi
255248
apt-get --purge autoremove -y
256249
fi
257250
@@ -287,7 +280,6 @@ phases:
287280
288281
elif [[ ${!PLATFORM} == DEBIAN ]]; then
289282
if [[ ${!DISABLE_KERNEL_UPDATE} != true ]]; then
290-
# already installed to LTS version
291283
apt-get -y install linux-aws linux-headers-aws linux-image-aws
292284
fi
293285
fi

0 commit comments

Comments
 (0)