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
|
// +optional
|
||||||
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
|
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
|
// +optional
|
||||||
LastObservedTime metav1.Time `json:"lastObservedTime,omitempty"`
|
LastHandledReconcileAt string `json:"lastHandledReconcileAt,omitempty"`
|
||||||
|
|
||||||
// Conditions holds the conditions for the HelmRelease.
|
// Conditions holds the conditions for the HelmRelease.
|
||||||
// +optional
|
// +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.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *HelmReleaseStatus) DeepCopyInto(out *HelmReleaseStatus) {
|
func (in *HelmReleaseStatus) DeepCopyInto(out *HelmReleaseStatus) {
|
||||||
*out = *in
|
*out = *in
|
||||||
in.LastObservedTime.DeepCopyInto(&out.LastObservedTime)
|
|
||||||
if in.Conditions != nil {
|
if in.Conditions != nil {
|
||||||
in, out := &in.Conditions, &out.Conditions
|
in, out := &in.Conditions, &out.Conditions
|
||||||
*out = make([]Condition, len(*in))
|
*out = make([]Condition, len(*in))
|
||||||
|
|
|
||||||
|
|
@ -453,10 +453,9 @@ spec:
|
||||||
description: LastAttemptedValuesChecksum is the SHA1 checksum of the
|
description: LastAttemptedValuesChecksum is the SHA1 checksum of the
|
||||||
values of the last reconciliation attempt.
|
values of the last reconciliation attempt.
|
||||||
type: string
|
type: string
|
||||||
lastObservedTime:
|
lastHandledReconcileAt:
|
||||||
description: LastObservedTime is the last time at which the HelmRelease
|
description: LastHandledReconcileAt is the last manual reconciliation
|
||||||
was observed.
|
request (by annotating the HelmRelease) handled by the reconciler.
|
||||||
format: date-time
|
|
||||||
type: string
|
type: string
|
||||||
lastReleaseRevision:
|
lastReleaseRevision:
|
||||||
description: LastReleaseRevision is the revision of the last successful
|
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)
|
hr, result, err := r.reconcile(ctx, log, hr)
|
||||||
|
|
||||||
// Update status after reconciliation.
|
// 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")
|
log.Error(updateStatusErr, "unable to update status after reconciliation")
|
||||||
return ctrl.Result{Requeue: true}, updateStatusErr
|
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) {
|
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.
|
// Observe HelmRelease generation.
|
||||||
if hr.Status.ObservedGeneration != hr.Generation {
|
if hr.Status.ObservedGeneration != hr.Generation {
|
||||||
hr.Status.ObservedGeneration = hr.Generation
|
hr.Status.ObservedGeneration = hr.Generation
|
||||||
hr = v2.HelmReleaseProgressing(hr)
|
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")
|
log.Error(updateStatusErr, "unable to update status after generation update")
|
||||||
return hr, ctrl.Result{Requeue: true}, updateStatusErr
|
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)
|
hr, hasNewState := v2.HelmReleaseAttempted(hr, revision, releaseRevision, valuesChecksum)
|
||||||
if hasNewState {
|
if hasNewState {
|
||||||
hr = v2.HelmReleaseProgressing(hr)
|
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")
|
log.Error(updateStatusErr, "unable to update status after state update")
|
||||||
return hr, updateStatusErr
|
return hr, updateStatusErr
|
||||||
}
|
}
|
||||||
|
|
@ -410,11 +415,6 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, log logr.L
|
||||||
return v2.HelmReleaseReady(hr), nil
|
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 {
|
func (r *HelmReleaseReconciler) checkDependencies(hr v2.HelmRelease) error {
|
||||||
for _, d := range hr.Spec.DependsOn {
|
for _, d := range hr.Spec.DependsOn {
|
||||||
if d.Namespace == "" {
|
if d.Namespace == "" {
|
||||||
|
|
|
||||||
|
|
@ -901,16 +901,15 @@ int64
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<code>lastObservedTime</code><br>
|
<code>lastHandledReconcileAt</code><br>
|
||||||
<em>
|
<em>
|
||||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#time-v1-meta">
|
string
|
||||||
Kubernetes meta/v1.Time
|
|
||||||
</a>
|
|
||||||
</em>
|
</em>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<em>(Optional)</em>
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue