@@ -38,9 +38,6 @@ import (
3838 "k8s.io/utils/ptr"
3939 jobsetapi "sigs.k8s.io/jobset/api/jobset/v1alpha2"
4040
41- kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
42- "sigs.k8s.io/kueue/pkg/podset"
43-
4441 awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"
4542)
4643
@@ -349,36 +346,32 @@ func EnsureComponentStatusInitialized(aw *awv1beta2.AppWrapper) error {
349346 return nil
350347}
351348
352- // GetPodSets constructs the kueue.PodSets for an AppWrapper
353- func GetPodSets ( aw * awv1beta2. AppWrapper ) ([]kueue. PodSet , error ) {
354- podSets := []kueue. PodSet {}
349+ func GetComponentPodSpecs ( aw * awv1beta2. AppWrapper ) ([] * v1. PodTemplateSpec , []awv1beta2. AppWrapperPodSet , error ) {
350+ templates := [] * v1. PodTemplateSpec {}
351+ podSets := []awv1beta2. AppWrapperPodSet {}
355352 if err := EnsureComponentStatusInitialized (aw ); err != nil {
356- return nil , err
353+ return nil , nil , err
357354 }
358355 for idx := range aw .Status .ComponentStatus {
359356 if len (aw .Status .ComponentStatus [idx ].PodSets ) > 0 {
360357 obj := & unstructured.Unstructured {}
361358 if _ , _ , err := unstructured .UnstructuredJSONScheme .Decode (aw .Spec .Components [idx ].Template .Raw , nil , obj ); err != nil {
362359 // Should be unreachable; Template.Raw validated by AppWrapper AdmissionController
363- return nil , err
360+ return nil , nil , err
364361 }
365- for psIdx , podSet := range aw .Status .ComponentStatus [idx ].PodSets {
366- replicas := Replicas (podSet )
362+ for _ , podSet := range aw .Status .ComponentStatus [idx ].PodSets {
367363 if template , err := GetPodTemplateSpec (obj , podSet .Path ); err == nil {
368- podSets = append (podSets , kueue.PodSet {
369- Name : fmt .Sprintf ("%s-%v-%v" , aw .Name , idx , psIdx ),
370- Template : * template ,
371- Count : replicas ,
372- })
364+ templates = append (templates , template )
365+ podSets = append (podSets , podSet )
373366 }
374367 }
375368 }
376369 }
377- return podSets , nil
370+ return templates , podSets , nil
378371}
379372
380373// SetPodSetInfos propagates podSetsInfo into the PodSetInfos of aw.Spec.Components
381- func SetPodSetInfos (aw * awv1beta2.AppWrapper , podSetsInfo []podset. PodSetInfo ) error {
374+ func SetPodSetInfos (aw * awv1beta2.AppWrapper , podSetsInfo []awv1beta2. AppWrapperPodSetInfo ) error {
382375 if err := EnsureComponentStatusInitialized (aw ); err != nil {
383376 return err
384377 }
@@ -392,18 +385,12 @@ func SetPodSetInfos(aw *awv1beta2.AppWrapper, podSetsInfo []podset.PodSetInfo) e
392385 if podSetsInfoIndex > len (podSetsInfo ) {
393386 continue // we will return an error below...continuing to get an accurate count for the error message
394387 }
395- aw .Spec .Components [idx ].PodSetInfos [podSetIdx ] = awv1beta2.AppWrapperPodSetInfo {
396- Annotations : podSetsInfo [podSetsInfoIndex - 1 ].Annotations ,
397- Labels : podSetsInfo [podSetsInfoIndex - 1 ].Labels ,
398- NodeSelector : podSetsInfo [podSetsInfoIndex - 1 ].NodeSelector ,
399- Tolerations : podSetsInfo [podSetsInfoIndex - 1 ].Tolerations ,
400- SchedulingGates : podSetsInfo [podSetsInfoIndex - 1 ].SchedulingGates ,
401- }
388+ aw .Spec .Components [idx ].PodSetInfos [podSetIdx ] = podSetsInfo [podSetIdx ]
402389 }
403390 }
404391
405392 if podSetsInfoIndex != len (podSetsInfo ) {
406- return podset . BadPodSetsInfoLenError ( podSetsInfoIndex , len (podSetsInfo ))
393+ return fmt . Errorf ( "expecting %d podsets, got %d" , podSetsInfoIndex , len (podSetsInfo ))
407394 }
408395 return nil
409396}
0 commit comments