From d7a64d68b56f407cd6629b2eb0127dbd228a1f9c Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 11 Apr 2025 10:25:55 +0200 Subject: [PATCH] DRA resourceslices: clarify code Using an else clause makes it more obvious that the code either creates a new controller or calls Publish on an existing one, not both. --- .../dynamic-resource-allocation/kubeletplugin/draplugin.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/staging/src/k8s.io/dynamic-resource-allocation/kubeletplugin/draplugin.go b/staging/src/k8s.io/dynamic-resource-allocation/kubeletplugin/draplugin.go index b6882710ef1..03572d85767 100644 --- a/staging/src/k8s.io/dynamic-resource-allocation/kubeletplugin/draplugin.go +++ b/staging/src/k8s.io/dynamic-resource-allocation/kubeletplugin/draplugin.go @@ -641,12 +641,11 @@ func (d *Helper) PublishResources(_ context.Context, resources resourceslice.Dri }); err != nil { return fmt.Errorf("start ResourceSlice controller: %w", err) } - return nil + } else { + // Inform running controller about new information. + d.resourceSliceController.Update(driverResources) } - // Inform running controller about new information. - d.resourceSliceController.Update(driverResources) - return nil }