Skip to content

Commit 14830c7

Browse files
authored
fix: some status updates are discarded by the status updater (#4337)
Signed-off-by: Huabing Zhao <[email protected]>
1 parent 9b161ee commit 14830c7

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

internal/provider/kubernetes/status_updater.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,13 @@ func (m MutatorFunc) Mutate(old client.Object) client.Object {
5656
type UpdateHandler struct {
5757
log logr.Logger
5858
client client.Client
59-
sendUpdates chan struct{}
6059
updateChannel chan Update
6160
}
6261

6362
func NewUpdateHandler(log logr.Logger, client client.Client) *UpdateHandler {
6463
return &UpdateHandler{
6564
log: log,
6665
client: client,
67-
sendUpdates: make(chan struct{}),
6866
updateChannel: make(chan Update, 100),
6967
}
7068
}
@@ -129,9 +127,6 @@ func (u *UpdateHandler) Start(ctx context.Context) error {
129127
u.log.Info("started status update handler")
130128
defer u.log.Info("stopped status update handler")
131129

132-
// Enable Updaters to start sending updates to this handler.
133-
close(u.sendUpdates)
134-
135130
for {
136131
select {
137132
case <-ctx.Done():
@@ -148,7 +143,6 @@ func (u *UpdateHandler) Start(ctx context.Context) error {
148143
// Writer retrieves the interface that should be used to write to the UpdateHandler.
149144
func (u *UpdateHandler) Writer() Updater {
150145
return &UpdateWriter{
151-
enabled: u.sendUpdates,
152146
updateChannel: u.updateChannel,
153147
}
154148
}
@@ -160,18 +154,13 @@ type Updater interface {
160154

161155
// UpdateWriter takes status updates and sends these to the UpdateHandler via a channel.
162156
type UpdateWriter struct {
163-
enabled <-chan struct{}
164157
updateChannel chan<- Update
165158
}
166159

167160
// Send sends the given Update off to the update channel for writing by the UpdateHandler.
168161
func (u *UpdateWriter) Send(update Update) {
169162
// Non-blocking receive to see if we should pass along update.
170-
select {
171-
case <-u.enabled:
172-
u.updateChannel <- update
173-
default:
174-
}
163+
u.updateChannel <- update
175164
}
176165

177166
// isStatusEqual checks if two objects have equivalent status.

0 commit comments

Comments
 (0)