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

@@ -136,10 +136,12 @@ func NewCNIServer(daemonConfig *ControllerNetConf, serverConfig []byte) (*Server
exec := invoke.Exec(nil)
if daemonConfig.ChrootDir != "" {
exec = &ChrootExec{
chrootExec := &ChrootExec{
Stderr: os.Stderr,
chrootDir: daemonConfig.ChrootDir,
}
types.ChrootMutex = &chrootExec.mu
exec = chrootExec
logging.Verbosef("server configured with chroot: %s", daemonConfig.ChrootDir)
}