Skip to content

Commit

Permalink
Re-assign once kubelet starts posting NotReady status for node
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Constantinescu <aconstan@redhat.com>
  • Loading branch information
alexanderConstantinescu committed Nov 2, 2020
1 parent 350943c commit 1f101eb
Show file tree
Hide file tree
Showing 3 changed files with 319 additions and 110 deletions.
38 changes: 27 additions & 11 deletions go-controller/pkg/ovn/egressip.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ func (oc *Controller) deleteEgressIP(eIP *egressipv1.EgressIP) error {
return nil
}

func (oc *Controller) isEgressNodeReady(egressNode *kapi.Node) bool {
for _, condition := range egressNode.Status.Conditions {
if condition.Type == v1.NodeReady {
return condition.Status == v1.ConditionTrue
}
}
return false
}

func (oc *Controller) syncEgressIPs(eIPs []interface{}) {
oc.eIPC.allocatorMutex.Lock()
defer oc.eIPC.allocatorMutex.Unlock()
Expand Down Expand Up @@ -357,7 +366,7 @@ func (oc *Controller) getSortedEgressData() ([]egressNode, map[string]bool) {
assignableNodes := []egressNode{}
allAllocations := make(map[string]bool)
for _, eNode := range oc.eIPC.allocator {
if eNode.isEgressAssignable {
if eNode.isEgressAssignable && eNode.isReady {
assignableNodes = append(assignableNodes, *eNode)
}
for ip := range eNode.allocations {
Expand All @@ -370,13 +379,24 @@ func (oc *Controller) getSortedEgressData() ([]egressNode, map[string]bool) {
return assignableNodes, allAllocations
}

func (oc *Controller) addEgressNode(egressNode *kapi.Node) error {
klog.V(5).Infof("Egress node: %s about to be initialized", egressNode.Name)
func (oc *Controller) setNodeEgressAssignable(nodeName string, isAssignable bool) {
oc.eIPC.allocatorMutex.Lock()
if eNode, exists := oc.eIPC.allocator[egressNode.Name]; exists {
eNode.isEgressAssignable = true
defer oc.eIPC.allocatorMutex.Unlock()
if eNode, exists := oc.eIPC.allocator[nodeName]; exists {
eNode.isEgressAssignable = isAssignable
}
oc.eIPC.allocatorMutex.Unlock()
}

func (oc *Controller) setNodeEgressReady(nodeName string, isReady bool) {
oc.eIPC.allocatorMutex.Lock()
defer oc.eIPC.allocatorMutex.Unlock()
if eNode, exists := oc.eIPC.allocator[nodeName]; exists {
eNode.isReady = isReady
}
}

func (oc *Controller) addEgressNode(egressNode *kapi.Node) error {
klog.V(5).Infof("Egress node: %s about to be initialized", egressNode.Name)
oc.eIPC.assignmentRetry.Range(func(key, value interface{}) bool {
eIPName := key.(string)
klog.V(5).Infof("Re-assignment for EgressIP: %s attempted by new node: %s", eIPName, egressNode.Name)
Expand All @@ -396,11 +416,6 @@ func (oc *Controller) addEgressNode(egressNode *kapi.Node) error {
}

func (oc *Controller) deleteEgressNode(egressNode *kapi.Node) error {
oc.eIPC.allocatorMutex.Lock()
if eNode, exists := oc.eIPC.allocator[egressNode.Name]; exists {
eNode.isEgressAssignable = false
}
oc.eIPC.allocatorMutex.Unlock()
klog.V(5).Infof("Egress node: %s about to be removed", egressNode.Name)
egressIPs, err := oc.kube.GetEgressIPs()
if err != nil {
Expand Down Expand Up @@ -511,6 +526,7 @@ type egressNode struct {
v4Subnet *net.IPNet
v6Subnet *net.IPNet
allocations map[string]bool
isReady bool
isEgressAssignable bool
tainted bool
name string
Expand Down

0 comments on commit 1f101eb

Please sign in to comment.