Report progressing status
Set ready condition to unknown while the reconciliation is progressing. This allows other operators to wait for a sync to complete.
This commit is contained in:
parent
9007286496
commit
86f6e84d59
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue