Skip to content

Commit

Permalink
Remove daemon check to ping pod gw
Browse files Browse the repository at this point in the history
For a pod who doesnt need networking ability, current implement will block
pod from creating.
  • Loading branch information
halfcrazy committed Mar 30, 2021
1 parent 7d1004e commit ffa0efd
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions pkg/daemon/ovs.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,39 +210,10 @@ func configureContainerNic(nicName, ifName string, ipAddr, gateway string, macAd
return fmt.Errorf("config gateway failed %v", err)
}

return waitNetworkReady(gateway)
return nil
})
}

func waitNetworkReady(gateway string) error {
for _, gw := range strings.Split(gateway, ",") {
pinger, err := goping.NewPinger(gw)
if err != nil {
return fmt.Errorf("failed to init pinger, %v", err)
}
pinger.SetPrivileged(true)
// CNITimeoutSec = 220, cannot exceed
count := 200
pinger.Count = count
pinger.Timeout = time.Duration(count) * time.Second
pinger.Interval = 1 * time.Second

success := false
pinger.OnRecv = func(p *goping.Packet) {
success = true
pinger.Stop()
}
pinger.Run()

cniConnectivityResult.WithLabelValues(nodeName).Add(float64(pinger.PacketsSent))
if !success {
return fmt.Errorf("network not ready after %d ping", count)
}
klog.Infof("network ready after %d ping, gw %v", pinger.PacketsSent, gw)
}
return nil
}

func configureNodeNic(portName, ip, gw string, macAddr net.HardwareAddr, mtu int) error {
ipStr := util.GetIpWithoutMask(ip)
raw, err := ovs.Exec(ovs.MayExist, "add-port", "br-int", util.NodeNic, "--",
Expand Down

0 comments on commit ffa0efd

Please sign in to comment.