Commit deb101a1 authored by Eric Tune's avatar Eric Tune

Handle error from watch.

A watch of the API can return an api.Status rather than the watched obejct type. This code didn't handle that. Tested with services e2e test (in conjunction with other PR).
parent ffcbe2fa
...@@ -112,7 +112,22 @@ func handleServicesWatch(resourceVersion *string, ch <-chan watch.Event, updates ...@@ -112,7 +112,22 @@ func handleServicesWatch(resourceVersion *string, ch <-chan watch.Event, updates
return return
} }
service := event.Object.(*api.Service) if event.Object == nil {
glog.Errorf("Got nil over WatchServices channel")
return
}
var service *api.Service
switch obj := event.Object.(type) {
case *api.Service:
service = obj
case *api.Status:
glog.Warningf("Got error status on WatchServices channel: %+v", obj)
return
default:
glog.Errorf("Got unexpected object over WatchServices channel: %+v", obj)
return
}
*resourceVersion = service.ResourceVersion *resourceVersion = service.ResourceVersion
switch event.Type { switch event.Type {
...@@ -161,7 +176,21 @@ func handleEndpointsWatch(resourceVersion *string, ch <-chan watch.Event, update ...@@ -161,7 +176,21 @@ func handleEndpointsWatch(resourceVersion *string, ch <-chan watch.Event, update
return return
} }
endpoints := event.Object.(*api.Endpoints) if event.Object == nil {
glog.Errorf("Got nil over WatchEndpoints channel")
return
}
var endpoints *api.Endpoints
switch obj := event.Object.(type) {
case *api.Endpoints:
endpoints = obj
case *api.Status:
glog.Warningf("Got error status on WatchEndpoints channel: %+v", obj)
return
default:
glog.Errorf("Got unexpected object over WatchEndpoints channel: %+v", obj)
return
}
*resourceVersion = endpoints.ResourceVersion *resourceVersion = endpoints.ResourceVersion
switch event.Type { switch event.Type {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment