Skip to content

Commit a74a334

Browse files
authored
Merge pull request containerd#3529 from apostasie/cni-lock-again
Fix CNIEnv concurrency issue
2 parents 57bafac + 50ac0b6 commit a74a334

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: pkg/netutil/netutil.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,15 @@ func NewCNIEnv(cniPath, cniConfPath string, opts ...CNIEnvOpt) (*CNIEnv, error)
215215
}
216216

217217
func (e *CNIEnv) NetworkList() ([]*NetworkConfig, error) {
218-
return e.networkConfigList()
218+
var netConfigList []*NetworkConfig
219+
var err error
220+
fn := func() error {
221+
netConfigList, err = e.networkConfigList()
222+
return err
223+
}
224+
err = lockutil.WithDirLock(e.NetconfPath, fn)
225+
226+
return netConfigList, err
219227
}
220228

221229
func (e *CNIEnv) NetworkMap() (map[string]*NetworkConfig, error) { //nolint:revive

0 commit comments

Comments
 (0)