Skip to content

feat: add support for HTTP, HTTPS proxy - #2748

Merged
samalba merged 3 commits into
dagger:mainfrom
samalba:feat-proxy-support
Jul 7, 2022
Merged

samalba merged 3 commits into
dagger:mainfrom
samalba:feat-proxy-support

Conversation

@samalba

@samalba samalba commented Jul 5, 2022

Copy link
Copy Markdown
Contributor

Adds support for HTTP and HTTPS Proxy. It translates the right env vars to LLB Run options.

@samalba
samalba requested a review from a team as a code owner July 5, 2022 22:53
@samalba
samalba requested review from aluzzardi and sipsma July 5, 2022 22:53
@juaruipav

Copy link
Copy Markdown

I know I'm not in the reviewers list, but I was one of the affected users.

Just wanted to confirm that the content of this PR solves the issue of using dagger behind a corporative proxy. Setting the https_proxy and http_proxy properly makes it work. Tested with the todoapp example + proxy.

Many thanks to @samalba for the fix and @grouville for prioritizing this issue in the backlog.

Regards,
JJ

@jlongtine jlongtine left a comment

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.

LGTM! Do we want to add any tests for this?

@samalba

samalba commented Jul 6, 2022 •

Copy link
Copy Markdown
Contributor Author

LGTM! Do we want to add any tests for this?

I thought about it, but not sure how to: 1/ spin up a proxy automatically from the test suite and 2/ ensure in the tests that all connections go through it. If you have an idea to do this easily, let me know.

@dolanor

dolanor commented Jul 6, 2022

Copy link
Copy Markdown
Contributor

There is this from the stdlib, but it doesn't handle the FTP case: https://pkg.go.dev/net/http#ProxyFromEnvironment
On the testing side, I'm trying something.

@samalba

samalba commented Jul 6, 2022

Copy link
Copy Markdown
Contributor Author

@aluzzardi shared an idea: set an invalid proxy URL and verify that a curl fails in a task. That's not perfect, but at least it will guarantee that the connection goes through the proxy url.

@dolanor

dolanor commented Jul 7, 2022

Copy link
Copy Markdown
Contributor

I've created a test in my fork: 67efa24
But somehow, the buildkit pull of the "ubuntu:18.04" doesn't pass by the proxy (which should have failed since it is the wrong proxy port)
I guess I had the same idea to make it fail ^^'

@dolanor

dolanor commented Jul 7, 2022

Copy link
Copy Markdown
Contributor

So it seems that buildkit ignore them in the case of image download through docker.#Pull.
But a curl inside of an action would work.

@samalba

samalba commented Jul 7, 2022

Copy link
Copy Markdown
Contributor Author

So it seems that buildkit ignore them in the case of image download through docker.#Pull. But a curl inside of an action would work.

I think it's expected, given that docker.#Pull is aliased to core.#Pull which translates to: LLB directly: https://github.com/dagger/dagger/blob/0fffdc223bb9d6c103538ef2fbbf5ed6fb5f3950/plan/task/pull.go

And this PR simply adds a RunOption so only exec will take the proxy into account.

We should: 1/ add a simple test for this (I can do it), 2/ look for a way to support the proxy for core.#Pull and core.#Push (hopefully there is one!)

@marcosnils marcosnils left a comment

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.

LGTM

Comment thread plan/task/exec.go Resolved
@samalba
samalba force-pushed the feat-proxy-support branch from 353c91a to df7ebe1 Compare July 7, 2022 01:31
@samalba
samalba merged commit a12e9f2 into dagger:main Jul 7, 2022
@samalba
samalba deleted the feat-proxy-support branch July 7, 2022 01:41
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.

✨ Dagger: set buildkit network proxy Dagger doesn't work behind a corporate proxy

5 participants