Skip to content

Commit 24ae6c1

Browse files
xulinfei1996xulinfeirenormalize
authored
skip patch ObservedGeneration if no change (#337)
* skip patch ObservedGeneration if no change Signed-off-by: xulinfei <xulinfei@bytedance.com> * Adapt changes made in PCS and PCLQ controllers to PCSG controller. Signed-off-by: Saketh Kalaga <saketh.kalaga@sap.com> --------- Signed-off-by: xulinfei <xulinfei@bytedance.com> Signed-off-by: Saketh Kalaga <saketh.kalaga@sap.com> Co-authored-by: xulinfei <xulinfei@bytedance.com> Co-authored-by: Saketh Kalaga <saketh.kalaga@sap.com>
1 parent 095d529 commit 24ae6c1

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

operator/internal/controller/podclique/reconcilespec.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ func (r *Reconciler) syncPCLQResources(ctx context.Context, logger logr.Logger,
188188

189189
// updateObservedGeneration updates the PodClique status to reflect the current generation being processed
190190
func (r *Reconciler) updateObservedGeneration(ctx context.Context, logger logr.Logger, pclq *grovecorev1alpha1.PodClique) ctrlcommon.ReconcileStepResult {
191+
if pclq.Status.ObservedGeneration != nil && *pclq.Status.ObservedGeneration == pclq.Generation {
192+
return ctrlcommon.ContinueReconcile()
193+
}
194+
191195
original := pclq.DeepCopy()
192196
pclq.Status.ObservedGeneration = &pclq.Generation
193197
if err := r.client.Status().Patch(ctx, pclq, client.MergeFrom(original)); err != nil {

operator/internal/controller/podcliquescalinggroup/reconcilespec.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ func (r *Reconciler) recordIncompleteReconcile(ctx context.Context, logger logr.
158158

159159
// updateObservedGeneration updates the PodCliqueScalingGroup status to reflect the current generation being processed
160160
func (r *Reconciler) updateObservedGeneration(ctx context.Context, logger logr.Logger, pcsg *grovecorev1alpha1.PodCliqueScalingGroup) ctrlcommon.ReconcileStepResult {
161+
if pcsg.Status.ObservedGeneration != nil && *pcsg.Status.ObservedGeneration == pcsg.Generation {
162+
return ctrlcommon.ContinueReconcile()
163+
}
164+
161165
original := pcsg.DeepCopy()
162166
pcsg.Status.ObservedGeneration = &pcsg.Generation
163167
if err := r.client.Status().Patch(ctx, pcsg, client.MergeFrom(original)); err != nil {

operator/internal/controller/podcliqueset/reconcilespec.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ func (r *Reconciler) syncPodCliqueSetResources(ctx context.Context, logger logr.
176176

177177
// updateObservedGeneration updates the status to reflect the current observed generation.
178178
func (r *Reconciler) updateObservedGeneration(ctx context.Context, logger logr.Logger, pcs *grovecorev1alpha1.PodCliqueSet) ctrlcommon.ReconcileStepResult {
179+
if pcs.Status.ObservedGeneration != nil && *pcs.Status.ObservedGeneration == pcs.Generation {
180+
return ctrlcommon.ContinueReconcile()
181+
}
182+
179183
original := pcs.DeepCopy()
180184
pcs.Status.ObservedGeneration = &pcs.Generation
181185
if err := r.client.Status().Patch(ctx, pcs, client.MergeFrom(original)); err != nil {

0 commit comments

Comments
 (0)