Skip to content

shim: unix->tcp API proxy - #3706

Merged
aluzzardi merged 2 commits into
dagger:mainfrom
aluzzardi:shim-api-proxy
Nov 7, 2022
Merged

aluzzardi merged 2 commits into
dagger:mainfrom
aluzzardi:shim-api-proxy

Conversation

@aluzzardi

@aluzzardi aluzzardi commented Nov 5, 2022 •

Copy link
Copy Markdown
Contributor

Will automatically rewrite a DAGGER_HOST from unix:// to http://

This removes the need for SDKs to implement unix socket support.

/cc @helderco @slumbering @TomChv

@aluzzardi
aluzzardi requested review from sipsma and vito November 5, 2022 02:39
Comment thread core/shim/cmd/main.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Until we build an engine image w/ CNI support all exec ops are in the same network namespace so I think this will create conflicts?

Fortunately it will soon be easy to include CNI support with the engine image!

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.

Right!

Do I try some random port with retry logic, or leave this feature be?

I'm trying to get python tests running in dagger but apparently there's no easy way for Python to communicate over unix sockets.

Currently for extensions, as far as I can see, it's pythoruntime.go that uses a socat to do the proxying.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you listen on localhost:0 a random open port will be chosen for you, which you can then retrieve from the listener object with the right incantation (just learned this earlier today here).

So I think that'd work here; listen on random port, set env var based on that.

If someone is trying to run 10,000 shims on their box I guess port contention could matter, but I look forward to that bug report!

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.

Will do!

Also -- this is only enabled when using the (semi) internal nesting flag on exec.

Proxy kicks off only if DAGGER_HOST is set

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.

Done!

Comment thread sdk/go/internal/engineconn/http/http.go Outdated

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.

/cc @vito

There's some overlap with #3671

I picked http because that's what the Python SDK currently requires -- but we can update that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HTTP works too 👍

I went with TCP early on when it wasn't clear whether I'd need to switch everything to gRPC, but now that it's gRPC-over-HTTP it doesn't really matter. I can just rebase on this. Besides, the TCP connection was just for local testing by hand.

@aluzzardi
aluzzardi force-pushed the shim-api-proxy branch 2 times, most recently from c5d017b to 5025db2 Compare November 7, 2022 18:48
Andrea Luzzardi added 2 commits November 7, 2022 12:26
Will automatically rewrite a DAGGER_HOST from `unix://` to `http://`

This removes the need for SDKs to implement unix socket support.

Signed-off-by: Andrea Luzzardi <[email protected]>
Signed-off-by: Andrea Luzzardi <[email protected]>
@aluzzardi
aluzzardi merged commit 74aab6d into dagger:main Nov 7, 2022
@aluzzardi
aluzzardi deleted the shim-api-proxy branch November 7, 2022 22:20
@helderco helderco added area/engine About dagger core engine sdk/go and removed area/sdk labels Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/engine About dagger core engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants