Skip to content

Commit

Permalink
Merge pull request #164 from fluxcd/status-update
Browse files Browse the repository at this point in the history
Use latest generation when updating final status
  • Loading branch information
stefanprodan authored Nov 4, 2020
2 parents 0f635d2 + 8ec066b commit 68df710
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
}

// update status
if err := r.Status().Update(ctx, &reconciledKustomization); err != nil {
if err := r.updateStatus(ctx, req, reconciledKustomization.Status); err != nil {
log.Error(err, "unable to update status after reconciliation")
return ctrl.Result{Requeue: true}, err
}
Expand Down Expand Up @@ -1033,6 +1033,16 @@ func (r *KustomizationReconciler) newKustomizationClient(kustomization kustomize
return client, statusPoller, err
}

func (r *KustomizationReconciler) updateStatus(ctx context.Context, req ctrl.Request, newStatus kustomizev1.KustomizationStatus) error {
var kustomization kustomizev1.Kustomization
if err := r.Get(ctx, req.NamespacedName, &kustomization); err != nil {
return err
}

kustomization.Status = newStatus
return r.Status().Update(ctx, &kustomization)
}

func containsString(slice []string, s string) bool {
for _, item := range slice {
if item == s {
Expand Down

0 comments on commit 68df710

Please sign in to comment.