diff --git a/pkg/webhook/playground_webhook.go b/pkg/webhook/playground_webhook.go index 96272950..9e32a703 100644 --- a/pkg/webhook/playground_webhook.go +++ b/pkg/webhook/playground_webhook.go @@ -103,6 +103,9 @@ func (w *PlaygroundWebhook) generateValidate(obj runtime.Object) field.ErrorList if playground.Spec.ModelClaim == nil && playground.Spec.ModelClaims == nil { allErrs = append(allErrs, field.Forbidden(specPath, "modelClaim and modelClaims couldn't be both nil")) } + if playground.Spec.ModelClaim != nil && playground.Spec.ModelClaims != nil { + allErrs = append(allErrs, field.Forbidden(specPath, "modelClaim and modelClaims couldn't be both not nil")) + } if playground.Spec.ModelClaims != nil { mainModelCount := 0 diff --git a/test/integration/webhook/playground_test.go b/test/integration/webhook/playground_test.go index f2f8708d..946bdd16 100644 --- a/test/integration/webhook/playground_test.go +++ b/test/integration/webhook/playground_test.go @@ -87,6 +87,13 @@ var _ = ginkgo.Describe("Playground default and validation", func() { }, failed: true, }), + ginkgo.Entry("both model claim and claims be set", &testValidatingCase{ + playground: func() *inferenceapi.Playground { + return wrapper.MakePlayground("playground", ns.Name).Replicas(1).ModelClaim("llama3-8b"). + ModelClaims([]string{"llama3-405b", "llama3-2b"}, []string{"main", "draft", "draft"}).Obj() + }, + failed: true, + }), ginkgo.Entry("any kind of backendRuntime should be supported", &testValidatingCase{ playground: func() *inferenceapi.Playground { return wrapper.MakePlayground("playground", ns.Name).Replicas(1).ModelClaim("llama3-8b").BackendRuntime(string("unknown")).Obj() @@ -141,7 +148,7 @@ var _ = ginkgo.Describe("Playground default and validation", func() { playground func() *inferenceapi.Playground wantPlayground func() *inferenceapi.Playground } - ginkgo.DescribeTable("test validating", + ginkgo.DescribeTable("test Defaulting", func(tc *testDefaultingCase) { playground := tc.playground() gomega.Expect(k8sClient.Create(ctx, playground)).To(gomega.Succeed())