Skip to content

konnectivity-client: extract newSingleStreamTunnel helper#822

Open
ipochi wants to merge 1 commit into
kubernetes-sigs:masterfrom
kinvolk:imran/extract-newSingleStreamTunnel-helper
Open

konnectivity-client: extract newSingleStreamTunnel helper#822
ipochi wants to merge 1 commit into
kubernetes-sigs:masterfrom
kinvolk:imran/extract-newSingleStreamTunnel-helper

Conversation

@ipochi
Copy link
Copy Markdown
Contributor

@ipochi ipochi commented Apr 28, 2026

This is a pure refactor with no behavioral change. Factor Proxy() stream setup and serve() goroutine launch out of
CreateSingleUseGrpcTunnelWithContext into an internal newSingleStreamTunnel helper that takes a ProxyServiceClient and a closeFn.

The helper invokes closeFn from the serve() goroutine on exit via the clientConn interface instead of unconditionally calling grpcConn.Close(). For the existing single-use path, closeFn is c.Close, preserving today's behavior: tunnelCtx still bounds both Proxy() establishment and the serve() goroutine, and the *grpc.ClientConn is still closed when serve() returns.

This separation prepares for a future reusable tunnel API that will share one *grpc.ClientConn across many per-dial streams. In that path, closeFn will cancel only the per-dial stream context rather than closing the shared conn. No such caller is added in this commit.

Add a closerFunc adapter so a func() error satisfies the existing clientConn interface without introducing a new abstraction.

This is a pure refactor with no behavioral change. Factor Proxy()
stream setup and serve() goroutine launch out of
CreateSingleUseGrpcTunnelWithContext into an internal
newSingleStreamTunnel helper that takes a ProxyServiceClient and a
closeFn.

The helper invokes closeFn from the serve() goroutine on exit via the
clientConn interface instead of unconditionally calling grpcConn.Close().
For the existing single-use path, closeFn is c.Close, preserving today's
behavior: tunnelCtx still bounds both Proxy() establishment and the
serve() goroutine, and the *grpc.ClientConn is still closed when serve()
returns.

This separation prepares for a future reusable tunnel API that will share
one *grpc.ClientConn across many per-dial streams. In that path, closeFn
will cancel only the per-dial stream context rather than closing the
shared conn. No such caller is added in this commit.

Add a closerFunc adapter so a func() error satisfies the existing
clientConn interface without introducing a new abstraction.

Signed-off-by: Imran Pochi <imranpochi@microsoft.com>
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 28, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ipochi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 28, 2026
@cheftako
Copy link
Copy Markdown
Contributor

cheftako commented May 1, 2026

@ipochi I fixed a bunch of problems on CI. I think if you rebase on the latest this should go better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants