Skip to content

Commit 40879b3

Browse files
Harish Senthilkumarharishxr
authored andcommitted
Fix NVIDIA Driver version tracking in GH Actions
1 parent f8bea75 commit 40879b3

3 files changed

Lines changed: 45 additions & 35 deletions

File tree

NVIDIA_DRIVER_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# documentation or automation scripts.
1313

1414
nvidia_driver_version_al2 = "550.163.01"
15-
nvidia_driver_version_al2023 = "570.133.20"
15+
nvidia_driver_version_al2023 = "580.65.06"

scripts/check-update-security.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,11 @@ instance_id=$(aws ec2 run-instances \
141141

142142
# check-update based on platform
143143
if [[ $platform == al2023* ]]; then
144-
check_upgrade_options="--releasever=latest --sec-severity Critical --exclude=$EXCLUDE_SEC_UPDATES_PKGS"
144+
check_upgrade_options="--sec-severity Critical --exclude=$EXCLUDE_SEC_UPDATES_PKGS"
145145
if [[ $platform == *gpu ]]; then
146146
check_upgrade_options="nvidia-driver-cuda"
147147
fi
148-
# Run check-upgrade in a loop to ensure that the repo metadata is up to date
149-
command_params="commands=[\"for i in {1..5}; do dnf clean expire-cache; dnf --refresh check-upgrade $check_upgrade_options -q; code=$?; if [ $code -eq 100 ]; then exit 100; fi; sleep 5; done; exit 0\"]"
148+
command_params="commands=[\"dnf --refresh check-upgrade --releasever=latest $check_upgrade_options -q\"]"
150149
elif [ "$platform" = "al2_gpu" ]; then
151150
# The amzn2-nvidia repository does not provide updateinfo metadata (updateinfo.xml),
152151
# which YUM relies on to classify updates as security-related. The --security flag

scripts/check-update.sh

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
set -exo pipefail
2+
set -euo pipefail
33

44
usage() {
55
echo "Usage:"
@@ -33,63 +33,74 @@ handle_nvidia_version() {
3333
version=$(echo "$gpu_update" | cut -d' ' -f2)
3434
fi
3535

36-
# Update version entry if version is available and file exists
37-
if [ -n "$version" ] && [ -f NVIDIA_DRIVER_VERSION ]; then
36+
# Update version entry if version is available
37+
if [ -n "$version" ]; then
3838
if grep -q "^${version_key} = " NVIDIA_DRIVER_VERSION; then
39-
sed -i "s/^${version_key} = .*/${version_key} = \"${version}\"/" NVIDIA_DRIVER_VERSION
39+
if ! sed -i "s/^${version_key} = .*/${version_key} = \"${version}\"/" NVIDIA_DRIVER_VERSION; then
40+
echo "Failed to update NVIDIA driver version in NVIDIA_DRIVER_VERSION file"
41+
fi
4042
fi
4143
fi
4244
}
4345

44-
readonly ami_type="$1"
46+
readonly ami_type="${1:-}"
4547
if [ -z "$ami_type" ]; then
4648
error "AMI_TYPE must be provided"
4749
fi
4850

51+
# Validate AMI type
52+
case "$ami_type" in
53+
al2 | al2023)
54+
# Valid AMI types
55+
;;
56+
*)
57+
error "Invalid AMI type: $ami_type"
58+
;;
59+
esac
60+
61+
# Backup current release file and generate new one
4962
cp release-$ami_type.auto.pkrvars.hcl release-$ami_type.old.hcl
5063
./generate-release-vars.sh $ami_type
64+
65+
# Compare release files (excluding ami_version)
5166
set +e
5267
diff_val=$(diff <(grep -v ami_version release-$ami_type.old.hcl) <(grep -v ami_version release-$ami_type.auto.pkrvars.hcl))
5368
set -e
5469

55-
# Check for NVIDIA driver version for both AL2 and AL2023
56-
if [ "$ami_type" = "al2" ] || [ "$ami_type" = "al2023" ]; then
57-
gpu_update=$(./scripts/check-update-security.sh "${ami_type}_gpu")
58-
handle_nvidia_version "$ami_type" "$gpu_update"
59-
if [[ $gpu_update == true* ]]; then
60-
Update="true"
61-
fi
70+
# Initialize update flag
71+
Update="false"
72+
73+
# Check for NVIDIA driver version updates
74+
gpu_update=$(./scripts/check-update-security.sh "${ami_type}_gpu")
75+
handle_nvidia_version "$ami_type" "$gpu_update"
76+
if [[ $gpu_update == true* ]]; then
77+
Update="true"
6278
fi
6379

64-
# If no difference in dependencies, check for security update
80+
# Check for security updates if no dependency changes
6581
if [ -z "$diff_val" ]; then
66-
Update="false"
67-
case "$ami_type" in
68-
"al2" | "al2023")
69-
# Check security updates for each architecture type
70-
amd_update=$(./scripts/check-update-security.sh $ami_type)
71-
arm_update=$(./scripts/check-update-security.sh "${ami_type}_arm")
72-
73-
# Combine results
74-
if [[ $amd_update == true* ]] || [[ $arm_update == true* ]]; then
75-
Update="true"
76-
fi
77-
;;
78-
*)
79-
echo "Error: Invalid AMI type: $ami_type"
80-
exit 1
81-
;;
82-
esac
82+
# Check security updates for each architecture type
83+
amd_update=$(./scripts/check-update-security.sh $ami_type)
84+
arm_update=$(./scripts/check-update-security.sh "${ami_type}_arm")
85+
86+
# Combine results
87+
if [[ $amd_update == true* ]] || [[ $arm_update == true* ]]; then
88+
Update="true"
89+
fi
8390
else
8491
Update="true"
8592
fi
8693

94+
# Clean up temporary file
8795
rm "release-$ami_type.old.hcl"
8896

97+
# Handle git operations based on update status
8998
if [ "$Update" = "true" ]; then
9099
echo "Update exists for $ami_type"
91100
git add release-$ami_type.auto.pkrvars.hcl
92-
if [ -f NVIDIA_DRIVER_VERSION ] && ! git diff --quiet NVIDIA_DRIVER_VERSION; then
101+
102+
# Add NVIDIA_DRIVER_VERSION if it has changes
103+
if ! git diff --quiet NVIDIA_DRIVER_VERSION; then
93104
echo "NVIDIA driver version changes detected"
94105
git add NVIDIA_DRIVER_VERSION
95106
fi

0 commit comments

Comments
 (0)