From 14830c7b7a7fa20cd3c5e82625c355485bcbd961 Mon Sep 17 00:00:00 2001 From: Huabing Zhao Date: Fri, 27 Sep 2024 09:31:10 +0800 Subject: [PATCH] fix: some status updates are discarded by the status updater (#4337) Signed-off-by: Huabing Zhao --- internal/provider/kubernetes/status_updater.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/internal/provider/kubernetes/status_updater.go b/internal/provider/kubernetes/status_updater.go index 9da708f1b02..24adaedd563 100644 --- a/internal/provider/kubernetes/status_updater.go +++ b/internal/provider/kubernetes/status_updater.go @@ -56,7 +56,6 @@ func (m MutatorFunc) Mutate(old client.Object) client.Object { type UpdateHandler struct { log logr.Logger client client.Client - sendUpdates chan struct{} updateChannel chan Update } @@ -64,7 +63,6 @@ func NewUpdateHandler(log logr.Logger, client client.Client) *UpdateHandler { return &UpdateHandler{ log: log, client: client, - sendUpdates: make(chan struct{}), updateChannel: make(chan Update, 100), } } @@ -129,9 +127,6 @@ func (u *UpdateHandler) Start(ctx context.Context) error { u.log.Info("started status update handler") defer u.log.Info("stopped status update handler") - // Enable Updaters to start sending updates to this handler. - close(u.sendUpdates) - for { select { case <-ctx.Done(): @@ -148,7 +143,6 @@ func (u *UpdateHandler) Start(ctx context.Context) error { // Writer retrieves the interface that should be used to write to the UpdateHandler. func (u *UpdateHandler) Writer() Updater { return &UpdateWriter{ - enabled: u.sendUpdates, updateChannel: u.updateChannel, } } @@ -160,18 +154,13 @@ type Updater interface { // UpdateWriter takes status updates and sends these to the UpdateHandler via a channel. type UpdateWriter struct { - enabled <-chan struct{} updateChannel chan<- Update } // Send sends the given Update off to the update channel for writing by the UpdateHandler. func (u *UpdateWriter) Send(update Update) { // Non-blocking receive to see if we should pass along update. - select { - case <-u.enabled: - u.updateChannel <- update - default: - } + u.updateChannel <- update } // isStatusEqual checks if two objects have equivalent status.