@@ -60,10 +60,10 @@ func (master *OsdnMaster) SubnetStartMaster(clusterNetworks []common.ClusterNetw
60
60
return nil
61
61
}
62
62
63
- // addNode takes the nodeName, a preferred nodeIP, the node's annotations and other valid ip addresses
63
+ // addNode takes the nodeName, a preferred nodeIP and the node's annotations
64
64
// Creates or updates a HostSubnet if needed
65
65
// Returns the IP address used for hostsubnet (either the preferred or one from the otherValidAddresses) and any error
66
- func (master * OsdnMaster ) addNode (nodeName string , nodeIP string , hsAnnotations map [string ]string , otherValidAddresses []kapi. NodeAddress ) (string , error ) {
66
+ func (master * OsdnMaster ) addNode (nodeName string , nodeIP string , hsAnnotations map [string ]string ) (string , error ) {
67
67
// Validate node IP before proceeding
68
68
if err := master .networkInfo .ValidateNodeIP (nodeIP ); err != nil {
69
69
return "" , err
@@ -74,8 +74,6 @@ func (master *OsdnMaster) addNode(nodeName string, nodeIP string, hsAnnotations
74
74
if err == nil {
75
75
if sub .HostIP == nodeIP {
76
76
return nodeIP , nil
77
- } else if isValidNodeIP (otherValidAddresses , sub .HostIP ) {
78
- return sub .HostIP , nil
79
77
} else {
80
78
// Node IP changed, update old subnet
81
79
sub .HostIP = nodeIP
@@ -131,23 +129,6 @@ func (master *OsdnMaster) deleteNode(nodeName string) error {
131
129
return nil
132
130
}
133
131
134
- func isValidNodeIP (validAddresses []kapi.NodeAddress , nodeIP string ) bool {
135
- for _ , addr := range validAddresses {
136
- if addr .Address == nodeIP {
137
- return true
138
- }
139
- }
140
- return false
141
- }
142
-
143
- func getNodeIP (node * kapi.Node ) (string , error ) {
144
- if len (node .Status .Addresses ) > 0 && node .Status .Addresses [0 ].Address != "" {
145
- return node .Status .Addresses [0 ].Address , nil
146
- } else {
147
- return netutils .GetNodeIP (node .Name )
148
- }
149
- }
150
-
151
132
// Because openshift-sdn uses an overlay and doesn't need GCE Routes, we need to
152
133
// clear the NetworkUnavailable condition that kubelet adds to initial node
153
134
// status when using GCE.
@@ -210,20 +191,27 @@ func (master *OsdnMaster) watchNodes() {
210
191
211
192
func (master * OsdnMaster ) handleAddOrUpdateNode (obj , _ interface {}, eventType watch.EventType ) {
212
193
node := obj .(* kapi.Node )
213
- nodeIP , err := getNodeIP (node )
214
- if err != nil {
215
- glog .Errorf ("Failed to get node IP for node %s, skipping %s event, node: %v" , node .Name , eventType , node )
194
+
195
+ var nodeIP string
196
+ for _ , addr := range node .Status .Addresses {
197
+ if addr .Type == kapi .NodeInternalIP {
198
+ nodeIP = addr .Address
199
+ break
200
+ }
201
+ }
202
+ if len (nodeIP ) == 0 {
203
+ glog .Errorf ("Node IP is not set for node %s, skipping %s event, node: %v" , node .Name , eventType , node )
216
204
return
217
205
}
218
206
master .clearInitialNodeNetworkUnavailableCondition (node )
219
207
220
- if oldNodeIP , ok := master .hostSubnetNodeIPs [node .UID ]; ok && (( nodeIP == oldNodeIP ) || isValidNodeIP ( node . Status . Addresses , oldNodeIP ) ) {
208
+ if oldNodeIP , ok := master .hostSubnetNodeIPs [node .UID ]; ok && (nodeIP == oldNodeIP ) {
221
209
return
222
210
}
223
211
// Node status is frequently updated by kubelet, so log only if the above condition is not met
224
212
glog .V (5 ).Infof ("Watch %s event for Node %q" , eventType , node .Name )
225
213
226
- usedNodeIP , err := master .addNode (node .Name , nodeIP , nil , node . Status . Addresses )
214
+ usedNodeIP , err := master .addNode (node .Name , nodeIP , nil )
227
215
if err != nil {
228
216
glog .Errorf ("Error creating subnet for node %s, ip %s: %v" , node .Name , nodeIP , err )
229
217
return
@@ -280,7 +268,7 @@ func (master *OsdnMaster) handleAddOrUpdateSubnet(obj, _ interface{}, eventType
280
268
glog .Errorf ("VNID %s is an invalid value for annotation %s. Annotation will be ignored." , vnid , networkapi .FixedVNIDHostAnnotation )
281
269
}
282
270
}
283
- _ , err = master .addNode (hs .Name , hs .HostIP , hsAnnotations , nil )
271
+ _ , err = master .addNode (hs .Name , hs .HostIP , hsAnnotations )
284
272
if err != nil {
285
273
glog .Errorf ("Error creating subnet for node %s, ip %s: %v" , hs .Name , hs .HostIP , err )
286
274
return
0 commit comments