Skip to content

feat(internal/cmd): Add 'instance tunnel' command#248

Open
craciunoiuc wants to merge 1 commit into
prod-stagingfrom
craciunoiuc/add-instance-tunnel
Open

feat(internal/cmd): Add 'instance tunnel' command#248
craciunoiuc wants to merge 1 commit into
prod-stagingfrom
craciunoiuc/add-instance-tunnel

Conversation

@craciunoiuc

@craciunoiuc craciunoiuc commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Nodes need this option --net-internal-traffic=vm in order to test it.

tunnel-3uhz1 │ [    0.141932] ERR:  [apptunlr] Target remote not in the same subnet.
tunnel-3uhz1 │ [    0.142826] ERR:  [apptunlr] Failed to hook TCP2TCP.

The Tunlr also needs updating to remove the check for inter-vm comms.
Done.

TODO: Update tests when platform is stable.

Blocked on: https://github.com/unikraft-cloud/platform/pull/705
Closes: TOOL-714

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new unikraft instance tunnel subcommand intended to forward a local port to a non-public instance via an intermediate TLS tunnel service, enabling testing scenarios that require internal VM traffic.

Changes:

  • Adds InstancesTunnelCmd to the instances command group.
  • Implements target parsing, instance/IP resolution, tunnel-proxy instance creation, and local-to-remote relaying over TLS.
  • Adds control-channel heartbeats to keep the tunnel service connection alive.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch 2 times, most recently from 49d2539 to 8ae136d Compare April 7, 2026 09:26
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/tunnel/tunnel.go
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
@craciunoiuc

Copy link
Copy Markdown
Contributor Author

I need to fix these + do one more pass so no rush

@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch from 5e8f3e5 to b8e8437 Compare April 7, 2026 19:02
@craciunoiuc craciunoiuc requested a review from jedevc April 7, 2026 19:05
@craciunoiuc

Copy link
Copy Markdown
Contributor Author

Should be as decent as it gets, definitely an upgrade compared to kraftkit

@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch from b8e8437 to a5b1451 Compare April 9, 2026 14:17
@craciunoiuc

Copy link
Copy Markdown
Contributor Author

Have to rebase the code and to generate tests on Monday.

@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch 2 times, most recently from dcaf1a6 to c7622e6 Compare April 20, 2026 09:02

@jedevc jedevc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a rebase, and to get the tests passing 🎉

Comment thread cmd/unikraft/instances_test.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/tunnel/relay.go Outdated
Comment thread internal/tunnel/relay.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
@craciunoiuc

Copy link
Copy Markdown
Contributor Author

I'll rebase and fix afterwards

@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch 3 times, most recently from ccbfb69 to 1aa3b6d Compare May 5, 2026 17:24
@craciunoiuc

Copy link
Copy Markdown
Contributor Author

once you agree with the changes, I will fixup the fixup, and regenerate the tests once more

I am pretty sure I covered all your requests. It now even has multi-metro support

The API is now: New -> Run -> Start -> Terminate Lemme know if you want me to reword

I tested that the usual + new stuff still works

@craciunoiuc craciunoiuc requested a review from jedevc May 5, 2026 17:25
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch from 1aa3b6d to ad763de Compare May 25, 2026 14:44
@craciunoiuc craciunoiuc marked this pull request as draft May 25, 2026 14:44
@craciunoiuc craciunoiuc requested a review from Copilot May 25, 2026 14:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread internal/integration/env.go
Comment thread internal/integration/env.go Outdated
Comment thread internal/cmd/instances.go
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch from ad763de to 0f148f9 Compare May 29, 2026 07:46
@craciunoiuc craciunoiuc marked this pull request as ready for review May 29, 2026 07:55
Comment thread cmd/unikraft/integration/instance_test.go Outdated
Comment thread cmd/unikraft/integration/instance_test.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go
Comment on lines +215 to +221
// NOTE(craciunoiuc): if the same instance name appears in multiple metros
// (no metro prefix given), the last-seen result wins. Users should include
// a metro prefix to disambiguate (e.g. fra/my-instance:8080).
infoByDisplay := make(map[string]instanceInfo, len(resolved))
for _, r := range resolved {
infoByDisplay[r.ref.Display] = r.info
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, but maybe we should have a helper CollectRefsMap or something.

Then we could use the same logic for logs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, leaving like this. Feel free to open a linear issue and we can do in a separate PR 😳

Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/cmd/instances.go Outdated
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch from 0f148f9 to 33c9044 Compare June 4, 2026 14:59
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch from 33c9044 to f95426d Compare July 2, 2026 12:53
Allows for tunelling when inter-vm  communication is enabled
on the box. Requires at least 1 free instance space for the
tunelling instance.

Also adds support for running background tasks in tests.
This enables tunelling in parallel with the curl request.

Signed-off-by: Cezar Craciunoiu <[email protected]>
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch from f95426d to d759875 Compare July 2, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants