diff --git a/api/v2alpha1/helmrelease_types.go b/api/v2alpha1/helmrelease_types.go index 73210d0..9c7d8e5 100644 --- a/api/v2alpha1/helmrelease_types.go +++ b/api/v2alpha1/helmrelease_types.go @@ -563,18 +563,22 @@ func (in Uninstall) GetTimeout(defaultTimeout metav1.Duration) metav1.Duration { // HelmReleaseStatus defines the observed state of HelmRelease type HelmReleaseStatus struct { - // ObservedGeneration is the last reconciled generation. + // ObservedGeneration is the last observed generation. // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty"` - // Conditions holds the conditions for the HelmRelease. - // +optional - Conditions []Condition `json:"conditions,omitempty"` - // ObservedStateReconciled represents whether the observed state has been successfully reconciled. // +optional ObservedStateReconciled bool `json:"observedStateReconciled,omitempty"` + // LastObservedTime is the last time at which the HelmRelease was observed. + // +optional + LastObservedTime metav1.Time `json:"lastObservedTime,omitempty"` + + // Conditions holds the conditions for the HelmRelease. + // +optional + Conditions []Condition `json:"conditions,omitempty"` + // LastAppliedRevision is the revision of the last successfully applied source. // +optional LastAppliedRevision string `json:"lastAppliedRevision,omitempty"` diff --git a/api/v2alpha1/zz_generated.deepcopy.go b/api/v2alpha1/zz_generated.deepcopy.go index 93b9603..2dffa35 100644 --- a/api/v2alpha1/zz_generated.deepcopy.go +++ b/api/v2alpha1/zz_generated.deepcopy.go @@ -207,6 +207,7 @@ func (in *HelmReleaseSpec) DeepCopy() *HelmReleaseSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HelmReleaseStatus) DeepCopyInto(out *HelmReleaseStatus) { *out = *in + in.LastObservedTime.DeepCopyInto(&out.LastObservedTime) if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make([]Condition, len(*in)) diff --git a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml index 5c055cc..9f3e591 100644 --- a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml +++ b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml @@ -409,12 +409,17 @@ spec: description: LastAttemptedValuesChecksum is the SHA1 checksum of the values of the last reconciliation attempt. type: string + lastObservedTime: + description: LastObservedTime is the last time at which the HelmRelease + was observed. + format: date-time + type: string lastReleaseRevision: description: LastReleaseRevision is the revision of the last successful Helm release. type: integer observedGeneration: - description: ObservedGeneration is the last reconciled generation. + description: ObservedGeneration is the last observed generation. format: int64 type: integer observedStateReconciled: diff --git a/controllers/helmrelease_controller.go b/controllers/helmrelease_controller.go index 0d4b193..c67c370 100644 --- a/controllers/helmrelease_controller.go +++ b/controllers/helmrelease_controller.go @@ -125,6 +125,15 @@ func (r *HelmReleaseReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) return ctrl.Result{}, nil } + // Record time of reconciliation attempt. + hr.Status.LastObservedTime = v1.Now() + + // Observe HelmRelease generation. + if hr.Status.ObservedGeneration != hr.Generation { + hr.Status.ObservedGeneration = hr.Generation + hr = v2.HelmReleaseProgressing(hr) + } + if hr.Spec.Suspend { msg := "HelmRelease is suspended, skipping reconciliation" hr = v2.HelmReleaseNotReady(hr, v2.SuspendedReason, msg) @@ -136,12 +145,6 @@ func (r *HelmReleaseReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) return ctrl.Result{}, nil } - // Observe the HelmRelease generation. - if hr.Status.ObservedGeneration != hr.Generation { - hr.Status.ObservedGeneration = hr.Generation - hr = v2.HelmReleaseProgressing(hr) - } - if err := r.Status().Update(ctx, &hr); err != nil { log.Error(err, "unable to update status") return ctrl.Result{Requeue: true}, err diff --git a/docs/api/helmrelease.md b/docs/api/helmrelease.md index ffc62fa..cbdaf82 100644 --- a/docs/api/helmrelease.md +++ b/docs/api/helmrelease.md @@ -770,7 +770,33 @@ int64 (Optional) -

ObservedGeneration is the last reconciled generation.

+

ObservedGeneration is the last observed generation.

+ + + + +observedStateReconciled
+ +bool + + + +(Optional) +

ObservedStateReconciled represents whether the observed state has been successfully reconciled.

+ + + + +lastObservedTime
+ + +Kubernetes meta/v1.Time + + + + +(Optional) +

LastObservedTime is the last time at which the HelmRelease was observed.

@@ -789,18 +815,6 @@ int64 -observedStateReconciled
- -bool - - - -(Optional) -

ObservedStateReconciled represents whether the observed state has been successfully reconciled.

- - - - lastAppliedRevision
string diff --git a/docs/spec/v2alpha1/helmreleases.md b/docs/spec/v2alpha1/helmreleases.md index c80f663..24ada4d 100644 --- a/docs/spec/v2alpha1/helmreleases.md +++ b/docs/spec/v2alpha1/helmreleases.md @@ -674,6 +674,7 @@ status: observedStateReconciled: true lastAppliedRevision: 4.0.6 lastAttemptedRevision: 4.0.6 + lastObservedTime: "2020-07-13T13:18:42Z" lastReleaseRevision: 1 observedGeneration: 2 ``` @@ -704,6 +705,7 @@ status: failures: 1 lastAppliedRevision: 4.0.6 lastAttemptedRevision: 4.0.6 + lastObservedTime: "2020-07-13T18:17:28Z" lastReleaseRevision: 1 observedGeneration: 3 ```