Skip to content

Commit

Permalink
Merge pull request #21 from fluxcd/progressing-status
Browse files Browse the repository at this point in the history
Report progressing status
  • Loading branch information
stefanprodan authored Apr 27, 2020
2 parents 9007286 + 86f6e84 commit a64fc01
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ const (
// InitializedReason represents the fact that a given resource has been initialized.
InitializedReason string = "Initialized"

// ProgressingReason represents the fact that a kustomization reconciliation
// is underway.
ProgressingReason string = "Progressing"

// SuspendedReason represents the fact that the kustomization execution is suspended.
SuspendedReason string = "Suspended"

Expand Down
13 changes: 13 additions & 0 deletions api/v1alpha1/kustomization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ func KustomizationReady(kustomization Kustomization, revision, reason, message s
return kustomization
}

func KustomizationProgressing(kustomization Kustomization) Kustomization {
kustomization.Status.Conditions = []Condition{
{
Type: ReadyCondition,
Status: corev1.ConditionUnknown,
LastTransitionTime: metav1.Now(),
Reason: ProgressingReason,
Message: "reconciliation in progress",
},
}
return kustomization
}

func KustomizationNotReady(kustomization Kustomization, reason, message string) Kustomization {
kustomization.Status.Conditions = []Condition{
{
Expand Down
8 changes: 7 additions & 1 deletion controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ 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"
kustomization = kustomizev1.KustomizationNotReady(kustomization, kustomizev1.SuspendedReason, msg)
Expand Down Expand Up @@ -345,7 +351,7 @@ transformers:
var data bytes.Buffer
writer := bufio.NewWriter(&data)
if err := t.Execute(writer, selectors); err != nil {
return fmt.Errorf("labelTransformer template excution failed: %w", err)
return fmt.Errorf("labelTransformer template execution failed: %w", err)
}

if err := writer.Flush(); err != nil {
Expand Down

0 comments on commit a64fc01

Please sign in to comment.