@@ -19,6 +19,7 @@ package controllers
1919import (
2020 "context"
2121 "fmt"
22+ "reflect"
2223 "time"
2324
2425 "gitee.com/zongzw/bigip-kubernetes-gateway/k8s"
@@ -93,48 +94,17 @@ func (r *NodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
9394 return ctrl.Result {Requeue : true }, nil
9495 }
9596
96- oIpAddresses := []string {}
97- nIpAddresses := []string {}
9897 ocfgs := map [string ]interface {}{}
9998 ncfgs := map [string ]interface {}{}
10099
101- oIpToMacV4 := map [string ]string {}
102- // oIpToMacV6 := map[string]string{}
103- nIpToMacV4 := map [string ]string {}
104- // nIpToMacV6 := map[string]string{}
105-
106100 var obj v1.Node
107- zlog := log .FromContext (ctx )
108- zlog .V (1 ).Info ("resource event: " + req .NamespacedName .String ())
101+ // zlog := log.FromContext(ctx)
102+ // zlog.V(1).Info("resource event: " + req.NamespacedName.String())
109103 if err := r .Get (ctx , req .NamespacedName , & obj ); err != nil {
110104 if client .IgnoreNotFound (err ) == nil {
111- if pkg .ActiveSIGs .Mode == "calico" {
112- oIpAddresses = k8s .NodeCache .AllIpAddresses ()
113- if ocfgs , err = pkg .ParseNeighsFrom ("gwcBGP" , "64512" , "64512" , oIpAddresses ); err != nil {
114- return ctrl.Result {}, err
115- }
116- }
117- if pkg .ActiveSIGs .Mode == "flannel" {
118- oIpToMacV4 , _ = k8s .NodeCache .AllIpToMac ()
119- if ocfgs , err = pkg .ParseFdbsFrom (pkg .ActiveSIGs .VxlanTunnelName , oIpToMacV4 ); err != nil {
120- return ctrl.Result {}, err
121- }
122- }
123-
124105 k8s .NodeCache .Unset (req .Name )
125-
126- if pkg .ActiveSIGs .Mode == "calico" {
127- nIpAddresses = k8s .NodeCache .AllIpAddresses ()
128-
129- if ncfgs , err = pkg .ParseNeighsFrom ("gwcBGP" , "64512" , "64512" , nIpAddresses ); err != nil {
130- return ctrl.Result {}, err
131- }
132- }
133- if pkg .ActiveSIGs .Mode == "flannel" {
134- nIpToMacV4 , _ = k8s .NodeCache .AllIpToMac ()
135- if ncfgs , err = pkg .ParseFdbsFrom (pkg .ActiveSIGs .VxlanTunnelName , nIpToMacV4 ); err != nil {
136- return ctrl.Result {}, err
137- }
106+ if ncfgs , err = pkg .ParseNodeConfigs (); err != nil {
107+ return ctrl.Result {}, err
138108 }
139109 pkg .PendingDeploys <- pkg.DeployRequest {
140110 Meta : fmt .Sprintf ("refreshing for request '%s'" , req .Name ),
@@ -148,36 +118,14 @@ func (r *NodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
148118 return ctrl.Result {}, err
149119 }
150120 } else {
151- if pkg .ActiveSIGs .Mode == "calico" {
152- oIpAddresses = k8s .NodeCache .AllIpAddresses ()
153-
154- if ocfgs , err = pkg .ParseNeighsFrom ("gwcBGP" , "64512" , "64512" , oIpAddresses ); err != nil {
155- return ctrl.Result {}, err
156- }
157- }
158-
159- if pkg .ActiveSIGs .Mode == "flannel" {
160- oIpToMacV4 , _ = k8s .NodeCache .AllIpToMac ()
161- if ocfgs , err = pkg .ParseFdbsFrom (pkg .ActiveSIGs .VxlanTunnelName , oIpToMacV4 ); err != nil {
162- return ctrl.Result {}, err
163- }
164- }
165-
121+ orig := k8s .NodeCache .Get (obj .Name )
166122 k8s .NodeCache .Set (obj .DeepCopy ())
167-
168- if pkg .ActiveSIGs .Mode == "calico" {
169- nIpAddresses = k8s .NodeCache .AllIpAddresses ()
170- if ncfgs , err = pkg .ParseNeighsFrom ("gwcBGP" , "64512" , "64512" , nIpAddresses ); err != nil {
171- return ctrl.Result {}, err
172- }
173-
123+ // use reflect.DeepEqual to eliminate endless false-positive node events
124+ if newa := k8s .NodeCache .Get (obj .Name ); reflect .DeepEqual (orig , newa ) {
125+ return ctrl.Result {}, nil
174126 }
175-
176- if pkg .ActiveSIGs .Mode == "flannel" {
177- nIpToMacV4 , _ = k8s .NodeCache .AllIpToMac ()
178- if ncfgs , err = pkg .ParseFdbsFrom (pkg .ActiveSIGs .VxlanTunnelName , nIpToMacV4 ); err != nil {
179- return ctrl.Result {}, err
180- }
127+ if ncfgs , err = pkg .ParseNodeConfigs (); err != nil {
128+ return ctrl.Result {}, err
181129 }
182130 pkg .PendingDeploys <- pkg.DeployRequest {
183131 Meta : fmt .Sprintf ("refreshing for request '%s'" , req .Name ),
0 commit comments