Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report progressing status #21

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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