Merge pull request #873 from sargun/fix-node-ping

Fix node ping interval code / default setting code
This commit is contained in:
Sargun Dhillon
2020-08-18 00:49:51 -07:00
committed by GitHub
2 changed files with 16 additions and 7 deletions

View File

@@ -82,6 +82,14 @@ func NewNodeController(p NodeProvider, node *corev1.Node, nodes v1.NodeInterface
return nil, pkgerrors.Wrap(err, "error applying node option")
}
}
if n.pingInterval == time.Duration(0) {
n.pingInterval = DefaultPingInterval
}
if n.statusInterval == time.Duration(0) {
n.statusInterval = DefaultStatusUpdateInterval
}
n.nodePingController = newNodePingController(n.p, n.pingInterval, n.pingTimeout)
return n, nil
@@ -206,13 +214,6 @@ const (
// periodically), otherwise it will only use node status update with the configured
// ping interval.
func (n *NodeController) Run(ctx context.Context) error {
if n.pingInterval == time.Duration(0) {
n.pingInterval = DefaultPingInterval
}
if n.statusInterval == time.Duration(0) {
n.statusInterval = DefaultStatusUpdateInterval
}
n.chStatusUpdate = make(chan *corev1.Node, 1)
n.p.NotifyNodeStatus(ctx, func(node *corev1.Node) {
n.chStatusUpdate <- node

View File

@@ -28,6 +28,14 @@ type pingResult struct {
}
func newNodePingController(node NodeProvider, pingInterval time.Duration, timeout *time.Duration) *nodePingController {
if pingInterval == 0 {
panic("Node ping interval is 0")
}
if timeout != nil && *timeout == 0 {
panic("Node ping timeout is 0")
}
return &nodePingController{
nodeProvider: node,
pingInterval: pingInterval,