From 9d1d5f2f0396793b35b929eaedd1eb2c30648854 Mon Sep 17 00:00:00 2001 From: James Rasell Date: Thu, 28 Aug 2025 08:05:58 +0100 Subject: [PATCH] csi: Correctly sort IDs when listing controller plugin clients. (#26640) --- .golangci.yml | 1 + nomad/client_csi_endpoint.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 0b3a2fc64..29c11da10 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -52,6 +52,7 @@ linters: - shadow staticcheck: checks: + - SA4029 - SA5008 - ST1016 - ST1020 diff --git a/nomad/client_csi_endpoint.go b/nomad/client_csi_endpoint.go index 4052b380d..91056f898 100644 --- a/nomad/client_csi_endpoint.go +++ b/nomad/client_csi_endpoint.go @@ -6,7 +6,7 @@ package nomad import ( "errors" "fmt" - "sort" + "slices" "strings" "time" @@ -280,7 +280,7 @@ func (a *ClientCSI) sendCSINodeRPC(nodeID, method, fwdMethod, op string, args an return nil } -// clientIDsForController returns a shuffled list of client IDs where the +// clientIDsForController returns a sorted list of client IDs where the // controller plugin is expected to be running. func (a *ClientCSI) clientIDsForController(pluginID string) ([]string, error) { @@ -354,7 +354,7 @@ func (a *ClientCSI) clientIDsForController(pluginID string) ([]string, error) { // and have undocumented expectations of using k8s-specific sidecars to // leader elect. Sort the client IDs so that we prefer sending requests to // the same controller to hack around this. - clientIDs = sort.StringSlice(clientIDs) + slices.Sort(clientIDs) return clientIDs, nil }