Check suspend status before progressing

When a release is marked as suspended no operations should be performed
for the release except acknowledging the reconciler has noticed it has
been suspended. This means the suspend check should happen _before_ the
Kustomization is marked as progressing (which should be an indicator
reconciliation is enabled for the Kustomization).
This commit is contained in:
Hidde Beydals 2020-06-29 14:08:15 +02:00
parent 7e080f14a9
commit 3f6edc5280
1 changed files with 7 additions and 7 deletions

View File

@ -66,14 +66,8 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
log := r.Log.WithValues(strings.ToLower(kustomization.Kind), req.NamespacedName)
kustomization = kustomizev1.KustomizationProgressing(kustomization)
if err := r.Status().Update(ctx, &kustomization); err != nil {
log.Error(err, "unable to update Kustomization status")
return ctrl.Result{Requeue: true}, err
}
if kustomization.Spec.Suspend {
msg := "Kustomization is suspended, skipping execution"
msg := "Kustomization is suspended, skipping reconciliation"
kustomization = kustomizev1.KustomizationNotReady(kustomization, kustomizev1.SuspendedReason, msg)
if err := r.Status().Update(ctx, &kustomization); err != nil {
log.Error(err, "unable to update Kustomization status")
@ -83,6 +77,12 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
return ctrl.Result{}, nil
}
kustomization = kustomizev1.KustomizationProgressing(kustomization)
if err := r.Status().Update(ctx, &kustomization); err != nil {
log.Error(err, "unable to update Kustomization status")
return ctrl.Result{Requeue: true}, err
}
var source sourcev1.Source
// get artifact source from Git repository