Skip to content

Commit b8b1ce1

Browse files
authored
Merge pull request #200 from Mashimiao/add-network-host-specific-check
validate: add network host-specific check
2 parents 47ca924 + 768043e commit b8b1ce1

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"
@@ -474,6 +475,26 @@ func (v *Validator) CheckLinuxResources() (msgs []string) {
474475
msgs = append(msgs, fmt.Sprintf("Minimum memory limit should be larger than memory reservation"))
475476
}
476477
}
478+
if r.Network != nil && v.HostSpecific {
479+
var exist bool
480+
interfaces, err := net.Interfaces()
481+
if err != nil {
482+
msgs = append(msgs, err.Error())
483+
return
484+
}
485+
for _, prio := range r.Network.Priorities {
486+
exist = false
487+
for _, ni := range interfaces {
488+
if prio.Name == ni.Name {
489+
exist = true
490+
break
491+
}
492+
}
493+
if !exist {
494+
msgs = append(msgs, fmt.Sprintf("Interface %s does not exist currently", prio.Name))
495+
}
496+
}
497+
}
477498

478499
return
479500
}

0 commit comments

Comments
 (0)