@@ -38,9 +38,6 @@ import (
38
38
"k8s.io/utils/ptr"
39
39
jobsetapi "sigs.k8s.io/jobset/api/jobset/v1alpha2"
40
40
41
- kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
42
- "sigs.k8s.io/kueue/pkg/podset"
43
-
44
41
awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"
45
42
)
46
43
@@ -349,36 +346,32 @@ func EnsureComponentStatusInitialized(aw *awv1beta2.AppWrapper) error {
349
346
return nil
350
347
}
351
348
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 {}
355
352
if err := EnsureComponentStatusInitialized (aw ); err != nil {
356
- return nil , err
353
+ return nil , nil , err
357
354
}
358
355
for idx := range aw .Status .ComponentStatus {
359
356
if len (aw .Status .ComponentStatus [idx ].PodSets ) > 0 {
360
357
obj := & unstructured.Unstructured {}
361
358
if _ , _ , err := unstructured .UnstructuredJSONScheme .Decode (aw .Spec .Components [idx ].Template .Raw , nil , obj ); err != nil {
362
359
// Should be unreachable; Template.Raw validated by AppWrapper AdmissionController
363
- return nil , err
360
+ return nil , nil , err
364
361
}
365
- for psIdx , podSet := range aw .Status .ComponentStatus [idx ].PodSets {
366
- replicas := Replicas (podSet )
362
+ for _ , podSet := range aw .Status .ComponentStatus [idx ].PodSets {
367
363
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 )
373
366
}
374
367
}
375
368
}
376
369
}
377
- return podSets , nil
370
+ return templates , podSets , nil
378
371
}
379
372
380
373
// 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 {
382
375
if err := EnsureComponentStatusInitialized (aw ); err != nil {
383
376
return err
384
377
}
@@ -392,18 +385,12 @@ func SetPodSetInfos(aw *awv1beta2.AppWrapper, podSetsInfo []podset.PodSetInfo) e
392
385
if podSetsInfoIndex > len (podSetsInfo ) {
393
386
continue // we will return an error below...continuing to get an accurate count for the error message
394
387
}
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 ]
402
389
}
403
390
}
404
391
405
392
if podSetsInfoIndex != len (podSetsInfo ) {
406
- return podset . BadPodSetsInfoLenError ( podSetsInfoIndex , len (podSetsInfo ))
393
+ return fmt . Errorf ( "expecting %d podsets, got %d" , podSetsInfoIndex , len (podSetsInfo ))
407
394
}
408
395
return nil
409
396
}
0 commit comments