Record last handled reconcile at annotation
This commit is contained in:
parent
1b20d255a8
commit
45bfe6dfe5
|
@ -135,6 +135,11 @@ type KustomizationStatus struct {
|
|||
// +optional
|
||||
LastAttemptedRevision string `json:"lastAttemptedRevision,omitempty"`
|
||||
|
||||
// LastHandledReconcileAt is the last manual reconciliation request (by
|
||||
// annotating the Kustomization) handled by the reconciler.
|
||||
// +optional
|
||||
LastHandledReconcileAt string `json:"lastHandledReconcileAt,omitempty"`
|
||||
|
||||
// The last successfully applied revision metadata.
|
||||
// +optional
|
||||
Snapshot *Snapshot `json:"snapshot,omitempty"`
|
||||
|
|
|
@ -228,6 +228,10 @@ spec:
|
|||
description: LastAttemptedRevision is the revision of the last reconciliation
|
||||
attempt.
|
||||
type: string
|
||||
lastHandledReconcileAt:
|
||||
description: LastHandledReconcileAt is the last manual reconciliation
|
||||
request (by annotating the Kustomization) handled by the reconciler.
|
||||
type: string
|
||||
observedGeneration:
|
||||
description: ObservedGeneration is the last reconciled generation.
|
||||
format: int64
|
||||
|
|
|
@ -44,7 +44,6 @@ import (
|
|||
"sigs.k8s.io/kustomize/api/krusty"
|
||||
kustypes "sigs.k8s.io/kustomize/api/types"
|
||||
|
||||
"github.com/fluxcd/pkg/lockedfile"
|
||||
"github.com/fluxcd/pkg/recorder"
|
||||
"github.com/fluxcd/pkg/runtime/predicates"
|
||||
"github.com/fluxcd/pkg/untar"
|
||||
|
@ -214,18 +213,10 @@ func (r *KustomizationReconciler) SetupWithManager(mgr ctrl.Manager, opts Kustom
|
|||
func (r *KustomizationReconciler) reconcile(
|
||||
kustomization kustomizev1.Kustomization,
|
||||
source sourcev1.Source) (kustomizev1.Kustomization, error) {
|
||||
// acquire lock
|
||||
unlock, err := r.lock(fmt.Sprintf("%s-%s", kustomization.GetName(), kustomization.GetNamespace()))
|
||||
if err != nil {
|
||||
err = fmt.Errorf("lockfile error: %w", err)
|
||||
return kustomizev1.KustomizationNotReady(
|
||||
kustomization,
|
||||
source.GetArtifact().Revision,
|
||||
sourcev1.StorageOperationFailedReason,
|
||||
err.Error(),
|
||||
), err
|
||||
// record the value of the reconciliation request, if any
|
||||
if v, ok := kustomization.GetAnnotations()[consts.ReconcileAtAnnotation]; ok {
|
||||
kustomization.Status.LastHandledReconcileAt = v
|
||||
}
|
||||
defer unlock()
|
||||
|
||||
// create tmp dir
|
||||
tmpDir, err := ioutil.TempDir("", kustomization.Name)
|
||||
|
@ -646,12 +637,6 @@ func (r *KustomizationReconciler) checkHealth(kustomization kustomizev1.Kustomiz
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *KustomizationReconciler) lock(name string) (unlock func(), err error) {
|
||||
lockFile := path.Join(os.TempDir(), name+".lock")
|
||||
mutex := lockedfile.MutexAt(lockFile)
|
||||
return mutex.Lock()
|
||||
}
|
||||
|
||||
func (r *KustomizationReconciler) parseApplyOutput(in []byte) map[string]string {
|
||||
result := make(map[string]string)
|
||||
input := strings.Split(string(in), "\n")
|
||||
|
|
|
@ -763,6 +763,19 @@ string
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>lastHandledReconcileAt</code><br>
|
||||
<em>
|
||||
string
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>LastHandledReconcileAt is the last manual reconciliation request (by
|
||||
annotating the Kustomization) handled by the reconciler.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>snapshot</code><br>
|
||||
<em>
|
||||
<a href="#kustomize.toolkit.fluxcd.io/v1alpha1.Snapshot">
|
||||
|
|
|
@ -104,6 +104,11 @@ type KustomizationStatus struct {
|
|||
// +optional
|
||||
LastAttemptedRevision string `json:"lastAttemptedRevision,omitempty"`
|
||||
|
||||
// LastHandledReconcileAt is the last manual reconciliation request (by
|
||||
// annotating the Kustomization) handled by the reconciler.
|
||||
// +optional
|
||||
LastHandledReconcileAt string `json:"lastHandledReconcileAt,omitempty"`
|
||||
|
||||
// The last successfully applied revision metadata.
|
||||
// +optional
|
||||
Snapshot *Snapshot `json:"snapshot"`
|
||||
|
|
Loading…
Reference in New Issue