mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
Call the right cleanup function
This commit is contained in:
parent
1f580ae898
commit
1ab88c94e8
@ -239,8 +239,6 @@ func (r *Reflector) resyncChan() (<-chan time.Time, func() bool) {
|
|||||||
func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error {
|
func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error {
|
||||||
glog.V(3).Infof("Listing and watching %v from %s", r.expectedType, r.name)
|
glog.V(3).Infof("Listing and watching %v from %s", r.expectedType, r.name)
|
||||||
var resourceVersion string
|
var resourceVersion string
|
||||||
resyncCh, cleanup := r.resyncChan()
|
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Explicitly set "0" as resource version - it's fine for the List()
|
// Explicitly set "0" as resource version - it's fine for the List()
|
||||||
// to be served from cache and potentially be delayed relative to
|
// to be served from cache and potentially be delayed relative to
|
||||||
@ -272,6 +270,10 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error {
|
|||||||
cancelCh := make(chan struct{})
|
cancelCh := make(chan struct{})
|
||||||
defer close(cancelCh)
|
defer close(cancelCh)
|
||||||
go func() {
|
go func() {
|
||||||
|
resyncCh, cleanup := r.resyncChan()
|
||||||
|
defer func() {
|
||||||
|
cleanup() // Call the last one written into cleanup
|
||||||
|
}()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-resyncCh:
|
case <-resyncCh:
|
||||||
|
Loading…
Reference in New Issue
Block a user