Skip to content

Commit

Permalink
replace reflect with generation (#885)
Browse files Browse the repository at this point in the history
Signed-off-by: zounengren <zouyee1989@gmail.com>
  • Loading branch information
zouyee authored Jan 19, 2022
1 parent 007ef53 commit 2a7eb6d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/controller/sidecarset/sidecarset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package sidecarset
import (
"context"
"flag"
"reflect"

appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1"
"github.com/openkruise/kruise/pkg/control/sidecarcontrol"
Expand Down Expand Up @@ -90,10 +89,10 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
// Watch for changes to SidecarSet
err = c.Watch(&source.Kind{Type: &appsv1alpha1.SidecarSet{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
old := e.ObjectOld.(*appsv1alpha1.SidecarSet)
new := e.ObjectNew.(*appsv1alpha1.SidecarSet)
if !reflect.DeepEqual(old.Spec, new.Spec) {
klog.V(3).Infof("Observed updated Spec for SidecarSet: %s/%s", new.Namespace, new.Name)
oldScS := e.ObjectOld.(*appsv1alpha1.SidecarSet)
newScS := e.ObjectNew.(*appsv1alpha1.SidecarSet)
if oldScS.GetGeneration() != newScS.GetGeneration() {
klog.V(3).Infof("Observed updated Spec for SidecarSet: %s/%s", newScS.GetNamespace(), newScS.GetName())
return true
}
return false
Expand Down

0 comments on commit 2a7eb6d

Please sign in to comment.