File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
operator/pkg/controller/karmada Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -183,5 +183,17 @@ func (ctrl *Controller) onKarmadaUpdate(updateEvent event.UpdateEvent) bool {
183183 return true
184184 }
185185
186- return ! reflect .DeepEqual (newObj .Spec , oldObj .Spec )
186+ // For updates that don't touch the spec (e.g. status updates), we can short-circuit.
187+ if reflect .DeepEqual (newObj .Spec , newObj .Spec ) {
188+ return false
189+ }
190+
191+ // The spec has changed. We need to check if it's a semantic change or just defaulting.
192+ // TODO(@zhzhuang-zju): If default values are set via an admission controller, the default() call below can be omitted.
193+ newCopy := newObj .DeepCopy ()
194+ oldCopy := oldObj .DeepCopy ()
195+
196+ operatorscheme .Scheme .Default (newCopy )
197+ operatorscheme .Scheme .Default (oldCopy )
198+ return ! reflect .DeepEqual (newCopy .Spec , oldCopy .Spec )
187199}
You can’t perform that action at this time.
0 commit comments