@@ -42,7 +42,6 @@ import (
4242
4343 coreapi "github.com/inftyai/llmaz/api/core/v1alpha1"
4444 inferenceapi "github.com/inftyai/llmaz/api/inference/v1alpha1"
45- "github.com/inftyai/llmaz/pkg"
4645 helper "github.com/inftyai/llmaz/pkg/controller_helper"
4746 modelSource "github.com/inftyai/llmaz/pkg/controller_helper/modelsource"
4847 pkgUtil "github.com/inftyai/llmaz/pkg/util"
@@ -114,7 +113,7 @@ func ValidateService(ctx context.Context, k8sClient client.Client, service *infe
114113 return err
115114 }
116115
117- if err := ValidateConfigmap (ctx , k8sClient , service ); err != nil {
116+ if err := ValidateConfigmap (ctx , k8sClient , service , & workload ); err != nil {
118117 return err
119118 }
120119
@@ -143,8 +142,8 @@ func ValidateModelLoader(model *coreapi.OpenModel, index int, template corev1.Po
143142 if initContainer .Name != containerName {
144143 return fmt .Errorf ("unexpected initContainer name, want %s, got %s" , modelSource .MODEL_LOADER_CONTAINER_NAME , initContainer .Name )
145144 }
146- if initContainer .Image != pkg . LOADER_IMAGE {
147- return fmt .Errorf ("unexpected initContainer image, want %s, got %s" , pkg . LOADER_IMAGE , initContainer . Image )
145+ if initContainer .Image == "" {
146+ return fmt .Errorf ("unexpected initContainer image, initContainer image should not be empty" )
148147 }
149148
150149 var envStrings []string
@@ -440,7 +439,7 @@ func CheckServiceAvaliable() error {
440439 return nil
441440}
442441
443- func ValidateConfigmap (ctx context.Context , k8sClient client.Client , service * inferenceapi.Service ) error {
442+ func ValidateConfigmap (ctx context.Context , k8sClient client.Client , service * inferenceapi.Service , workload * lws. LeaderWorkerSet ) error {
444443 cm := corev1.ConfigMap {}
445444 if err := k8sClient .Get (ctx , types.NamespacedName {Name : "llmaz-global-config" , Namespace : "llmaz-system" }, & cm ); err != nil {
446445 return err
@@ -451,6 +450,7 @@ func ValidateConfigmap(ctx context.Context, k8sClient client.Client, service *in
451450 return fmt .Errorf ("failed to parse global configmap: %v" , err )
452451 }
453452
453+ // Validate scheduler name.
454454 if service .Spec .WorkloadTemplate .LeaderTemplate != nil {
455455 if service .Spec .WorkloadTemplate .LeaderTemplate .Spec .SchedulerName != data .SchedulerName {
456456 return fmt .Errorf ("unexpected scheduler name %s, want %s" , service .Spec .WorkloadTemplate .LeaderTemplate .Spec .SchedulerName , data .SchedulerName )
@@ -461,5 +461,22 @@ func ValidateConfigmap(ctx context.Context, k8sClient client.Client, service *in
461461 return fmt .Errorf ("unexpected scheduler name %s, want %s" , service .Spec .WorkloadTemplate .WorkerTemplate .Spec .SchedulerName , data .SchedulerName )
462462 }
463463
464+ if ! helper .SkipModelLoader (service ) {
465+ // Validate init container image.
466+ if service .Spec .WorkloadTemplate .LeaderTemplate != nil {
467+ for _ , initContainer := range workload .Spec .LeaderWorkerTemplate .LeaderTemplate .Spec .InitContainers {
468+ if initContainer .Image != data .InitContainerImage {
469+ return fmt .Errorf ("unexpected init container image %s in leader template, want %s" , initContainer .Image , data .InitContainerImage )
470+ }
471+ }
472+ }
473+
474+ for _ , initContainer := range workload .Spec .LeaderWorkerTemplate .WorkerTemplate .Spec .InitContainers {
475+ if initContainer .Image != data .InitContainerImage {
476+ return fmt .Errorf ("unexpected init container image %s in worker template, want %s" , initContainer .Image , data .InitContainerImage )
477+ }
478+ }
479+ }
480+
464481 return nil
465482}
0 commit comments