From d0fc938a07fb8d55224eebaacd5ba5a8db96a63f Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Sat, 19 Jul 2025 11:30:31 +0200 Subject: [PATCH] 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. --- .../src/k8s.io/dynamic-resource-allocation/client/generic.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/staging/src/k8s.io/dynamic-resource-allocation/client/generic.go b/staging/src/k8s.io/dynamic-resource-allocation/client/generic.go index 8ac672e7668..15ea24baeac 100644 --- a/staging/src/k8s.io/dynamic-resource-allocation/client/generic.go +++ b/staging/src/k8s.io/dynamic-resource-allocation/client/generic.go @@ -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.