transformValidatorSecurityContext updates the security context for a validator container so that it runs as uid 0. Some of the validations run commands that require root privileges (e.g. chroot). In addition, all validations create / delete status files in the '/run/nvidia/validations' host path vol
(ctr *corev1.Container)
| 2313 | // volume. This directory is initially created by the kubelet and thus has |
| 2314 | // the same group and ownership as the kubelet. |
| 2315 | func transformValidatorSecurityContext(ctr *corev1.Container) { |
| 2316 | if ctr.SecurityContext == nil { |
| 2317 | ctr.SecurityContext = &corev1.SecurityContext{} |
| 2318 | } |
| 2319 | ctr.SecurityContext.RunAsUser = rootUID |
| 2320 | } |
| 2321 | |
| 2322 | // TransformValidator transforms nvidia-operator-validator daemonset with required config as per ClusterPolicy |
| 2323 | func TransformValidator(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n ClusterPolicyController) error { |
no outgoing calls
no test coverage detected