mirror of
https://github.com/rancher/norman.git
synced 2025-09-02 07:44:51 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user