From 3bc65fcb99db48c89228792666e9a1c310729a82 Mon Sep 17 00:00:00 2001 From: Ulrich Schreiner Date: Wed, 24 Jan 2024 15:49:33 +0100 Subject: [PATCH] check for old value and only update if new values differ --- controllers/clusterwidenetworkpolicy_controller.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/controllers/clusterwidenetworkpolicy_controller.go b/controllers/clusterwidenetworkpolicy_controller.go index c003f4b8..b9f52a37 100644 --- a/controllers/clusterwidenetworkpolicy_controller.go +++ b/controllers/clusterwidenetworkpolicy_controller.go @@ -239,6 +239,11 @@ func (r *ClusterwideNetworkPolicyReconciler) allowedCWNPs(ctx context.Context, c } func (r *ClusterwideNetworkPolicyReconciler) updateCWNPState(ctx context.Context, cwnp firewallv1.ClusterwideNetworkPolicy, state firewallv1.PolicyDeploymentState, msg string) error { + // do nothing if message and state already have the desired values + if cwnp.Status.Message == msg && cwnp.Status.State == state { + return nil + } + cwnp.Status.Message = msg cwnp.Status.State = state