Merge pull request #885 from fluxcd/drift-correction-ready-condition
Update Ready condition during drift correction
This commit is contained in:
commit
b31701ebf4
|
@ -24,6 +24,8 @@ import (
|
|||
apierrutil "k8s.io/apimachinery/pkg/util/errors"
|
||||
"k8s.io/client-go/tools/record"
|
||||
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
"github.com/fluxcd/pkg/runtime/conditions"
|
||||
"github.com/fluxcd/pkg/ssa"
|
||||
"github.com/fluxcd/pkg/ssa/jsondiff"
|
||||
|
||||
|
@ -64,6 +66,9 @@ func (r *CorrectClusterDrift) Reconcile(ctx context.Context, req *Request) error
|
|||
ctx, cancel := context.WithTimeout(ctx, req.Object.GetTimeout().Duration)
|
||||
defer cancel()
|
||||
|
||||
// Update condition to reflect the current status.
|
||||
conditions.MarkUnknown(req.Object, meta.ReadyCondition, meta.ProgressingReason, "correcting cluster drift")
|
||||
|
||||
changeSet, err := action.ApplyDiff(ctx, r.configFactory.Build(nil), r.diff, r.fieldManager)
|
||||
r.report(req.Object, changeSet, err)
|
||||
return nil
|
||||
|
|
|
@ -24,10 +24,13 @@ import (
|
|||
. "github.com/onsi/gomega"
|
||||
extjsondiff "github.com/wI2L/jsondiff"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
apierrutil "k8s.io/apimachinery/pkg/util/errors"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
"github.com/fluxcd/pkg/runtime/conditions"
|
||||
"github.com/fluxcd/pkg/ssa"
|
||||
"github.com/fluxcd/pkg/ssa/jsondiff"
|
||||
|
||||
|
@ -154,6 +157,10 @@ func TestCorrectClusterDrift_Reconcile(t *testing.T) {
|
|||
} else {
|
||||
g.Expect(recorder.GetEvents()).To(BeEmpty())
|
||||
}
|
||||
|
||||
g.Expect(tt.obj.Status.Conditions).To(conditions.MatchConditions([]metav1.Condition{
|
||||
*conditions.UnknownCondition(meta.ReadyCondition, meta.ProgressingReason, "correcting cluster drift"),
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue