devpod icon indicating copy to clipboard operation
devpod copied to clipboard

Restore http features like proxy handling

Open gbonnefille opened this issue 1 year ago • 5 comments

Fixes #365

gbonnefille avatar Jun 29 '23 09:06 gbonnefille

Unable to test on my side. Any feedback from other user is welcome.

gbonnefille avatar Jun 29 '23 09:06 gbonnefille

Humh... I understood that there are many proxy related problems.

The client itself should be able to pass the proxy. I think this is solved by this PR.

But the agent is also responsible of downloading the openvscode archive. Thus, the whole Container should be configured with HTTP proxy settings. This can be achieve by adding proxy settings in https://github.com/loft-sh/devpod/blob/43eac112842697be4882269bf0b7a7866401890a/pkg/driver/kubernetes/run.go#L138

But we have one major issue: we can imagine that the client need a proxy (because inside the corporate network) and the kubernetes cluster does not requires, as it is running outside (managed kubernetes? AWS, Google...?)

One solution can be to add settings in the provider config directly: this way, one can adjust the settings to the effective situation.

Another solution can be to change the architecture: the openvscode (and other) are no more downloaded by the agent, but by the client itself and then, injected into the container. This can be much more longer, but we do not have to configure proxy settings onto the container.

@89luca89 any thought?

gbonnefille avatar Jun 29 '23 12:06 gbonnefille

@gbonnefille thanks a lot for your PR! Looks good to me, but since we essentially reuse the same piece of code multiple times there, would be good to create a function and then just call that so we have it all in a central place

FabianKramm avatar Jun 29 '23 17:06 FabianKramm

@gbonnefille thanks a lot for your PR! Looks good to me, but since we essentially reuse the same piece of code multiple times there, would be good to create a function and then just call that so we have it all in a central place

Sure! But it is too great decision for a casual contributor. Where is it nice to factorize? What effect on Go pakages?

I would prefer you do this refactoring. Or at least, give me the design you want.

gbonnefille avatar Jun 29 '23 17:06 gbonnefille

Just put a function like this into package pkg/http:

func GetClient() *http.Client {
	customTransport := http.DefaultTransport.(*http.Transport).Clone()
	customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
	return &http.Client{Transport: customTransport}
}

Then call that from everywhere

FabianKramm avatar Jun 30 '23 07:06 FabianKramm

Deploy Preview for devpod-docs canceled.

Name Link
Latest commit 70d8060b2268755f8e15e228f67477f430b81d0d
Latest deploy log https://app.netlify.com/sites/devpod-docs/deploys/64a53594ee67440008aaddec

netlify[bot] avatar Jul 05 '23 09:07 netlify[bot]

@FabianKramm I fear only half of the problem is solved. As pointed previously, the agent is also doing HTTP requests.

Should we create a new issue for that?

gbonnefille avatar Jul 05 '23 10:07 gbonnefille