From 596b07169a0ac05671cf40bea1f49be1dd5baed7 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Tue, 31 Oct 2023 18:06:24 +0100 Subject: [PATCH] reconcile: allow cfg of manager in atomic action Signed-off-by: Hidde Beydals --- internal/controller/helmrelease_controller.go | 2 +- internal/reconcile/atomic_release.go | 8 +++++--- internal/reconcile/atomic_release_test.go | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/controller/helmrelease_controller.go b/internal/controller/helmrelease_controller.go index 71beefa1d..ee2830979 100644 --- a/internal/controller/helmrelease_controller.go +++ b/internal/controller/helmrelease_controller.go @@ -328,7 +328,7 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, patchHelpe } // Off we go! - if err = intreconcile.NewAtomicRelease(patchHelper, cfg, r.EventRecorder).Reconcile(ctx, &intreconcile.Request{ + if err = intreconcile.NewAtomicRelease(patchHelper, cfg, r.EventRecorder, r.FieldManager).Reconcile(ctx, &intreconcile.Request{ Object: obj, Chart: loadedChart, Values: values, diff --git a/internal/reconcile/atomic_release.go b/internal/reconcile/atomic_release.go index bbfa8c329..7db37b631 100644 --- a/internal/reconcile/atomic_release.go +++ b/internal/reconcile/atomic_release.go @@ -80,16 +80,18 @@ type AtomicRelease struct { configFactory *action.ConfigFactory eventRecorder record.EventRecorder strategy releaseStrategy + fieldManager string } // NewAtomicRelease returns a new AtomicRelease reconciler configured with the // provided values. -func NewAtomicRelease(patchHelper *patch.SerialPatcher, cfg *action.ConfigFactory, recorder record.EventRecorder) *AtomicRelease { +func NewAtomicRelease(patchHelper *patch.SerialPatcher, cfg *action.ConfigFactory, recorder record.EventRecorder, fieldManager string) *AtomicRelease { return &AtomicRelease{ patchHelper: patchHelper, eventRecorder: recorder, configFactory: cfg, strategy: &cleanReleaseStrategy{}, + fieldManager: fieldManager, } } @@ -188,7 +190,7 @@ func (r *AtomicRelease) Reconcile(ctx context.Context, req *Request) error { conditions.MarkTrue(req.Object, meta.ReconcilingCondition, "Progressing", "Running '%s' %s action with timeout of %s", next.Name(), next.Type(), timeoutForAction(next, req.Object).String()) // Patch the object to reflect the new condition. - if err = r.patchHelper.Patch(ctx, req.Object, patch.WithOwnedConditions{Conditions: OwnedConditions}, patch.WithFieldOwner("helm-controller")); err != nil { + if err = r.patchHelper.Patch(ctx, req.Object, patch.WithOwnedConditions{Conditions: OwnedConditions}, patch.WithFieldOwner(r.fieldManager)); err != nil { return err } @@ -214,7 +216,7 @@ func (r *AtomicRelease) Reconcile(ctx context.Context, req *Request) error { previous = append(previous, next.Type()) // Patch the release to reflect progress. - if err = r.patchHelper.Patch(ctx, req.Object, patch.WithOwnedConditions{Conditions: OwnedConditions}, patch.WithFieldOwner("helm-controller")); err != nil { + if err = r.patchHelper.Patch(ctx, req.Object, patch.WithOwnedConditions{Conditions: OwnedConditions}, patch.WithFieldOwner(r.fieldManager)); err != nil { return err } } diff --git a/internal/reconcile/atomic_release_test.go b/internal/reconcile/atomic_release_test.go index a69b8bd9f..f46b6bd4f 100644 --- a/internal/reconcile/atomic_release_test.go +++ b/internal/reconcile/atomic_release_test.go @@ -163,7 +163,7 @@ func TestAtomicRelease_Reconcile(t *testing.T) { Chart: testutil.BuildChart(testutil.ChartWithTestHook()), Values: nil, } - g.Expect(NewAtomicRelease(patchHelper, cfg, recorder).Reconcile(context.TODO(), req)).ToNot(HaveOccurred()) + g.Expect(NewAtomicRelease(patchHelper, cfg, recorder, "helm-controller").Reconcile(context.TODO(), req)).ToNot(HaveOccurred()) g.Expect(obj.Status.Conditions).To(conditions.MatchConditions([]metav1.Condition{ {