From a4af1564cbd86571226b9828443deff774cf500b Mon Sep 17 00:00:00 2001 From: Shiva Krishna Merla Date: Thu, 19 Dec 2024 05:21:39 +0530 Subject: [PATCH] Handle updated model manifest path with latest NIMs (#262) * Handle updated model manifest path with latest NIMs Model manifest file path has changed with recent NIMs to /opt/nim/etc/default/model_manifest.yaml. This change will handle that. Signed-off-by: Shiva Krishna, Merla * Update command to check for the latest manifest path inside the NIM container Signed-off-by: Shiva Krishna, Merla --------- Signed-off-by: Shiva Krishna, Merla --- internal/controller/nimcache_controller.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/controller/nimcache_controller.go b/internal/controller/nimcache_controller.go index 5b254693..c1bb5b3c 100644 --- a/internal/controller/nimcache_controller.go +++ b/internal/controller/nimcache_controller.go @@ -910,6 +910,21 @@ func getManifestConfigName(nimCache *appsv1alpha1.NIMCache) string { return fmt.Sprintf("%s-manifest", nimCache.GetName()) } +func getCommand() []string { + return []string{ + "sh", + "-c", + strings.Join([]string{ + "if [ -f /opt/nim/etc/default/model_manifest.yaml ]; then", + "cat /opt/nim/etc/default/model_manifest.yaml;", + "else", + "cat /etc/nim/config/model_manifest.yaml;", + "fi;", + "sleep infinity", + }, " "), + } +} + // constructPodSpec constructs a Pod specification func constructPodSpec(nimCache *appsv1alpha1.NIMCache, platformType k8sutil.OrchestratorType) *corev1.Pod { labels := map[string]string{ @@ -938,7 +953,7 @@ func constructPodSpec(nimCache *appsv1alpha1.NIMCache, platformType k8sutil.Orch { Name: NIMCacheContainerName, Image: nimCache.Spec.Source.NGC.ModelPuller, - Command: []string{"sh", "-c", "cat /etc/nim/config/model_manifest.yaml; sleep infinity"}, + Command: getCommand(), SecurityContext: &corev1.SecurityContext{ AllowPrivilegeEscalation: ptr.To[bool](false), Capabilities: &corev1.Capabilities{