Skip to content

Commit

Permalink
changed new object
Browse files Browse the repository at this point in the history
Signed-off-by: GW Cloud Common Services <[email protected]>
  • Loading branch information
GW Cloud Common Services committed Jul 10, 2024
1 parent 7bbca7d commit d73a006
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions controllers/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ func (r *BackupReconciler) SetupWithManager(mgr ctrl.Manager) error {
// filter the changes in workflow status
// let workflow handle its reconcile
UpdateFunc: func(e ctrlEvent.UpdateEvent) bool {
new := e.ObjectNew.DeepCopyObject().(*v1alpha1.WorkflowRun)
old := e.ObjectOld.DeepCopyObject().(*v1alpha1.WorkflowRun)
newObj := e.ObjectNew.DeepCopyObject().(*v1alpha1.WorkflowRun)
oldObj := e.ObjectOld.DeepCopyObject().(*v1alpha1.WorkflowRun)
// if the workflow is not finished, skip the reconcile
if !new.Status.Finished {
if !newObj.Status.Finished {
return false
}

return !reflect.DeepEqual(old, new)
return !reflect.DeepEqual(oldObj, newObj)
},
CreateFunc: func(e ctrlEvent.CreateEvent) bool {
run := e.Object.DeepCopyObject().(*v1alpha1.WorkflowRun)
Expand Down
18 changes: 9 additions & 9 deletions controllers/workflowrun_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,35 +216,35 @@ func (r *WorkflowRunReconciler) SetupWithManager(mgr ctrl.Manager) error {
// filter the changes in workflow status
// let workflow handle its reconcile
UpdateFunc: func(e ctrlEvent.UpdateEvent) bool {
new, isNewWR := e.ObjectNew.DeepCopyObject().(*v1alpha1.WorkflowRun)
old, isOldWR := e.ObjectOld.DeepCopyObject().(*v1alpha1.WorkflowRun)
newObj, isNewWR := e.ObjectNew.DeepCopyObject().(*v1alpha1.WorkflowRun)
oldObj, isOldWR := e.ObjectOld.DeepCopyObject().(*v1alpha1.WorkflowRun)

// if the object is a event listener, reconcile the controller
if !isNewWR || !isOldWR {
return true
}

// if the workflow is finished, skip the reconcile
if new.Status.Finished {
if newObj.Status.Finished {
return false
}

// filter managedFields changes
old.ManagedFields = nil
new.ManagedFields = nil
oldObj.ManagedFields = nil
newObj.ManagedFields = nil

// filter resourceVersion changes
old.ResourceVersion = new.ResourceVersion
oldObj.ResourceVersion = newObj.ResourceVersion

// if the generation is changed, return true to let the controller handle it
if old.Generation != new.Generation {
if oldObj.Generation != newObj.Generation {
return true
}

// ignore the changes in step status
old.Status.Steps = new.Status.Steps
oldObj.Status.Steps = newObj.Status.Steps

return !reflect.DeepEqual(old, new)
return !reflect.DeepEqual(oldObj, newObj)
},
CreateFunc: func(e ctrlEvent.CreateEvent) bool { //nolint:revive,unused
return true
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/recycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (r *recycleCronJob) start(ctx context.Context) (*cron.Cron, error) {
Duration: 1 * time.Minute,
Factor: 5.0,
Jitter: 0.1,
}, func(err error) bool {
}, func(err error) bool { //nolint:revive,unused
// always retry
return true
}, func() error {
Expand Down

0 comments on commit d73a006

Please sign in to comment.