@@ -175,9 +175,7 @@ func (r *NIMServiceReconciler) reconcileNIMService(ctx context.Context, nimServi
175175 }
176176
177177 var result * ctrl.Result
178- result , err = r .checkInferenceServiceStatus (ctx ,
179- & types.NamespacedName {Name : nimService .GetName (), Namespace : nimService .GetNamespace ()},
180- nimService , deploymentMode )
178+ result , err = r .checkInferenceServiceStatus (ctx , nimService , deploymentMode )
181179
182180 if err != nil {
183181 r .log .Error (err , "Unable to update status" )
@@ -400,7 +398,7 @@ func (r *NIMServiceReconciler) renderAndSyncInferenceService(ctx context.Context
400398
401399 logger := r .log
402400
403- var profileEnv * corev1.EnvVar
401+ var profileEnv * [] corev1.EnvVar
404402 var profile * appsv1alpha1.NIMProfile
405403 var gpuResources * corev1.ResourceRequirements
406404 var initContainers []corev1.Container
@@ -410,9 +408,11 @@ func (r *NIMServiceReconciler) renderAndSyncInferenceService(ctx context.Context
410408
411409 // Setup env for explicit override profile is specified
412410 if modelProfile != "" {
413- profileEnv = & corev1.EnvVar {
414- Name : "NIM_MODEL_PROFILE" ,
415- Value : modelProfile ,
411+ profileEnv = & []corev1.EnvVar {
412+ {
413+ Name : "NIM_MODEL_PROFILE" ,
414+ Value : modelProfile ,
415+ },
416416 }
417417
418418 // Only assign GPU resources if the NIMCache is for optimized NIM
@@ -457,16 +457,18 @@ func (r *NIMServiceReconciler) renderAndSyncInferenceService(ctx context.Context
457457
458458 isvcParams .PodResourceClaims = shared .GetPodResourceClaims (namedDraResources )
459459 if nimCache .IsUniversalNIM () {
460- isvcParams .Env = append (isvcParams .Env , corev1.EnvVar {
461- Name : "NIM_MODEL_NAME" ,
462- Value : utils .DefaultModelStorePath ,
463- })
460+ isvcParams .Env = utils .MergeEnvVars ([]corev1.EnvVar {
461+ {
462+ Name : "NIM_MODEL_NAME" ,
463+ Value : utils .DefaultModelStorePath ,
464+ },
465+ }, isvcParams .Env )
464466 }
465467 // Setup volume mounts with model store
466468 isvcParams .Volumes = nimService .GetVolumes (* modelPVC )
467469 isvcParams .VolumeMounts = nimService .GetVolumeMounts (* modelPVC )
468470 if profileEnv != nil {
469- isvcParams .Env = append ( isvcParams .Env , * profileEnv )
471+ isvcParams .Env = utils . MergeEnvVars ( * profileEnv , isvcParams .Env )
470472 }
471473 // Auto assign GPU resources in case of the optimized profile
472474 if gpuResources != nil {
@@ -602,12 +604,12 @@ func (r *NIMServiceReconciler) addGPUResources(ctx context.Context, nimService *
602604 return resources , nil
603605}
604606
605- func (r * NIMServiceReconciler ) checkInferenceServiceStatus (ctx context.Context , namespacedName * types. NamespacedName ,
606- nimService * appsv1alpha1. NIMService , deploymentMode kserveconstants.DeploymentModeType ) (* ctrl.Result , error ) {
607+ func (r * NIMServiceReconciler ) checkInferenceServiceStatus (ctx context.Context , nimService * appsv1alpha1. NIMService ,
608+ deploymentMode kserveconstants.DeploymentModeType ) (* ctrl.Result , error ) {
607609 logger := r .log
608610
609611 // Check if InferenceService is ready
610- msg , ready , err := r .isInferenceServiceReady (ctx , namespacedName )
612+ msg , ready , err := r .isInferenceServiceReady (ctx , nimService )
611613 if err != nil {
612614 return & ctrl.Result {}, err
613615 }
@@ -632,7 +634,7 @@ func (r *NIMServiceReconciler) checkInferenceServiceStatus(ctx context.Context,
632634 "NIMService %s not ready yet, msg: %s" , nimService .Name , msg )
633635 } else {
634636 // Update NIMServiceStatus with model config.
635- updateErr := r .updateModelStatus (ctx , nimService , namespacedName , deploymentMode )
637+ updateErr := r .updateModelStatus (ctx , nimService , deploymentMode )
636638 if updateErr != nil {
637639 logger .Info ("WARN: Model status update failed, will retry in 5 seconds" , "error" , updateErr .Error ())
638640 return & ctrl.Result {RequeueAfter : 5 * time .Second }, nil
@@ -653,33 +655,36 @@ func (r *NIMServiceReconciler) checkInferenceServiceStatus(ctx context.Context,
653655}
654656
655657// isInferenceServiceReady checks if the InferenceService is ready.
656- func (r * NIMServiceReconciler ) isInferenceServiceReady (ctx context.Context , namespacedName * types. NamespacedName ) (string , bool , error ) {
658+ func (r * NIMServiceReconciler ) isInferenceServiceReady (ctx context.Context , nimService * appsv1alpha1. NIMService ) (string , bool , error ) {
657659 logger := r .log
658660
659661 isvc := & kservev1beta1.InferenceService {}
660- err := r .Get (ctx , client.ObjectKey {Name : namespacedName .Name , Namespace : namespacedName .Namespace }, isvc )
662+ err := r .Get (ctx , client.ObjectKey {Name : nimService .Name , Namespace : nimService .Namespace }, isvc )
661663 if err != nil {
662664 logger .Error (err , "failed to fetch inferenceservice" )
663665 if k8serrors .IsNotFound (err ) {
664- return "" , false , nil
666+ return fmt . Sprintf ( "Waiting for InferenceService %q creation" , nimService . Name ) , false , nil
665667 }
666668 return "" , false , err
667669 }
668670
669- var cond knativeapis.Condition
671+ var cond * knativeapis.Condition
670672 for i := range isvc .Status .Conditions {
671673 c := isvc .Status .Conditions [i ]
672674 if c .Type == kservev1beta1 .PredictorReady {
673- cond = c
675+ cond = & c
674676 break
675677 }
676678 }
677- return cond .GetMessage (), cond .IsTrue (), nil
679+ if cond != nil {
680+ return cond .GetMessage (), cond .IsTrue (), nil
681+ }
682+ return fmt .Sprintf ("Waiting for InferenceService %q reporting Predictor readiness" , isvc .Name ), false , nil
678683}
679684
680685func (r * NIMServiceReconciler ) updateModelStatus (ctx context.Context , nimService * appsv1alpha1.NIMService ,
681- namespacedName * types. NamespacedName , deploymentMode kserveconstants.DeploymentModeType ) error {
682- clusterEndpoint , externalEndpoint , err := r .getNIMModelEndpoints (ctx , nimService , namespacedName , deploymentMode )
686+ deploymentMode kserveconstants.DeploymentModeType ) error {
687+ clusterEndpoint , externalEndpoint , err := r .getNIMModelEndpoints (ctx , nimService , deploymentMode )
683688 if err != nil {
684689 return err
685690 }
@@ -698,11 +703,11 @@ func (r *NIMServiceReconciler) updateModelStatus(ctx context.Context, nimService
698703}
699704
700705func (r * NIMServiceReconciler ) getNIMModelEndpoints (ctx context.Context , nimService * appsv1alpha1.NIMService ,
701- namespacedName * types. NamespacedName , deploymentMode kserveconstants.DeploymentModeType ) (string , string , error ) {
706+ deploymentMode kserveconstants.DeploymentModeType ) (string , string , error ) {
702707 logger := r .log
703708
704709 isvc := & kservev1beta1.InferenceService {}
705- err := r .Get (ctx , client.ObjectKey {Name : namespacedName .Name , Namespace : namespacedName .Namespace }, isvc )
710+ err := r .Get (ctx , client.ObjectKey {Name : nimService .Name , Namespace : nimService .Namespace }, isvc )
706711 if err != nil {
707712 logger .Error (err , "unable to fetch k8s service" , "nimservice" , nimService .GetName ())
708713 return "" , "" , err
0 commit comments