From b2f581c82a4c02017a45c8bb9968f870f7d81c2f Mon Sep 17 00:00:00 2001 From: rmweir Date: Tue, 9 Jun 2020 14:02:14 -0700 Subject: [PATCH] Change context in realWatch Using the watch is ultimately share and should use the store's context. Using the requests context may cause the watch to end too early. --- store/proxy/proxy_store.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/store/proxy/proxy_store.go b/store/proxy/proxy_store.go index 545b429d..80fbea89 100644 --- a/store/proxy/proxy_store.go +++ b/store/proxy/proxy_store.go @@ -296,7 +296,7 @@ func (s *Store) realWatch(apiContext *types.APIContext, schema *types.Schema, op ResourceVersion: "0", }, metav1.ParameterCodec) - body, err := req.Stream(apiContext.Request.Context()) + body, err := req.Stream(s.close) if err != nil { return nil, err } @@ -305,7 +305,7 @@ func (s *Store) realWatch(apiContext *types.APIContext, schema *types.Schema, op decoder := streaming.NewDecoder(framer, &unstructuredDecoder{}) watcher := watch.NewStreamWatcher(restclientwatch.NewDecoder(decoder, &unstructuredDecoder{}), &errorReporter{}) - watchingContext, cancelWatchingContext := context.WithCancel(apiContext.Request.Context()) + watchingContext, cancelWatchingContext := context.WithCancel(s.close) go func() { <-watchingContext.Done() logrus.Tracef("stopping watcher for %s", schema.ID)