From fca381a5d1d1b480ae21240fb36f3e311164aa9e Mon Sep 17 00:00:00 2001 From: Enrique Llorente Pastora Date: Fri, 25 Oct 2024 11:10:52 +0200 Subject: [PATCH] events: Remove duplicated 'Available' events (#1922) CNAO is emitting config 'Availabe' event after each reconcile even when nothing changes, this add noise to users. This change emits the event only if Available changes from false to true. Signed-off-by: Enrique Llorente --- pkg/controller/statusmanager/status_manager.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/controller/statusmanager/status_manager.go b/pkg/controller/statusmanager/status_manager.go index 2338054d3..71fd35524 100644 --- a/pkg/controller/statusmanager/status_manager.go +++ b/pkg/controller/statusmanager/status_manager.go @@ -159,7 +159,11 @@ func (status *StatusManager) set(reachedAvailableLevel bool, conditions ...condi ) } else if reachedAvailableLevel { // If successfully deployed all components and is not failing on anything, mark as Available - status.eventEmitter.EmitAvailableForConfig() + if conditionsv1.IsStatusConditionFalse(config.Status.Conditions, conditionsv1.ConditionAvailable) { + // Emit event only if conditions changes from false to true to + // so we don't duplicate events + status.eventEmitter.EmitAvailableForConfig() + } conditionsv1.SetStatusConditionNoHeartbeat(&config.Status.Conditions, conditionsv1.Condition{ Type: conditionsv1.ConditionAvailable,