@@ -84,7 +84,8 @@ func (aw *AppWrapper) PodSets() []kueue.PodSet {
8484 if len (aw .Status .ComponentStatus [idx ].PodSets ) > 0 {
8585 obj := & unstructured.Unstructured {}
8686 if _ , _ , err := unstructured .UnstructuredJSONScheme .Decode (aw .Spec .Components [idx ].Template .Raw , nil , obj ); err != nil {
87- continue // Should be unreachable; Template.Raw validated by our AdmissionController
87+ // Should be unreachable; Template.Raw validated by AppWrapper AdmissionController
88+ return []kueue.PodSet {} // Kueue will raise an error on zero length PodSet.
8889 }
8990 for psIdx , podSet := range aw .Status .ComponentStatus [idx ].PodSets {
9091 replicas := utils .Replicas (podSet )
@@ -103,6 +104,9 @@ func (aw *AppWrapper) PodSets() []kueue.PodSet {
103104
104105// RunWithPodSetsInfo records the assigned PodSetInfos for each component and sets aw.spec.Suspend to false
105106func (aw * AppWrapper ) RunWithPodSetsInfo (podSetsInfo []podset.PodSetInfo ) error {
107+ if err := utils .EnsureComponentStatusInitialized ((* workloadv1beta2 .AppWrapper )(aw )); err != nil {
108+ return err
109+ }
106110 podSetsInfoIndex := 0
107111 for idx := range aw .Spec .Components {
108112 if len (aw .Spec .Components [idx ].PodSetInfos ) != len (aw .Status .ComponentStatus [idx ].PodSets ) {
@@ -114,10 +118,10 @@ func (aw *AppWrapper) RunWithPodSetsInfo(podSetsInfo []podset.PodSetInfo) error
114118 continue // we will return an error below...continuing to get an accurate count for the error message
115119 }
116120 aw .Spec .Components [idx ].PodSetInfos [podSetIdx ] = workloadv1beta2.AppWrapperPodSetInfo {
117- Annotations : podSetsInfo [podSetIdx ].Annotations ,
118- Labels : podSetsInfo [podSetIdx ].Labels ,
119- NodeSelector : podSetsInfo [podSetIdx ].NodeSelector ,
120- Tolerations : podSetsInfo [podSetIdx ].Tolerations ,
121+ Annotations : podSetsInfo [podSetsInfoIndex - 1 ].Annotations ,
122+ Labels : podSetsInfo [podSetsInfoIndex - 1 ].Labels ,
123+ NodeSelector : podSetsInfo [podSetsInfoIndex - 1 ].NodeSelector ,
124+ Tolerations : podSetsInfo [podSetsInfoIndex - 1 ].Tolerations ,
121125 }
122126 }
123127 }
0 commit comments