From 03f7b6a239a3230e1604b4fe065dd67295cb4484 Mon Sep 17 00:00:00 2001 From: Tharsanan1 Date: Tue, 8 Oct 2024 15:37:25 +0530 Subject: [PATCH] Fix indefintely increasing status events --- .../internal/operator/controllers/dp/api_controller.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/adapter/internal/operator/controllers/dp/api_controller.go b/adapter/internal/operator/controllers/dp/api_controller.go index 431fed99e..872030de2 100644 --- a/adapter/internal/operator/controllers/dp/api_controller.go +++ b/adapter/internal/operator/controllers/dp/api_controller.go @@ -2723,7 +2723,14 @@ func (apiReconciler *APIReconciler) handleStatus() { hCopy.Status.DeploymentStatus.Status = successEvent.State hCopy.Status.DeploymentStatus.Accepted = accept hCopy.Status.DeploymentStatus.Message = message - hCopy.Status.DeploymentStatus.Events = append(hCopy.Status.DeploymentStatus.Events, event) + events := hCopy.Status.DeploymentStatus.Events + // Keep the first 2 and last 3 events, remove the rest + if len(events) > 6 { + // Truncate the events and add the special event + events = append(events[:2], events[len(events)-3:]...) + } + + hCopy.Status.DeploymentStatus.Events = append(events, event) hCopy.Status.DeploymentStatus.TransitionTime = &timeNow return hCopy },