Skip to content

Commit cfb5988

Browse files
Himani Anil Deshpandehanwen-cluster
authored andcommitted
Adding Kernel Pinning in parallelcluster.yaml
1 parent 8b63b4e commit cfb5988

File tree

1 file changed

+76
-8
lines changed

1 file changed

+76
-8
lines changed

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

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,54 @@ phases:
184184
fi
185185
fi
186186
187+
- name: CreatingJsonFile
188+
action: CreateFile
189+
inputs:
190+
- path: /etc/parallelcluster/image_dna.json
191+
content: |
192+
${CfnParamChefDnaJson}
193+
overwrite: true
194+
195+
- name: DisableKernelUpdate
196+
action: ExecuteBash
197+
inputs:
198+
commands:
199+
- |
200+
set -v
201+
DISABLE_KERNEL_UPDATE=$(cat /etc/parallelcluster/image_dna.json | jq -r '.cluster.disable_kernel_update.enabled')
202+
echo "${!DISABLE_KERNEL_UPDATE}"
203+
204+
- name: PinKernelVersion
205+
action: ExecuteBash
206+
inputs:
207+
commands:
208+
- |
209+
set -v
210+
OS='{{ build.OperatingSystemName.outputs.stdout }}'
211+
PLATFORM='{{ build.PlatformName.outputs.stdout }}'
212+
DISABLE_KERNEL_UPDATE='{{ build.DisableKernelUpdate.outputs.stdout }}'
213+
214+
if [[ ${!DISABLE_KERNEL_UPDATE} == true ]]; then
215+
if [[ ${!PLATFORM} == RHEL ]]; then
216+
yum install -y yum-plugin-versionlock
217+
# listing all the packages because wildcard does not work as expected
218+
yum versionlock kernel kernel-core kernel-modules
219+
220+
if [[ ${!OS} == "alinux2" ]] || [[ ${!OS} == "alinux2023" ]] ; then
221+
yum versionlock kernel-abi-whitelists
222+
else
223+
yum versionlock kernel-abi-stablelists
224+
fi
225+
226+
if [[ ${!OS} == "rocky8" ]] || [[ ${!OS} == "rocky9" ]] ; then
227+
yum versionlock rocky-release rocky-repos
228+
elif [[ ${!OS} == "rhel8" ]] || [[ ${!OS} == "rhel9" ]] ; then
229+
yum versionlock redhat-release
230+
fi
231+
echo "Kernel version locked"
232+
fi
233+
fi
234+
187235
# Install prerequisite OS packages
188236
- name: InstallPrerequisite
189237
action: ExecuteBash
@@ -284,14 +332,6 @@ phases:
284332
cookbook_path ['/etc/chef/cookbooks']
285333
overwrite: true
286334

287-
- name: CreatingJsonFile
288-
action: CreateFile
289-
inputs:
290-
- path: /etc/parallelcluster/image_dna.json
291-
content: |
292-
${CfnParamChefDnaJson}
293-
overwrite: true
294-
295335
- name: InstallPClusterPackages
296336
action: ExecuteBash
297337
inputs:
@@ -310,6 +350,34 @@ phases:
310350
{{ build.PClusterCookbookVersionName.outputs.stdout }}
311351
overwrite: true
312352

353+
- name: RemoveKernelPin
354+
action: ExecuteBash
355+
inputs:
356+
commands:
357+
- |
358+
set -v
359+
OS='{{ build.OperatingSystemName.outputs.stdout }}'
360+
PLATFORM='{{ build.PlatformName.outputs.stdout }}'
361+
DISABLE_KERNEL_UPDATE='{{ build.DisableKernelUpdate.outputs.stdout }}'
362+
363+
# Remove kernel version lock
364+
if [[ ${!DISABLE_KERNEL_UPDATE} == true ]] && [[ ${!PLATFORM} == RHEL ]]; then
365+
yum versionlock delete kernel kernel-core kernel-modules
366+
367+
if [[ ${!OS} == "alinux2" ]] || [[ ${!OS} == "alinux2023" ]] ; then
368+
yum versionlock delete kernel-abi-whitelists
369+
else
370+
yum versionlock delete kernel-abi-stablelists
371+
fi
372+
373+
if [[ ${!OS} == "rocky8" ]] || [[ ${!OS} == "rocky9" ]] ; then
374+
yum versionlock delete rocky-release
375+
elif [[ ${!OS} == "rhel8" ]] || [[ ${!OS} == "rhel9" ]] ; then
376+
yum versionlock delete redhat-release
377+
fi
378+
echo "Kernel version unlocked"
379+
fi
380+
313381
- name: KeepSSM
314382
action: ExecuteBash
315383
inputs:

0 commit comments

Comments
 (0)