Skip to content

Commit ec8726f

Browse files
Himani Anil Deshpandehanwen-cluster
authored andcommitted
Add kernel locking for Ubuntu AMI's
1 parent 0e47df6 commit ec8726f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ phases:
192192
set -v
193193
OS='{{ build.OperatingSystemName.outputs.stdout }}'
194194
PLATFORM='{{ build.PlatformName.outputs.stdout }}'
195-
195+
KERNEL_VERSION=$(uname -a)
196196
if [[ ${!PLATFORM} == RHEL ]]; then
197197
yum install -y yum-plugin-versionlock
198198
# listing all the packages because wildcard does not work as expected
@@ -209,8 +209,10 @@ phases:
209209
elif [[ ${!OS} == "rhel8" ]] || [[ ${!OS} == "rhel9" ]] ; then
210210
yum versionlock redhat-release
211211
fi
212-
echo "Kernel version locked"
212+
else
213+
apt-mark hold linux-aws* linux-base* linux-headers* linux-image*
213214
fi
215+
echo "Kernel version is ${!KERNEL_VERSION}"
214216
215217
# Install prerequisite OS packages
216218
- name: InstallPrerequisite
@@ -340,7 +342,7 @@ phases:
340342
set -v
341343
OS='{{ build.OperatingSystemName.outputs.stdout }}'
342344
PLATFORM='{{ build.PlatformName.outputs.stdout }}'
343-
345+
BEFORE_KERNEL_VERSION='{{ build.PinKernelVersion.output.stdout }}'
344346
# Remove kernel version lock
345347
if [[ ${!PLATFORM} == RHEL ]]; then
346348
yum versionlock delete kernel kernel-core kernel-modules
@@ -352,12 +354,17 @@ phases:
352354
fi
353355
354356
if [[ ${!OS} == "rocky8" ]] || [[ ${!OS} == "rocky9" ]] ; then
355-
yum versionlock delete rocky-release
357+
yum versionlock delete rocky-release rocky-repos
356358
elif [[ ${!OS} == "rhel8" ]] || [[ ${!OS} == "rhel9" ]] ; then
357359
yum versionlock delete redhat-release
358360
fi
359-
echo "Kernel version unlocked"
361+
else
362+
apt-mark unhold linux-aws* linux-base* linux-headers* linux-image*
363+
fi
364+
if [[ "$(uname -a)" != ${!BEFORE_KERNEL_VERSION} ]] ; then
365+
echo "Kernel was upgraded from ${!BEFORE_KERNEL_VERSION} to $(uname -a)"
360366
fi
367+
echo "Kernel version unlocked"
361368
362369
- name: KeepSSM
363370
action: ExecuteBash

0 commit comments

Comments
 (0)