Skip to content

Commit

Permalink
use less agressive patch to fix nsmgr
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com>
  • Loading branch information
denis-tingaikin committed Sep 3, 2024
1 parent 2e058bf commit d9269e1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
14 changes: 12 additions & 2 deletions pkg/registry/common/dial/ns_client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-2022 Cisco and/or its affiliates.
// Copyright (c) 2021-2024 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -149,8 +149,18 @@ func (c *dialNSClient) Find(ctx context.Context, in *registry.NetworkServiceQuer
return nil, err
}

var stopContext, stopCancel = context.WithTimeout(resp.Context(), time.Minute/4)
if in.Watch {
stopContext = resp.Context()
}
cleanupFn = func() {
stopCancel()
clientconn.Delete(ctx)
_ = di.Close()
}

go func() {
<-resp.Context().Done()
<-stopContext.Done()
cleanupFn()
}()

Expand Down
12 changes: 10 additions & 2 deletions pkg/registry/common/dial/nse_client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-2023 Cisco and/or its affiliates.
// Copyright (c) 2021-2024 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -155,8 +155,16 @@ func (c *dialNSEClient) Find(ctx context.Context, in *registry.NetworkServiceEnd
return nil, err
}

var stopContext, stopCancel = context.WithTimeout(resp.Context(), time.Minute/4)

cleanupFn = func() {
stopCancel()
clientconn.Delete(ctx)
_ = di.Close()
}

go func() {
<-resp.Context().Done()
<-stopContext.Done()
cleanupFn()
}()

Expand Down

0 comments on commit d9269e1

Please sign in to comment.