Use correct interface for netStatus

CNI plugins can return multiple interfaces, eg the bridge plugin.
We need the interface with the sandbox.
This commit is contained in:
Wim 2020-11-14 22:29:22 +01:00
parent 8df5f28dc3
commit 4e37897dd9
1 changed files with 3 additions and 1 deletions

View File

@ -112,7 +112,9 @@ func (c *cniNetworkConfigurator) Setup(ctx context.Context, alloc *structs.Alloc
if len(res.Interfaces) > 0 { if len(res.Interfaces) > 0 {
iface, name := func(r *cni.CNIResult) (*cni.Config, string) { iface, name := func(r *cni.CNIResult) (*cni.Config, string) {
for i := range r.Interfaces { for i := range r.Interfaces {
return r.Interfaces[i], i if r.Interfaces[i].Sandbox != "" {
return r.Interfaces[i], i
}
} }
return nil, "" return nil, ""
}(res) }(res)