mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-20 07:56:02 +00:00
DRA client: fix conversion of watch channel
When the input channel gets closed (for example, because the apiserver got shut down), then the output channel also needs to get closed because that triggers the next round of List+Watch. Also, the channel is used to transmit errors, so it can happen that non-data items need to be forwarded. That is not an error that needs to be logged.
This commit is contained in:
@@ -303,6 +303,8 @@ func (w *watchSomething[NP, N, OP]) ResultChan() <-chan watch.Event {
|
||||
}
|
||||
|
||||
func (w *watchSomething[NP, N, OP]) run() {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer close(w.resultChan)
|
||||
resultChan := w.upstream.ResultChan()
|
||||
for {
|
||||
e, ok := <-resultChan
|
||||
@@ -320,9 +322,6 @@ func (w *watchSomething[NP, N, OP]) run() {
|
||||
Type: e.Type,
|
||||
Object: NP(out),
|
||||
}
|
||||
} else {
|
||||
//nolint:logcheck // Shouldn't happen.
|
||||
klog.Errorf("unexpected object with type %T received from watch", e.Object)
|
||||
}
|
||||
// This must not get blocked when the consumer stops reading,
|
||||
// hence the stopChan.
|
||||
|
||||
Reference in New Issue
Block a user