devopsspiral / KubeLibrary

Kubernetes library for Robot Framework
MIT License
138 stars 37 forks source link

no_proxy/NO_PROXY not working in v0.8.4, and so proxy usage may still be wrong #131

Closed tanguydelignieresaccenture closed 1 year ago

tanguydelignieresaccenture commented 1 year ago

Following v0.8.4, http_proxy/https_proxy/HTTP_PROXY/HTTPS_PROXY are now well managed (#128, #129). But it misses the no_proxy/NO_PROXY retrieval from env var and assignation on Configuration._default.no_proxy

Due to that I'm now facing a regression compared to v0.8.3 as the api server I must connect to is concerned by the no_proxy/NO_PROXY and proxy environnement usage is now enforced in v0.8.4.

My workaround for this case is to drop proxy setting before using KubeLibrary:

unset http_proxy;
unset HTTP_PROXY;
unset https_proxy;
unset HTTPS_PROXY;
m-wcislo commented 1 year ago

Hi, no_proxy should be handled as pointed out in https://github.com/devopsspiral/KubeLibrary/pull/122#issuecomment-1341458691. If setting env is not working this needs to be fixed.

tanguydelignieresaccenture commented 1 year ago

Thanks @m-wcislo, I've seen your comment, but I do not see where in the kubernetes client the no_proxy/NO_PROXY is set by default from env var in configuration.no_proxy for https://github.com/kubernetes-client/python/blob/5a96bbcbe21a552cc1f9cda13e0522fafb0dbac8/kubernetes/client/rest.py#L87 to use it.

m-wcislo commented 1 year ago

Yeah it should be taken by requests library by default if no_proxy is empty in kubeclient . But this need to be verified, could you try setting no_proxy env var, if you didn't try already? The problem with those proxy changes is that i don't have a good way of verifying things, apart from debugging.

tanguydelignieresaccenture commented 1 year ago

Maybe I was not clear, but that's why I opened this issue.

I have http(s)_proxy/HTTP(S)_PROXY/no_proxy/NO_PROXY env var set, and I confirm that in v0.8.4 only http(s)_proxy/HTTP(S)_PROXY are used, not no_proxy/NO_PROXY, which in my case make kubeneretes client calls fail as it is using the proxy for hostnames in my no_proxy/NO_PROXY env var.

In the meantime, In v0.8.3, as proxy env var was not correctly managed at KubeLibrary level, it was working for me (like if no_proxy was correctly used).

Hope it's clearer now.

m-wcislo commented 1 year ago

Ok understood, I will work on the fix.

tanguydelignieresaccenture commented 1 year ago

To summarize:

kubernetes client api calls to api server under anapiserver.otherdomain.com: KO, because proxy settings are used (thanks to #129) but as no_proxy is still not really used interally, it makes "no proxy" calls to be proxied.

m-wcislo commented 1 year ago

Hi, please check out #132 . Let me know if it is possible to test it on your side, if not I will merge it as is (tested on local and ci without real proxy).

MW.

tanguydelignieresaccenture commented 1 year ago

Hi and thanks @m-wcislo. I'll try to test it on my side. I'll let you know quickly.

tanguydelignieresaccenture commented 1 year ago

@m-wcislo I've been able to test it and confirm that #132 fix the issue, making no_proxy/NO_PROXY env var well managed by KubeLibrary.

m-wcislo commented 1 year ago

@tanguydelignieresaccenture thanks for help. Merged.