diff --git a/api/v1beta1/bucket_types.go b/api/v1beta1/bucket_types.go index 29db6e16..2c10960c 100644 --- a/api/v1beta1/bucket_types.go +++ b/api/v1beta1/bucket_types.go @@ -95,6 +95,8 @@ type BucketStatus struct { // Artifact represents the output of the last successful Bucket sync. // +optional Artifact *Artifact `json:"artifact,omitempty"` + + meta.ReconcileRequestStatus `json:",inline"` } const ( diff --git a/api/v1beta1/gitrepository_types.go b/api/v1beta1/gitrepository_types.go index 1d0831a8..ce2ea8d9 100644 --- a/api/v1beta1/gitrepository_types.go +++ b/api/v1beta1/gitrepository_types.go @@ -116,6 +116,8 @@ type GitRepositoryStatus struct { // Artifact represents the output of the last successful repository sync. // +optional Artifact *Artifact `json:"artifact,omitempty"` + + meta.ReconcileRequestStatus `json:",inline"` } const ( diff --git a/api/v1beta1/helmchart_types.go b/api/v1beta1/helmchart_types.go index 2b3a9f9c..6a7e6af5 100644 --- a/api/v1beta1/helmchart_types.go +++ b/api/v1beta1/helmchart_types.go @@ -86,6 +86,8 @@ type HelmChartStatus struct { // Artifact represents the output of the last successful chart sync. // +optional Artifact *Artifact `json:"artifact,omitempty"` + + meta.ReconcileRequestStatus `json:",inline"` } const ( diff --git a/api/v1beta1/helmrepository_types.go b/api/v1beta1/helmrepository_types.go index de6fbbab..c8f7a76d 100644 --- a/api/v1beta1/helmrepository_types.go +++ b/api/v1beta1/helmrepository_types.go @@ -73,6 +73,8 @@ type HelmRepositoryStatus struct { // Artifact represents the output of the last successful repository sync. // +optional Artifact *Artifact `json:"artifact,omitempty"` + + meta.ReconcileRequestStatus `json:",inline"` } const ( diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index ace990b0..d8e1018b 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -147,6 +147,7 @@ func (in *BucketStatus) DeepCopyInto(out *BucketStatus) { *out = new(Artifact) (*in).DeepCopyInto(*out) } + out.ReconcileRequestStatus = in.ReconcileRequestStatus } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BucketStatus. @@ -289,6 +290,7 @@ func (in *GitRepositoryStatus) DeepCopyInto(out *GitRepositoryStatus) { *out = new(Artifact) (*in).DeepCopyInto(*out) } + out.ReconcileRequestStatus = in.ReconcileRequestStatus } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitRepositoryStatus. @@ -408,6 +410,7 @@ func (in *HelmChartStatus) DeepCopyInto(out *HelmChartStatus) { *out = new(Artifact) (*in).DeepCopyInto(*out) } + out.ReconcileRequestStatus = in.ReconcileRequestStatus } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartStatus. @@ -520,6 +523,7 @@ func (in *HelmRepositoryStatus) DeepCopyInto(out *HelmRepositoryStatus) { *out = new(Artifact) (*in).DeepCopyInto(*out) } + out.ReconcileRequestStatus = in.ReconcileRequestStatus } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmRepositoryStatus. diff --git a/config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml b/config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml index 7539f995..5665a6a5 100644 --- a/config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml +++ b/config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml @@ -196,6 +196,10 @@ spec: - type type: object type: array + lastHandledReconcileAt: + description: LastHandledReconcileAt holds the value of the most recent + reconcile request value, so a change can be detected. + type: string observedGeneration: description: ObservedGeneration is the last observed generation. format: int64 diff --git a/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml b/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml index 06493bab..48c16056 100644 --- a/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml +++ b/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml @@ -224,6 +224,10 @@ spec: - type type: object type: array + lastHandledReconcileAt: + description: LastHandledReconcileAt holds the value of the most recent + reconcile request value, so a change can be detected. + type: string observedGeneration: description: ObservedGeneration is the last observed generation. format: int64 diff --git a/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml b/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml index 52d2ca41..39af34b5 100644 --- a/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml +++ b/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml @@ -200,6 +200,10 @@ spec: - type type: object type: array + lastHandledReconcileAt: + description: LastHandledReconcileAt holds the value of the most recent + reconcile request value, so a change can be detected. + type: string observedGeneration: description: ObservedGeneration is the last observed generation. format: int64 diff --git a/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml b/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml index 1f9b4bfa..8cae509a 100644 --- a/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml +++ b/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml @@ -175,6 +175,10 @@ spec: - type type: object type: array + lastHandledReconcileAt: + description: LastHandledReconcileAt holds the value of the most recent + reconcile request value, so a change can be detected. + type: string observedGeneration: description: ObservedGeneration is the last observed generation. format: int64 diff --git a/controllers/bucket_controller.go b/controllers/bucket_controller.go index 9bc4abfb..4ac120d3 100644 --- a/controllers/bucket_controller.go +++ b/controllers/bucket_controller.go @@ -109,6 +109,13 @@ func (r *BucketReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { r.recordReadiness(bucket) } + // record the value of the reconciliation request, if any + // TODO(hidde): would be better to defer this in combination with + // always patching the status sub-resource after a reconciliation. + if v, ok := meta.ReconcileAnnotationValue(bucket.GetAnnotations()); ok { + bucket.Status.SetLastHandledReconcileRequest(v) + } + // purge old artifacts from storage if err := r.gc(bucket); err != nil { log.Error(err, "unable to purge old artifacts") diff --git a/controllers/gitrepository_controller.go b/controllers/gitrepository_controller.go index faaa879a..88ef0e76 100644 --- a/controllers/gitrepository_controller.go +++ b/controllers/gitrepository_controller.go @@ -108,6 +108,13 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro r.recordReadiness(repository) } + // record the value of the reconciliation request, if any + // TODO(hidde): would be better to defer this in combination with + // always patching the status sub-resource after a reconciliation. + if v, ok := meta.ReconcileAnnotationValue(repository.GetAnnotations()); ok { + repository.Status.SetLastHandledReconcileRequest(v) + } + // purge old artifacts from storage if err := r.gc(repository); err != nil { log.Error(err, "unable to purge old artifacts") diff --git a/controllers/helmchart_controller.go b/controllers/helmchart_controller.go index 518620ca..995e203f 100644 --- a/controllers/helmchart_controller.go +++ b/controllers/helmchart_controller.go @@ -95,7 +95,7 @@ func (r *HelmChartReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { return r.reconcileDelete(ctx, chart) } - // record reconciliation duration + // Record reconciliation duration if r.MetricsRecorder != nil { objRef, err := reference.GetReference(r.Scheme, &chart) if err != nil { @@ -115,6 +115,13 @@ func (r *HelmChartReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { r.recordReadiness(chart) } + // Record the value of the reconciliation request, if any + // TODO(hidde): would be better to defer this in combination with + // always patching the status sub-resource after a reconciliation. + if v, ok := meta.ReconcileAnnotationValue(chart.GetAnnotations()); ok { + chart.Status.SetLastHandledReconcileRequest(v) + } + // Purge all but current artifact from storage if err := r.gc(chart); err != nil { log.Error(err, "unable to purge old artifacts") diff --git a/controllers/helmrepository_controller.go b/controllers/helmrepository_controller.go index a74d8880..fc889660 100644 --- a/controllers/helmrepository_controller.go +++ b/controllers/helmrepository_controller.go @@ -109,6 +109,13 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err r.recordReadiness(repository) } + // record the value of the reconciliation request, if any + // TODO(hidde): would be better to defer this in combination with + // always patching the status sub-resource after a reconciliation. + if v, ok := meta.ReconcileAnnotationValue(repository.GetAnnotations()); ok { + repository.Status.SetLastHandledReconcileRequest(v) + } + // purge old artifacts from storage if err := r.gc(repository); err != nil { log.Error(err, "unable to purge old artifacts") diff --git a/docs/api/source.md b/docs/api/source.md index 188c3662..5ac01962 100644 --- a/docs/api/source.md +++ b/docs/api/source.md @@ -908,7 +908,7 @@ int64
conditions
Artifact represents the output of the last successful Bucket sync.
ReconcileRequestStatus
+(Members of ReconcileRequestStatus
are embedded into this type.)
+
conditions
Artifact represents the output of the last successful repository sync.
ReconcileRequestStatus
+(Members of ReconcileRequestStatus
are embedded into this type.)
+
conditions
Artifact represents the output of the last successful chart sync.
ReconcileRequestStatus
+(Members of ReconcileRequestStatus
are embedded into this type.)
+
conditions
Artifact represents the output of the last successful repository sync.
ReconcileRequestStatus
+(Members of ReconcileRequestStatus
are embedded into this type.)
+