mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Don't double-close the channel when etcd returns an error.
This commit is contained in:
parent
a10ac51224
commit
229b8fca2a
@ -105,11 +105,10 @@ func (rm *ReplicationManager) watchControllers() {
|
|||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
defer util.HandleCrash()
|
defer util.HandleCrash()
|
||||||
defer func() {
|
|
||||||
close(watchChannel)
|
|
||||||
}()
|
|
||||||
_, err := rm.etcdClient.Watch("/registry/controllers", 0, true, watchChannel, stop)
|
_, err := rm.etcdClient.Watch("/registry/controllers", 0, true, watchChannel, stop)
|
||||||
if err != etcd.ErrWatchStoppedByUser {
|
if err == etcd.ErrWatchStoppedByUser {
|
||||||
|
close(watchChannel)
|
||||||
|
} else {
|
||||||
glog.Errorf("etcd.Watch stopped unexpectedly: %v (%#v)", err, err)
|
glog.Errorf("etcd.Watch stopped unexpectedly: %v (%#v)", err, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -135,6 +135,8 @@ func (f *FakeEtcdClient) Watch(prefix string, waitIndex uint64, recursive bool,
|
|||||||
case <-stop:
|
case <-stop:
|
||||||
return nil, etcd.ErrWatchStoppedByUser
|
return nil, etcd.ErrWatchStoppedByUser
|
||||||
case err := <-injectedError:
|
case err := <-injectedError:
|
||||||
|
// Emulate etcd's behavior.
|
||||||
|
close(receiver)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Never get here.
|
// Never get here.
|
||||||
|
Loading…
Reference in New Issue
Block a user