Merge pull request #94 from fluxcd/last-handled-reconcile-at
Record last handled reconcile at annotation
This commit is contained in:
commit
ddcbd1c88e
|
|
@ -593,9 +593,10 @@ type HelmReleaseStatus struct {
|
|||
// +optional
|
||||
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
|
||||
|
||||
// LastObservedTime is the last time at which the HelmRelease was observed.
|
||||
// LastHandledReconcileAt is the last manual reconciliation request (by
|
||||
// annotating the HelmRelease) handled by the reconciler.
|
||||
// +optional
|
||||
LastObservedTime metav1.Time `json:"lastObservedTime,omitempty"`
|
||||
LastHandledReconcileAt string `json:"lastHandledReconcileAt,omitempty"`
|
||||
|
||||
// Conditions holds the conditions for the HelmRelease.
|
||||
// +optional
|
||||
|
|
|
|||
|
|
@ -224,7 +224,6 @@ 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))
|
||||
|
|
|
|||
|
|
@ -453,10 +453,9 @@ 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
|
||||
lastHandledReconcileAt:
|
||||
description: LastHandledReconcileAt is the last manual reconciliation
|
||||
request (by annotating the HelmRelease) handled by the reconciler.
|
||||
type: string
|
||||
lastReleaseRevision:
|
||||
description: LastReleaseRevision is the revision of the last successful
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ func (r *HelmReleaseReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
|
|||
hr, result, err := r.reconcile(ctx, log, hr)
|
||||
|
||||
// Update status after reconciliation.
|
||||
if updateStatusErr := r.updateStatus(ctx, &hr); updateStatusErr != nil {
|
||||
if updateStatusErr := r.Status().Update(ctx, &hr); updateStatusErr != nil {
|
||||
log.Error(updateStatusErr, "unable to update status after reconciliation")
|
||||
return ctrl.Result{Requeue: true}, updateStatusErr
|
||||
}
|
||||
|
|
@ -142,11 +142,16 @@ func (r *HelmReleaseReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
|
|||
}
|
||||
|
||||
func (r *HelmReleaseReconciler) reconcile(ctx context.Context, log logr.Logger, hr v2.HelmRelease) (v2.HelmRelease, ctrl.Result, error) {
|
||||
// Record the value of the reconciliation request, if any
|
||||
if v, ok := hr.GetAnnotations()[consts.ReconcileAtAnnotation]; ok {
|
||||
hr.Status.LastHandledReconcileAt = v
|
||||
}
|
||||
|
||||
// Observe HelmRelease generation.
|
||||
if hr.Status.ObservedGeneration != hr.Generation {
|
||||
hr.Status.ObservedGeneration = hr.Generation
|
||||
hr = v2.HelmReleaseProgressing(hr)
|
||||
if updateStatusErr := r.updateStatus(ctx, &hr); updateStatusErr != nil {
|
||||
if updateStatusErr := r.Status().Update(ctx, &hr); updateStatusErr != nil {
|
||||
log.Error(updateStatusErr, "unable to update status after generation update")
|
||||
return hr, ctrl.Result{Requeue: true}, updateStatusErr
|
||||
}
|
||||
|
|
@ -294,7 +299,7 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, log logr.L
|
|||
hr, hasNewState := v2.HelmReleaseAttempted(hr, revision, releaseRevision, valuesChecksum)
|
||||
if hasNewState {
|
||||
hr = v2.HelmReleaseProgressing(hr)
|
||||
if updateStatusErr := r.updateStatus(ctx, &hr); updateStatusErr != nil {
|
||||
if updateStatusErr := r.Status().Update(ctx, &hr); updateStatusErr != nil {
|
||||
log.Error(updateStatusErr, "unable to update status after state update")
|
||||
return hr, updateStatusErr
|
||||
}
|
||||
|
|
@ -410,11 +415,6 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, log logr.L
|
|||
return v2.HelmReleaseReady(hr), nil
|
||||
}
|
||||
|
||||
func (r *HelmReleaseReconciler) updateStatus(ctx context.Context, hr *v2.HelmRelease) error {
|
||||
hr.Status.LastObservedTime = v1.Now()
|
||||
return r.Status().Update(ctx, hr)
|
||||
}
|
||||
|
||||
func (r *HelmReleaseReconciler) checkDependencies(hr v2.HelmRelease) error {
|
||||
for _, d := range hr.Spec.DependsOn {
|
||||
if d.Namespace == "" {
|
||||
|
|
|
|||
|
|
@ -901,16 +901,15 @@ int64
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>lastObservedTime</code><br>
|
||||
<code>lastHandledReconcileAt</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#time-v1-meta">
|
||||
Kubernetes meta/v1.Time
|
||||
</a>
|
||||
string
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>LastObservedTime is the last time at which the HelmRelease was observed.</p>
|
||||
<p>LastHandledReconcileAt is the last manual reconciliation request (by
|
||||
annotating the HelmRelease) handled by the reconciler.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
|||
Loading…
Reference in New Issue