@@ -27,7 +27,6 @@ import (
2727 "golang.org/x/exp/maps"
2828 corev1 "k8s.io/api/core/v1"
2929 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30- "k8s.io/apimachinery/pkg/util/sets"
3130 "k8s.io/utils/ptr"
3231 "sigs.k8s.io/controller-runtime/pkg/client"
3332
@@ -102,10 +101,6 @@ func (t *componentWorkloadTransformer) reconcileWorkload(ctx context.Context, cl
102101
103102 t .buildInstanceSetPlacementAnnotation (comp , protoITS )
104103
105- if err := t .reconcileReplicasStatus (ctx , cli , synthesizedComp , runningITS , protoITS ); err != nil {
106- return err
107- }
108-
109104 return nil
110105}
111106
@@ -121,43 +116,6 @@ func (t *componentWorkloadTransformer) buildInstanceSetPlacementAnnotation(comp
121116 }
122117}
123118
124- func (t * componentWorkloadTransformer ) reconcileReplicasStatus (ctx context.Context , cli client.Reader ,
125- synthesizedComp * component.SynthesizedComponent , runningITS , protoITS * workloads.InstanceSet ) error {
126- var (
127- namespace = synthesizedComp .Namespace
128- clusterName = synthesizedComp .ClusterName
129- compName = synthesizedComp .Name
130- )
131-
132- // HACK: sync replicas status from runningITS to protoITS
133- component .BuildReplicasStatus (runningITS , protoITS )
134-
135- replicas , err := func () ([]string , error ) {
136- pods , err := component .ListOwnedPods (ctx , cli , namespace , clusterName , compName )
137- if err != nil {
138- return nil , err
139- }
140- podNameSet := sets .New [string ]()
141- for _ , pod := range pods {
142- podNameSet .Insert (pod .Name )
143- }
144-
145- desiredPodNames , err := component .GetDesiredPodNamesByITS (runningITS , protoITS )
146- if err != nil {
147- return nil , err
148- }
149- desiredPodNameSet := sets .New (desiredPodNames ... )
150-
151- return desiredPodNameSet .Intersection (podNameSet ).UnsortedList (), nil
152- }()
153- if err != nil {
154- return err
155- }
156-
157- hasMemberJoinDefined , hasDataActionDefined := hasMemberJoinNDataActionDefined (synthesizedComp .LifecycleActions .ComponentLifecycleActions )
158- return component .StatusReplicasStatus (protoITS , replicas , hasMemberJoinDefined , hasDataActionDefined )
159- }
160-
161119func (t * componentWorkloadTransformer ) handleUpdate (transCtx * componentTransformContext , cli model.GraphClient , dag * graph.DAG ,
162120 synthesizedComp * component.SynthesizedComponent , comp * appsv1.Component , runningITS , protoITS * workloads.InstanceSet ) error {
163121 start , stop := t .handleWorkloadStartNStop (transCtx , synthesizedComp , runningITS , & protoITS )
@@ -206,13 +164,13 @@ func isCompStopped(synthesizedComp *component.SynthesizedComponent) bool {
206164 return ptr .Deref (synthesizedComp .Stop , false )
207165}
208166
209- func (t * componentWorkloadTransformer ) handleWorkloadUpdate (transCtx * componentTransformContext , dag * graph.DAG ,
210- synthesizeComp * component.SynthesizedComponent , comp * appsv1.Component , obj , its * workloads.InstanceSet ) error {
211- cwo , err := newComponentWorkloadOps (transCtx , t . Client , synthesizeComp , comp , obj , its , dag )
167+ func (t * componentWorkloadTransformer ) handleWorkloadUpdate (_ * componentTransformContext , _ * graph.DAG ,
168+ synthesizeComp * component.SynthesizedComponent , _ * appsv1.Component , obj , its * workloads.InstanceSet ) error {
169+ cwo , err := newComponentWorkloadOps (synthesizeComp , obj , its )
212170 if err != nil {
213171 return err
214172 }
215- if err := cwo .horizontalScale (); err != nil {
173+ if err := cwo .validateHorizontalScale (); err != nil {
216174 return err
217175 }
218176 return nil
0 commit comments