mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #1447 from lavalamp/fix
Fix type cast problems now that watch can pass errors
This commit is contained in:
commit
eea0265598
@ -150,8 +150,14 @@ func (rs *REST) Watch(label, field labels.Selector, resourceVersion uint64) (wat
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// TODO(lavalamp): remove watch.Filter, which is broken. Implement consistent way of filtering.
|
||||||
|
// TODO(lavalamp): this watch method needs a test.
|
||||||
return watch.Filter(incoming, func(e watch.Event) (watch.Event, bool) {
|
return watch.Filter(incoming, func(e watch.Event) (watch.Event, bool) {
|
||||||
repController := e.Object.(*api.ReplicationController)
|
repController, ok := e.Object.(*api.ReplicationController)
|
||||||
|
if !ok {
|
||||||
|
// must be an error event-- pass it on
|
||||||
|
return e, true
|
||||||
|
}
|
||||||
match := label.Matches(labels.Set(repController.Labels))
|
match := label.Matches(labels.Set(repController.Labels))
|
||||||
if match {
|
if match {
|
||||||
rs.fillCurrentState(repController)
|
rs.fillCurrentState(repController)
|
||||||
|
@ -85,12 +85,13 @@ func (r *Registry) ListPodsPredicate(filter func(*api.Pod) bool) (*api.PodList,
|
|||||||
// WatchPods begins watching for new, changed, or deleted pods.
|
// WatchPods begins watching for new, changed, or deleted pods.
|
||||||
func (r *Registry) WatchPods(resourceVersion uint64, filter func(*api.Pod) bool) (watch.Interface, error) {
|
func (r *Registry) WatchPods(resourceVersion uint64, filter func(*api.Pod) bool) (watch.Interface, error) {
|
||||||
return r.WatchList("/registry/pods", resourceVersion, func(obj runtime.Object) bool {
|
return r.WatchList("/registry/pods", resourceVersion, func(obj runtime.Object) bool {
|
||||||
pod, ok := obj.(*api.Pod)
|
switch t := obj.(type) {
|
||||||
if !ok {
|
case *api.Pod:
|
||||||
glog.Errorf("Unexpected object during pod watch: %#v", obj)
|
return filter(t)
|
||||||
return false
|
default:
|
||||||
|
// Must be an error
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
return filter(pod)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user