From 6a194182a141665cfcb9b03815d77cd1e468d34e Mon Sep 17 00:00:00 2001 From: cyclinder Date: Tue, 20 Feb 2024 14:34:22 +0800 Subject: [PATCH] Fix data race in apiserver mux handler Signed-off-by: cyclinder --- staging/src/k8s.io/apiserver/pkg/server/mux/pathrecorder.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/apiserver/pkg/server/mux/pathrecorder.go b/staging/src/k8s.io/apiserver/pkg/server/mux/pathrecorder.go index beb7a8d807c..3ed92d96c6d 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/mux/pathrecorder.go +++ b/staging/src/k8s.io/apiserver/pkg/server/mux/pathrecorder.go @@ -96,9 +96,11 @@ func NewPathRecorderMux(name string) *PathRecorderMux { // ListedPaths returns the registered handler exposedPaths. func (m *PathRecorderMux) ListedPaths() []string { + m.lock.Lock() handledPaths := append([]string{}, m.exposedPaths...) - sort.Strings(handledPaths) + m.lock.Unlock() + sort.Strings(handledPaths) return handledPaths }