@@ -190,53 +190,44 @@ func (master *OsdnMaster) deleteNode(nodeName string) error {
190
190
// TODO: make upstream kubelet more flexible with overlays and GCE so this
191
191
// condition doesn't get added for network plugins that don't want it, and then
192
192
// we can remove this function.
193
- func (master * OsdnMaster ) clearInitialNodeNetworkUnavailableCondition (node * kapi.Node ) {
193
+ func (master * OsdnMaster ) clearInitialNodeNetworkUnavailableCondition (origNode * kapi.Node ) {
194
+ // Informer cache should not be mutated, so get a copy of the object
195
+ node := origNode .DeepCopy ()
194
196
knode := node
195
197
cleared := false
196
198
resultErr := retry .RetryOnConflict (retry .DefaultBackoff , func () error {
197
199
var err error
198
200
199
201
if knode != node {
200
- knode , err = master .kClient .Core ().Nodes ().Get (node .ObjectMeta . Name , metav1.GetOptions {})
202
+ knode , err = master .kClient .Core ().Nodes ().Get (node .Name , metav1.GetOptions {})
201
203
if err != nil {
202
204
return err
203
205
}
204
206
}
205
207
206
- // Let caller modify knode's status, then push to api server.
207
- _ , condition := GetNodeCondition (& node .Status , kapi .NodeNetworkUnavailable )
208
- if condition != nil && condition .Status != kapi .ConditionFalse && condition .Reason == "NoRouteCreated" {
209
- condition .Status = kapi .ConditionFalse
210
- condition .Reason = "RouteCreated"
211
- condition .Message = "openshift-sdn cleared kubelet-set NoRouteCreated"
212
- condition .LastTransitionTime = metav1 .Now ()
213
- knode , err = master .kClient .Core ().Nodes ().UpdateStatus (knode )
214
- if err == nil {
215
- cleared = true
208
+ for i := range knode .Status .Conditions {
209
+ if knode .Status .Conditions [i ].Type == kapi .NodeNetworkUnavailable {
210
+ condition := & knode .Status .Conditions [i ]
211
+ if condition .Status != kapi .ConditionFalse && condition .Reason == "NoRouteCreated" {
212
+ condition .Status = kapi .ConditionFalse
213
+ condition .Reason = "RouteCreated"
214
+ condition .Message = "openshift-sdn cleared kubelet-set NoRouteCreated"
215
+ condition .LastTransitionTime = metav1 .Now ()
216
+
217
+ if knode , err = master .kClient .Core ().Nodes ().UpdateStatus (knode ); err == nil {
218
+ cleared = true
219
+ }
220
+ }
221
+ break
216
222
}
217
223
}
218
224
return err
219
225
})
220
226
if resultErr != nil {
221
227
utilruntime .HandleError (fmt .Errorf ("status update failed for local node: %v" , resultErr ))
222
228
} else if cleared {
223
- glog .Infof ("Cleared node NetworkUnavailable/NoRouteCreated condition for %s" , node .ObjectMeta .Name )
224
- }
225
- }
226
-
227
- // TODO remove this and switch to external
228
- // GetNodeCondition extracts the provided condition from the given status and returns that.
229
- // Returns nil and -1 if the condition is not present, and the index of the located condition.
230
- func GetNodeCondition (status * kapi.NodeStatus , conditionType kapi.NodeConditionType ) (int , * kapi.NodeCondition ) {
231
- if status == nil {
232
- return - 1 , nil
233
- }
234
- for i := range status .Conditions {
235
- if status .Conditions [i ].Type == conditionType {
236
- return i , & status .Conditions [i ]
237
- }
229
+ glog .Infof ("Cleared node NetworkUnavailable/NoRouteCreated condition for %s" , node .Name )
238
230
}
239
- return - 1 , nil
240
231
}
241
232
242
233
func (master * OsdnMaster ) watchNodes () {
0 commit comments