Add mutex lock for load confs in GetDefaultNetworks (#1073)

Thick server's chroot mutex is missing in GetDefaultNetworks,
that touch the pod filesystem. This change adds mutex lock there
and prevent race condition.

Fix #1072
This commit is contained in:
Tomofumi Hayashi
2023-04-13 22:40:16 +09:00
committed by GitHub
parent 487c6fcec4
commit 7c22973f9f
3 changed files with 20 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ import (
"net"
"os"
"strings"
"sync"
"github.com/containernetworking/cni/libcni"
"github.com/containernetworking/cni/pkg/skel"
@@ -39,6 +40,9 @@ const (
defaultNonIsolatedNamespace = "default"
)
// ChrootMutex provides lock to access host filesystem
var ChrootMutex *sync.Mutex
// LoadDelegateNetConfList reads DelegateNetConf from bytes
func LoadDelegateNetConfList(bytes []byte, delegateConf *DelegateNetConf) error {
logging.Debugf("LoadDelegateNetConfList: %s, %v", string(bytes), delegateConf)