From 72945e3679f7fc54dd818457a67212d758481526 Mon Sep 17 00:00:00 2001 From: Tomofumi Hayashi Date: Sat, 15 Apr 2023 02:02:44 +0900 Subject: [PATCH] Add missing mutex lock for race condition fix (#1074) --- pkg/k8sclient/k8sclient.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/k8sclient/k8sclient.go b/pkg/k8sclient/k8sclient.go index 006d5a48a..5d5b4e154 100644 --- a/pkg/k8sclient/k8sclient.go +++ b/pkg/k8sclient/k8sclient.go @@ -292,6 +292,11 @@ func getKubernetesDelegate(client *ClientInfo, net *types.NetworkSelectionElemen } } + // acquire lock to access file + if types.ChrootMutex != nil { + types.ChrootMutex.Lock() + defer types.ChrootMutex.Unlock() + } configBytes, err := netutils.GetCNIConfig(customResource, confdir) if err != nil { return nil, resourceMap, err