Skip to content

Commit 6618e6c

Browse files
committed
operator: avoid invalid reconcile
Signed-off-by: zhzhuang-zju <[email protected]>
1 parent d8473e1 commit 6618e6c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

operator/pkg/controller/karmada/controller.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,15 @@ func skipIfSuspended() predicate.Predicate {
176176
// 1. when the karmada cr is deleted.
177177
// 2. when the spec of karmada cr is updated.
178178
func (ctrl *Controller) onKarmadaUpdate(updateEvent event.UpdateEvent) bool {
179-
newObj := updateEvent.ObjectNew.(*operatorv1alpha1.Karmada)
180-
oldObj := updateEvent.ObjectOld.(*operatorv1alpha1.Karmada)
179+
newObj := updateEvent.ObjectNew.(*operatorv1alpha1.Karmada).DeepCopy()
180+
oldObj := updateEvent.ObjectOld.(*operatorv1alpha1.Karmada).DeepCopy()
181181

182182
if !newObj.DeletionTimestamp.IsZero() {
183183
return true
184184
}
185185

186+
// TODO(@zhzhuang-zju): If default values are set via an admission controller, the default() call below can be omitted.
187+
operatorscheme.Scheme.Default(newObj)
188+
operatorscheme.Scheme.Default(oldObj)
186189
return !reflect.DeepEqual(newObj.Spec, oldObj.Spec)
187190
}

0 commit comments

Comments
 (0)