Skip to content

Commit 5d8122a

Browse files
author
Ma Shimiao
committed
validate: add network host-specific check
Signed-off-by: Ma Shimiao <[email protected]>
1 parent 893d9e3 commit 5d8122a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

validate/validate.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"io/ioutil"
8+
"net"
89
"os"
910
"path/filepath"
1011
"reflect"
@@ -411,6 +412,26 @@ func (v *Validator) CheckLinuxResources() (msgs []string) {
411412
msgs = append(msgs, fmt.Sprintf("Minimum memory limit should be larger than memory reservation"))
412413
}
413414
}
415+
if r.Network != nil && hostCheck {
416+
var exist bool
417+
interfaces, err := net.Interfaces()
418+
if err != nil {
419+
msgs = append(msgs, err.Error())
420+
return
421+
}
422+
for _, prio := range r.Network.Priorities {
423+
exist = false
424+
for _, ni := range interfaces {
425+
if prio.Name == ni.Name {
426+
exist = true
427+
break
428+
}
429+
}
430+
if !exist {
431+
msgs = append(msgs, fmt.Sprintf("Interface %s does not exist on host", prio.Name))
432+
}
433+
}
434+
}
414435

415436
return
416437
}

0 commit comments

Comments
 (0)