Skip to content

Commit 3b6c372

Browse files
author
OpenShift Bot
authored
Merge pull request #11742 from rajatchopra/f5
Merged by openshift-bot
2 parents 75ed7e1 + 315c2e4 commit 3b6c372

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

pkg/router/f5/plugin.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/golang/glog"
77
kapi "k8s.io/kubernetes/pkg/api"
8+
"k8s.io/kubernetes/pkg/types"
89
"k8s.io/kubernetes/pkg/util/sets"
910
"k8s.io/kubernetes/pkg/watch"
1011

@@ -17,6 +18,10 @@ type F5Plugin struct {
1718
// F5Client is the object that represents the F5 BIG-IP host, holds state,
1819
// and provides an interface to manipulate F5 BIG-IP.
1920
F5Client *f5LTM
21+
22+
// VtepMap is a map of node ids and their ip addresses
23+
// helps to sync events at router start vs node status update events
24+
VtepMap map[types.UID]string
2025
}
2126

2227
// F5PluginConfig holds configuration for the f5 plugin.
@@ -84,7 +89,7 @@ func NewF5Plugin(cfg F5PluginConfig) (*F5Plugin, error) {
8489
if err != nil {
8590
return nil, err
8691
}
87-
return &F5Plugin{f5}, f5.Initialize()
92+
return &F5Plugin{f5, map[types.UID]string{}}, f5.Initialize()
8893
}
8994

9095
// ensurePoolExists checks whether the named pool already exists in F5 BIG-IP
@@ -496,19 +501,27 @@ func (p *F5Plugin) HandleNode(eventType watch.EventType, node *kapi.Node) error
496501
// The F5 appliance, if hooked to use the VxLAN encapsulation
497502
// should have its FDB updated depending on nodes arriving and leaving the cluster
498503
switch eventType {
499-
case watch.Added:
504+
case watch.Added, watch.Modified:
500505
// New VTEP created, add the record to the vxlan fdb
501506
ip, err := getNodeIP(node)
502507
if err != nil {
503508
// just log the error
504509
glog.Warningf("Error in obtaining IP address of newly added node %s - %v", node.Name, err)
505510
return nil
506511
}
512+
513+
// check and find if the node has already been processed
514+
// if yes, then break, or just add the new vtep
515+
uid := node.ObjectMeta.UID
516+
if oldNodeIP, ok := p.VtepMap[uid]; ok && (oldNodeIP == ip) {
517+
break
518+
}
507519
err = p.F5Client.AddVtep(ip)
508520
if err != nil {
509521
glog.Errorf("Error in adding node '%s' to F5s FDB - %v", ip, err)
510522
return err
511523
}
524+
p.VtepMap[uid] = ip
512525
case watch.Deleted:
513526
// VTEP deleted, delete the record from vxlan fdb
514527
ip, err := getNodeIP(node)
@@ -522,8 +535,8 @@ func (p *F5Plugin) HandleNode(eventType watch.EventType, node *kapi.Node) error
522535
glog.Errorf("Error in removing node '%s' from F5s FDB - %v", ip, err)
523536
return err
524537
}
525-
case watch.Modified:
526-
// ignore the modified event. Change in IP address of the node is not supported.
538+
uid := node.ObjectMeta.UID
539+
delete(p.VtepMap, uid)
527540
}
528541
return nil
529542
}

0 commit comments

Comments
 (0)