Skip to content

Commit

Permalink
Fix calling nodeInformer in EgressIPManager.
Browse files Browse the repository at this point in the history
This commit adds nodeInformer to the creation of a eim, as previously it
couldn't be instatiated. In addition, it triggers the change of EIP on
the hostsubnet when the node can't be reached.
  • Loading branch information
danielmellado committed Aug 26, 2020
1 parent 06c184f commit 82c79ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions pkg/network/master/egressip.go
Expand Up @@ -49,9 +49,10 @@ func newEgressIPManager() *egressIPManager {
return eim
}

func (eim *egressIPManager) Start(networkClient networkclient.Interface, hostSubnetInformer networkinformers.HostSubnetInformer, netNamespaceInformer networkinformers.NetNamespaceInformer) {
func (eim *egressIPManager) Start(networkClient networkclient.Interface, hostSubnetInformer networkinformers.HostSubnetInformer, netNamespaceInformer networkinformers.NetNamespaceInformer, nodeInformer kcoreinformers.NodeInformer) {
eim.networkClient = networkClient
eim.hostSubnetInformer = hostSubnetInformer
eim.nodeInformer = nodeInformer
eim.tracker.Start(hostSubnetInformer, netNamespaceInformer)
}

Expand Down Expand Up @@ -163,6 +164,16 @@ func (eim *egressIPManager) poll(stop chan struct{}) {
}
}

func isNodeConditionGood(cond v1.NodeCondition) bool {
isNodeGood := true
if cond.Type == v1.NodeReady {
if cond.Status == v1.ConditionFalse || cond.Status == v1.ConditionUnknown {
isNodeGood = false
}
}
return isNodeGood
}

func (eim *egressIPManager) check(retrying bool) (bool, error) {
var timeout time.Duration
if retrying {
Expand All @@ -183,12 +194,12 @@ func (eim *egressIPManager) check(retrying bool) (bool, error) {
}

for _, cond := range nn.Status.Conditions {
if cond.Type == v1.TaintNodeNotReady {
klog.Warningf("Node %s is not Ready", node.ip)
if !isNodeConditionGood(cond) {
klog.Warningf("Node %s is not Ready", node.name)
node.offline = true
eim.tracker.SetNodeOffline(node.ip, true)
// Return when there's a not Ready node
return true, nil
return false, nil
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/network/master/master.go
Expand Up @@ -115,7 +115,7 @@ func (master *OsdnMaster) startSubSystems(pluginName string) {
}

eim := newEgressIPManager()
eim.Start(master.networkClient, master.hostSubnetInformer, master.netNamespaceInformer)
eim.Start(master.networkClient, master.hostSubnetInformer, master.netNamespaceInformer, master.nodeInformer)
}

func (master *OsdnMaster) checkClusterNetworkAgainstLocalNetworks() error {
Expand Down

0 comments on commit 82c79ea

Please sign in to comment.