mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +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 {
|
||||
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) {
|
||||
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))
|
||||
if match {
|
||||
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.
|
||||
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 {
|
||||
pod, ok := obj.(*api.Pod)
|
||||
if !ok {
|
||||
glog.Errorf("Unexpected object during pod watch: %#v", obj)
|
||||
return false
|
||||
switch t := obj.(type) {
|
||||
case *api.Pod:
|
||||
return filter(t)
|
||||
default:
|
||||
// Must be an error
|
||||
return true
|
||||
}
|
||||
return filter(pod)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user