Introduce a dedicated manager for status updates to avoid conflicts
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
parent
38541078fa
commit
f353ba44a7
|
|
@ -86,6 +86,7 @@ type KustomizationReconciler struct {
|
|||
MetricsRecorder *metrics.Recorder
|
||||
StatusPoller *polling.StatusPoller
|
||||
ControllerName string
|
||||
statusManager string
|
||||
NoCrossNamespaceRefs bool
|
||||
DefaultServiceAccount string
|
||||
}
|
||||
|
|
@ -116,6 +117,7 @@ func (r *KustomizationReconciler) SetupWithManager(mgr ctrl.Manager, opts Kustom
|
|||
}
|
||||
|
||||
r.requeueDependency = opts.DependencyRequeueInterval
|
||||
r.statusManager = fmt.Sprintf("gotk-%s", r.ControllerName)
|
||||
|
||||
// Configure the retryable http client used for fetching artifacts.
|
||||
// By default it retries 10 times within a 3.5 minutes window.
|
||||
|
|
@ -160,7 +162,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
|
|||
if !controllerutil.ContainsFinalizer(&kustomization, kustomizev1.KustomizationFinalizer) {
|
||||
patch := client.MergeFrom(kustomization.DeepCopy())
|
||||
controllerutil.AddFinalizer(&kustomization, kustomizev1.KustomizationFinalizer)
|
||||
if err := r.Patch(ctx, &kustomization, patch); err != nil {
|
||||
if err := r.Patch(ctx, &kustomization, patch, client.FieldOwner(r.statusManager)); err != nil {
|
||||
log.Error(err, "unable to register finalizer")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
|
@ -584,7 +586,6 @@ func (r *KustomizationReconciler) getSource(ctx context.Context, kustomization k
|
|||
if kustomization.Spec.SourceRef.Namespace != "" {
|
||||
sourceNamespace = kustomization.Spec.SourceRef.Namespace
|
||||
}
|
||||
|
||||
namespacedName := types.NamespacedName{
|
||||
Namespace: sourceNamespace,
|
||||
Name: kustomization.Spec.SourceRef.Name,
|
||||
|
|
@ -960,7 +961,7 @@ func (r *KustomizationReconciler) finalize(ctx context.Context, kustomization ku
|
|||
|
||||
// Remove our finalizer from the list and update it
|
||||
controllerutil.RemoveFinalizer(&kustomization, kustomizev1.KustomizationFinalizer)
|
||||
if err := r.Update(ctx, &kustomization, client.FieldOwner(r.ControllerName)); err != nil {
|
||||
if err := r.Update(ctx, &kustomization, client.FieldOwner(r.statusManager)); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
|
|
@ -1057,6 +1058,5 @@ func (r *KustomizationReconciler) patchStatus(ctx context.Context, req ctrl.Requ
|
|||
|
||||
patch := client.MergeFrom(kustomization.DeepCopy())
|
||||
kustomization.Status = newStatus
|
||||
|
||||
return r.Status().Patch(ctx, &kustomization, patch, client.FieldOwner(r.ControllerName))
|
||||
return r.Status().Patch(ctx, &kustomization, patch, client.FieldOwner(r.statusManager))
|
||||
}
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -14,7 +14,7 @@ require (
|
|||
github.com/fluxcd/pkg/apis/kustomize v0.3.1
|
||||
github.com/fluxcd/pkg/apis/meta v0.10.2
|
||||
github.com/fluxcd/pkg/runtime v0.12.4
|
||||
github.com/fluxcd/pkg/ssa v0.11.1
|
||||
github.com/fluxcd/pkg/ssa v0.12.0
|
||||
github.com/fluxcd/pkg/testserver v0.2.0
|
||||
github.com/fluxcd/pkg/untar v0.1.0
|
||||
github.com/fluxcd/source-controller/api v0.20.1
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -257,6 +257,8 @@ github.com/fluxcd/pkg/runtime v0.12.4 h1:gA27RG/+adN2/7Qe03PB46Iwmye/MusPCpuS4zQ
|
|||
github.com/fluxcd/pkg/runtime v0.12.4/go.mod h1:gspNvhAqodZgSmK1ZhMtvARBf/NGAlxmaZaIOHkJYsc=
|
||||
github.com/fluxcd/pkg/ssa v0.11.1 h1:iZMMe6Pdgt/sv3pZPJ5y4oRDa+8IXHbpPYgpjEmaq/8=
|
||||
github.com/fluxcd/pkg/ssa v0.11.1/go.mod h1:S+qig7BTOxop0c134y8Yv8/iQST4Kt7S2xXiFkP4VMA=
|
||||
github.com/fluxcd/pkg/ssa v0.12.0 h1:7nF4UigU9Zk/9P/nbzUP3ah8IRC+BpB64O9iu5VnvEo=
|
||||
github.com/fluxcd/pkg/ssa v0.12.0/go.mod h1:S+qig7BTOxop0c134y8Yv8/iQST4Kt7S2xXiFkP4VMA=
|
||||
github.com/fluxcd/pkg/testserver v0.2.0 h1:Mj0TapmKaywI6Fi5wvt1LAZpakUHmtzWQpJNKQ0Krt4=
|
||||
github.com/fluxcd/pkg/testserver v0.2.0/go.mod h1:bgjjydkXsZTeFzjz9Cr4heGANr41uTB1Aj1Q5qzuYVk=
|
||||
github.com/fluxcd/pkg/untar v0.1.0 h1:k97V/xV5hFrAkIkVPuv5AVhyxh1ZzzAKba/lbDfGo6o=
|
||||
|
|
|
|||
Loading…
Reference in New Issue