From 085591183e125f541534d6d372ca4150fa0575e5 Mon Sep 17 00:00:00 2001 From: Luke Addison Date: Mon, 8 Jan 2024 18:08:14 +0000 Subject: [PATCH 1/3] Use semantic DeepEqual in foghorn controller --- pkg/foghorn/controller.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/foghorn/controller.go b/pkg/foghorn/controller.go index 7cdf819ca..9c90f1f24 100644 --- a/pkg/foghorn/controller.go +++ b/pkg/foghorn/controller.go @@ -3,7 +3,6 @@ package foghorn import ( "context" "fmt" - "reflect" "strings" "sync" "time" @@ -18,6 +17,7 @@ import ( "github.com/jenkins-x/lighthouse/pkg/watcher" "github.com/pkg/errors" "github.com/sirupsen/logrus" + "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" @@ -121,7 +121,7 @@ func (r *LighthouseJobReconciler) Reconcile(ctx context.Context, req ctrl.Reques r.updateJobStatusForActivity(activityRecord, jobCopy) r.reportStatus(activityRecord, jobCopy) - if !reflect.DeepEqual(job.Status, jobCopy.Status) { + if !equality.Semantic.DeepEqual(job.Status, jobCopy.Status) { f := func(job *lighthousev1alpha1.LighthouseJob) error { job.Status = jobCopy.Status if err := r.client.Status().Update(ctx, job); err != nil { From 2f8775e32015933dbf19220b34ca41cb3eee5cd8 Mon Sep 17 00:00:00 2001 From: Luke Addison Date: Mon, 8 Jan 2024 18:26:50 +0000 Subject: [PATCH 2/3] Pass Job object to retryModifyJob --- pkg/foghorn/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/foghorn/controller.go b/pkg/foghorn/controller.go index 9c90f1f24..d4a827abe 100644 --- a/pkg/foghorn/controller.go +++ b/pkg/foghorn/controller.go @@ -130,7 +130,7 @@ func (r *LighthouseJobReconciler) Reconcile(ctx context.Context, req ctrl.Reques } return nil } - if err := r.retryModifyJob(ctx, req.NamespacedName, jobCopy, f); err != nil { + if err := r.retryModifyJob(ctx, req.NamespacedName, &job, f); err != nil { r.logger.Errorf("Failed to update LighthouseJob status: %s", err) return ctrl.Result{}, err } From c654951ca93fc81e0850e4d0cced8631f824a244 Mon Sep 17 00:00:00 2001 From: Luke Addison Date: Mon, 8 Jan 2024 18:34:29 +0000 Subject: [PATCH 3/3] Reverse equality.Semantic.DeepEqual --- pkg/foghorn/controller.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/foghorn/controller.go b/pkg/foghorn/controller.go index d4a827abe..06434165c 100644 --- a/pkg/foghorn/controller.go +++ b/pkg/foghorn/controller.go @@ -3,6 +3,7 @@ package foghorn import ( "context" "fmt" + "reflect" "strings" "sync" "time" @@ -17,7 +18,6 @@ import ( "github.com/jenkins-x/lighthouse/pkg/watcher" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" @@ -121,7 +121,7 @@ func (r *LighthouseJobReconciler) Reconcile(ctx context.Context, req ctrl.Reques r.updateJobStatusForActivity(activityRecord, jobCopy) r.reportStatus(activityRecord, jobCopy) - if !equality.Semantic.DeepEqual(job.Status, jobCopy.Status) { + if !reflect.DeepEqual(job.Status, jobCopy.Status) { f := func(job *lighthousev1alpha1.LighthouseJob) error { job.Status = jobCopy.Status if err := r.client.Status().Update(ctx, job); err != nil {