Skip to content

Commit

Permalink
Adding check for empty runtimeclassname to NIMCache (#225)
Browse files Browse the repository at this point in the history
Signed-off-by: Vishesh Tanksale <[email protected]>
  • Loading branch information
visheshtanksale authored Nov 8, 2024
1 parent afe9aad commit b322edb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 5 additions & 2 deletions api/apps/v1alpha1/nimcache_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,11 @@ func (n *NIMCache) GetNodeSelectors() map[string]string {
}

// GetRuntimeClassName return the runtime class name for the NIMCache Job
func (n *NIMCache) GetRuntimeClassName() string {
return n.Spec.RuntimeClassName
func (n *NIMCache) GetRuntimeClassName() *string {
if n.Spec.RuntimeClassName == "" {
return nil
}
return &n.Spec.RuntimeClassName
}

// +kubebuilder:object:root=true
Expand Down
6 changes: 2 additions & 4 deletions internal/controller/nimcache_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,6 @@ func constructPodSpec(nimCache *appsv1alpha1.NIMCache, platformType k8sutil.Orch
"app.kubernetes.io/name": nimCache.Name,
"app.kubernetes.io/managed-by": "k8s-nim-operator",
}
runtimeClassName := nimCache.GetRuntimeClassName()
annotations := make(map[string]string)

if platformType == k8sutil.OpenShift {
Expand All @@ -931,7 +930,7 @@ func constructPodSpec(nimCache *appsv1alpha1.NIMCache, platformType k8sutil.Orch
Annotations: annotations,
},
Spec: corev1.PodSpec{
RuntimeClassName: &runtimeClassName,
RuntimeClassName: nimCache.GetRuntimeClassName(),
Containers: []corev1.Container{
{
Name: NIMCacheContainerName,
Expand Down Expand Up @@ -1005,7 +1004,6 @@ func (r *NIMCacheReconciler) getPodLogs(ctx context.Context, pod *corev1.Pod) (s
func (r *NIMCacheReconciler) constructJob(ctx context.Context, nimCache *appsv1alpha1.NIMCache, platformType k8sutil.OrchestratorType) (*batchv1.Job, error) {
logger := r.GetLogger()
pvcName := getPvcName(nimCache, nimCache.Spec.Storage.PVC)
runtimeClassName := nimCache.GetRuntimeClassName()
labels := map[string]string{
"app": "k8s-nim-operator",
"app.kubernetes.io/name": nimCache.Name,
Expand All @@ -1032,7 +1030,7 @@ func (r *NIMCacheReconciler) constructJob(ctx context.Context, nimCache *appsv1a
Annotations: annotations,
},
Spec: corev1.PodSpec{
RuntimeClassName: &runtimeClassName,
RuntimeClassName: nimCache.GetRuntimeClassName(),
SecurityContext: &corev1.PodSecurityContext{
RunAsUser: nimCache.GetUserID(),
FSGroup: nimCache.GetGroupID(),
Expand Down

0 comments on commit b322edb

Please sign in to comment.