Browse Source

fix: update condition when error message changes

fixes #116
Moritz Johner 5 years ago
parent
commit
f49de4f887

+ 5 - 0
pkg/controllers/externalsecret/externalsecret_controller.go

@@ -28,6 +28,7 @@ import (
 	ctrl "sigs.k8s.io/controller-runtime"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
+	"sigs.k8s.io/controller-runtime/pkg/predicate"
 
 	esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
 	"github.com/external-secrets/external-secrets/pkg/provider"
@@ -231,8 +232,12 @@ func (r *Reconciler) getProviderSecretData(ctx context.Context, providerClient p
 }
 
 func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
+	// prevent reconcile on status updates
+	// https://github.com/kubernetes-sigs/kubebuilder/issues/618#issuecomment-698018831
+	pred := predicate.GenerationChangedPredicate{}
 	return ctrl.NewControllerManagedBy(mgr).
 		For(&esv1alpha1.ExternalSecret{}).
+		WithEventFilter(pred).
 		Owns(&corev1.Secret{}).
 		Complete(r)
 }

+ 2 - 1
pkg/controllers/externalsecret/util.go

@@ -46,7 +46,8 @@ func GetExternalSecretCondition(status esv1alpha1.ExternalSecretStatus, condType
 func SetExternalSecretCondition(es *esv1alpha1.ExternalSecret, condition esv1alpha1.ExternalSecretStatusCondition) {
 	currentCond := GetExternalSecretCondition(es.Status, condition.Type)
 
-	if currentCond != nil && currentCond.Status == condition.Status && currentCond.Reason == condition.Reason {
+	if currentCond != nil && currentCond.Status == condition.Status &&
+		currentCond.Reason == condition.Reason && currentCond.Message == condition.Message {
 		updateExternalSecretCondition(es, &condition, 1.0)
 		return
 	}