diff --git a/dtk_nic_driver_build.sh b/dtk_nic_driver_build.sh index 65e7313..d1b8d78 100755 --- a/dtk_nic_driver_build.sh +++ b/dtk_nic_driver_build.sh @@ -4,7 +4,10 @@ : ${ENTRYPOINT_DEBUG:=false} : ${DTK_OCP_NIC_SHARED_DIR:=/mnt/shared-nvidia-nic-driver-toolkit} -DTK_OCP_NIC_SHARED_DIR=$DTK_OCP_NIC_SHARED_DIR/$(uname -r) +# Sanitize kernel version to match Kubernetes NFD label format used by network-operator for volume paths +# NFD replaces all non-alphanumeric characters (except -._) with underscore, then trims leading/trailing -._ +DTK_KVER=$(uname -r | sed 's/[^-A-Za-z0-9_.]/_/g' | sed 's/^[-_.]*//;s/[-_.]*$//') +DTK_OCP_NIC_SHARED_DIR=$DTK_OCP_NIC_SHARED_DIR/$DTK_KVER DTK_OCP_START_COMPILE_FLAG="" DTK_OCP_DONE_COMPILE_FLAG="" DTK_OCP_COMPILED_DRIVER_VER="" diff --git a/entrypoint.sh b/entrypoint.sh index 59ffba1..23b07d1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1360,7 +1360,10 @@ IS_OS_SLES=true; [[ "$(grep -i sles /etc/os-release -c)" == "0" ]] && IS_OS_SLES RHEL_MAJOR_VERSION=0 OPENSHIFT_VERSION="" -DTK_OCP_NIC_SHARED_DIR=${DTK_OCP_NIC_SHARED_DIR}/${FULL_KVER} +# Sanitize kernel version to match Kubernetes NFD label format used by network-operator for volume paths +# NFD replaces all non-alphanumeric characters (except -._) with underscore, then trims leading/trailing -._ +DTK_KVER=$(echo "${FULL_KVER}" | sed 's/[^-A-Za-z0-9_.]/_/g' | sed 's/^[-_.]*//;s/[-_.]*$//') +DTK_OCP_NIC_SHARED_DIR=${DTK_OCP_NIC_SHARED_DIR}/${DTK_KVER} DTK_OCP_BUILD_SCRIPT="/root/dtk_nic_driver_build.sh" DTK_OCP_START_COMPILE_FLAG=${DTK_OCP_NIC_SHARED_DIR}/dtk_start_compile DTK_OCP_DONE_COMPILE_FLAG_PREFIX=${DTK_OCP_NIC_SHARED_DIR}/dtk_done_compile_