@@ -21,25 +21,32 @@ var inferenceObjectiveGVR = schema.GroupVersionResource{
2121 Resource : "inferenceobjectives" ,
2222}
2323
24- // EnsureInferenceObjective creates the e2e-default InferenceObjective for GIE flow-control
24+ const defaultInferenceObjectiveName = "e2e-default"
25+
26+ // EnsureInferenceObjective creates the default InferenceObjective for GIE flow-control
2527// queuing when the CRD exists. poolName must match the InferencePool metadata.name (typically the
2628// EPP Service name with an "-epp" suffix removed, e.g. gaie-sim-epp → gaie-sim).
2729//
2830// Returns applied=true if the object exists or was created. If the InferenceObjective API is not
2931// available on the cluster, returns (false, nil).
3032func EnsureInferenceObjective (ctx context.Context , dc dynamic.Interface , namespace , poolName string ) (applied bool , err error ) {
33+ return EnsureInferenceObjectiveNamed (ctx , dc , namespace , defaultInferenceObjectiveName , poolName )
34+ }
35+
36+ // EnsureInferenceObjectiveNamed creates or updates a named InferenceObjective when the CRD exists.
37+ func EnsureInferenceObjectiveNamed (ctx context.Context , dc dynamic.Interface , namespace , objectiveName , poolName string ) (applied bool , err error ) {
3138 ri := dc .Resource (inferenceObjectiveGVR ).Namespace (namespace )
3239 poolGroup , gErr := resolveInferencePoolGroup (ctx , dc , namespace , poolName )
3340 if gErr != nil {
3441 return false , gErr
3542 }
36- obj := buildInferenceObjective (namespace , poolName , poolGroup )
43+ obj := buildInferenceObjective (namespace , objectiveName , poolName , poolGroup )
3744
3845 if _ , cErr := ri .Create (ctx , obj , metav1.CreateOptions {}); cErr != nil {
3946 if apierrors .IsAlreadyExists (cErr ) {
40- current , getErr := ri .Get (ctx , "e2e-default" , metav1.GetOptions {})
47+ current , getErr := ri .Get (ctx , objectiveName , metav1.GetOptions {})
4148 if getErr != nil {
42- return false , fmt .Errorf ("get existing InferenceObjective e2e-default : %w" , getErr )
49+ return false , fmt .Errorf ("get existing InferenceObjective %s : %w" , objectiveName , getErr )
4350 }
4451
4552 currentSpec , _ , specErr := unstructured .NestedMap (current .Object , "spec" )
@@ -58,34 +65,39 @@ func EnsureInferenceObjective(ctx context.Context, dc dynamic.Interface, namespa
5865 return false , fmt .Errorf ("set desired InferenceObjective spec: %w" , setErr )
5966 }
6067 if _ , uErr := ri .Update (ctx , current , metav1.UpdateOptions {}); uErr != nil {
61- return false , fmt .Errorf ("update InferenceObjective e2e-default : %w" , uErr )
68+ return false , fmt .Errorf ("update InferenceObjective %s : %w" , objectiveName , uErr )
6269 }
6370 return true , nil
6471 }
6572 if inferenceObjectiveAPIMissing (cErr ) {
6673 return false , nil
6774 }
68- return false , fmt .Errorf ("create InferenceObjective e2e-default : %w" , cErr )
75+ return false , fmt .Errorf ("create InferenceObjective %s : %w" , objectiveName , cErr )
6976 }
7077 return true , nil
7178}
7279
73- // DeleteInferenceObjective removes e2e- default InferenceObjective if present.
80+ // DeleteInferenceObjective removes the default InferenceObjective if present.
7481func DeleteInferenceObjective (ctx context.Context , dc dynamic.Interface , namespace string ) error {
75- err := dc .Resource (inferenceObjectiveGVR ).Namespace (namespace ).Delete (ctx , "e2e-default" , metav1.DeleteOptions {})
82+ return DeleteInferenceObjectiveNamed (ctx , dc , namespace , defaultInferenceObjectiveName )
83+ }
84+
85+ // DeleteInferenceObjectiveNamed removes a named InferenceObjective if present.
86+ func DeleteInferenceObjectiveNamed (ctx context.Context , dc dynamic.Interface , namespace , objectiveName string ) error {
87+ err := dc .Resource (inferenceObjectiveGVR ).Namespace (namespace ).Delete (ctx , objectiveName , metav1.DeleteOptions {})
7688 if apierrors .IsNotFound (err ) || inferenceObjectiveAPIMissing (err ) {
7789 return nil
7890 }
7991 return err
8092}
8193
82- func buildInferenceObjective (namespace , poolName , poolGroup string ) * unstructured.Unstructured {
94+ func buildInferenceObjective (namespace , objectiveName , poolName , poolGroup string ) * unstructured.Unstructured {
8395 return & unstructured.Unstructured {
8496 Object : map [string ]interface {}{
8597 "apiVersion" : "inference.networking.x-k8s.io/v1alpha2" ,
8698 "kind" : "InferenceObjective" ,
8799 "metadata" : map [string ]interface {}{
88- "name" : "e2e-default" ,
100+ "name" : objectiveName ,
89101 "namespace" : namespace ,
90102 },
91103 "spec" : map [string ]interface {}{
@@ -145,6 +157,5 @@ func resolveInferencePoolGroup(ctx context.Context, dc dynamic.Interface, namesp
145157 return "" , fmt .Errorf ("detect InferencePool API group for %q: %w" , poolName , err )
146158 }
147159
148- // Default to the primary group used by llm-d charts.
149- return "inference.networking.k8s.io" , nil
160+ return "" , fmt .Errorf ("detect InferencePool API group for %q: no supported InferencePool resource found" , poolName )
150161}
0 commit comments