Skip to content

Commit 40bebb4

Browse files
authored
Small rework of watch context propagation (#882)
1 parent 31abf1b commit 40bebb4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pkg/stores/sqlproxy/proxy_store.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,18 +703,19 @@ func newWatchers() *Watchers {
703703
}
704704

705705
func (s *Store) watch(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest, client dynamic.ResourceInterface) (chan watch.Event, error) {
706-
inf, doneFn, err := s.cacheForWithDeps(apiOp.Context(), apiOp, schema)
706+
ctx := apiOp.Context()
707+
inf, doneFn, err := s.cacheForWithDeps(ctx, apiOp, schema)
707708
if err != nil {
708709
return nil, err
709710
}
710711

711-
ctx, cancel := context.WithCancel(context.Background())
712+
// Cancel watch if the informer is shutdown
713+
ctx, cancel := context.WithCancel(ctx)
712714
go func() {
713715
select {
714716
case <-inf.Context().Done():
715717
cancel()
716-
case <-apiOp.Context().Done():
717-
cancel()
718+
case <-ctx.Done():
718719
}
719720
}()
720721

0 commit comments

Comments
 (0)