Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion parts/linux/cloud-init/artifacts/cse_config_gpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,15 @@ configGPUDrivers() {
}

validateGPUDrivers() {
retrycmd_if_failure 24 5 25 nvidia-modprobe -u -c0 && echo "gpu driver loaded" || configGPUDrivers || exit $ERR_GPU_DRIVERS_START_FAIL
# A cache-only VHD has no host driver yet. Retrying a missing executable cannot make it ready
# and consumes 115 seconds of the CSE budget before the existing full-install fallback.
if [ "$OS" = "$UBUNTU_OS_NAME" ] && [ "${IS_VHD,,}" = "true" ] &&
[ "$(getCPUArch)" = "amd64" ] && ! command -v nvidia-modprobe >/dev/null 2>&1; then
echo "NVIDIA driver is not installed in this Ubuntu VHD; installing before validation"
configGPUDrivers || exit $ERR_GPU_DRIVERS_START_FAIL
else
retrycmd_if_failure 24 5 25 nvidia-modprobe -u -c0 && echo "gpu driver loaded" || configGPUDrivers || exit $ERR_GPU_DRIVERS_START_FAIL
fi

if which nvidia-smi; then
SMI_RESULT=$(retrycmd_if_failure 24 5 30 nvidia-smi)
Expand Down
97 changes: 97 additions & 0 deletions spec/parts/linux/cloud-init/artifacts/cse_config_gpu_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,103 @@ Describe 'cse_config_gpu.sh'
End
End

Describe 'validation on cache-only Ubuntu VHDs'
OS="$UBUNTU_OS_NAME"
IS_VHD=true
MOCK_CPU_ARCH=amd64
MOCK_MODPROBE_PRESENT=1
MOCK_MODPROBE_RESULT=0
MOCK_INSTALL_RESULT=0
ERR_GPU_DRIVERS_START_FAIL=84

getCPUArch() { echo "$MOCK_CPU_ARCH"; }
command() {
if [ "$*" = "-v nvidia-modprobe" ]; then
return "$MOCK_MODPROBE_PRESENT"
fi
builtin command "$@"
}
retrycmd_if_failure() {
echo "retry $*" >&2
if [ "$4" = "nvidia-modprobe" ]; then
return "$MOCK_MODPROBE_RESULT"
fi
Comment thread
Copilot marked this conversation as resolved.
Comment thread
Copilot marked this conversation as resolved.
}
configGPUDrivers() {
echo "normal driver installation"
return "$MOCK_INSTALL_RESULT"
}
which() { return 0; }

It 'installs an absent driver without retrying the missing executable'
When run validateGPUDrivers
The status should be success
The output should include "installing before validation"
The output should include "normal driver installation"
The output should include "gpu driver working fine"
The stderr should not include "nvidia-modprobe"
The stderr should include "retry 24 5 30 nvidia-smi"
End

It 'accepts the existing uppercase VHD flag'
IS_VHD=TRUE
When run validateGPUDrivers
The status should be success
The output should include "normal driver installation"
The stderr should not include "nvidia-modprobe"
The stderr should include "nvidia-smi"
End

It 'propagates installation failure without reporting successful validation'
MOCK_INSTALL_RESULT=1
When run validateGPUDrivers
The status should equal 84
The output should include "normal driver installation"
The output should not include "gpu driver working fine"
The stderr should equal ""
End

It 'keeps readiness retries for a present driver'
MOCK_MODPROBE_PRESENT=0
When run validateGPUDrivers
The status should be success
The output should include "gpu driver loaded"
The output should not include "normal driver installation"
The stderr should include "retry 24 5 25 nvidia-modprobe -u -c0"
The stderr should include "nvidia-smi"
End

It 'preserves the full-install fallback after an installed driver fails to load'
MOCK_MODPROBE_PRESENT=0
MOCK_MODPROBE_RESULT=1
When run validateGPUDrivers
The status should be success
The output should include "normal driver installation"
The output should not include "installing before validation"
The stderr should include "retry 24 5 25 nvidia-modprobe -u -c0"
The stderr should include "nvidia-smi"
End

Parameters
UBUNTU false amd64
UBUNTU "" amd64
UBUNTU true arm64
AZURELINUX true amd64
End

It "preserves legacy validation for OS=$1 VHD=$2 arch=$3"
OS=$1
IS_VHD=$2
MOCK_CPU_ARCH=$3
When run validateGPUDrivers
The status should be success
The output should include "gpu driver loaded"
The output should not include "normal driver installation"
The stderr should include "retry 24 5 25 nvidia-modprobe -u -c0"
The stderr should include "nvidia-smi"
End
End

Describe 'logGPUDriverPrebakeReadiness'
It 'reports marker_present=false when no prebake marker exists'
GPU_DKMS_MARKER_FILE="$(mktemp)"; rm -f "${GPU_DKMS_MARKER_FILE}"
Expand Down
6 changes: 6 additions & 0 deletions vhdbuilder/packer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Goal1: remove mariner workflow so things will be simplified.
- `cse_config_network.sh` -> `provision_configs_network.sh`
- `cse_config_addons.sh` -> `provision_configs_addons.sh` (autoscaler, ACI connector, Azure Policy)

On managed Ubuntu amd64 VHD nodes, GPU validation selects the normal installer
immediately if `nvidia-modprobe` is absent. A cached installer image is not an
installed host driver. Present drivers retain the existing readiness retries and
full-install fallback; ARM64, other OSes and non-VHD images retain their existing
validation path. GPU eligibility and opt-out decisions still happen in `nodePrep`.

`cse_cmd.sh` and the ANC parser provide their paths through
`CSE_CONFIG_GPU_FILEPATH`, `CSE_CONFIG_LOCALDNS_FILEPATH`,
`CSE_CONFIG_KUBELET_FILEPATH`, `CSE_CONFIG_NETWORK_FILEPATH`, and
Expand Down
Loading