canonical / multipass

Multipass orchestrates virtual Ubuntu instances
https://multipass.run
GNU General Public License v3.0
7.54k stars 635 forks source link

Multipass ignores no_proxy when HTTPS_PROXY is set #3445

Open Gmerold opened 3 months ago

Gmerold commented 3 months ago

Describe the bug Hello Team,

I'm trying to create a Multipass VM in the env running behind the proxy. I'm setting the proxy through /etc/environment (I'm setting both lowercase and uppercase variables for proxy). I don't want Multipass to use the proxy though, because the proxy doesn't allow connections to cdimage.ubuntu.com. In order to bypass proxy, I've added .ubuntu.com to the no_proxy and NO_PROXY variables. With this setup, when I try to launch a Multipass instance, I'm getting launch failed: Remote "" is unknown or unreachable. error. In the daemon status I can see that it's trying to use the proxy anyway:

Mar 19 13:08:58 upf-operator multipassd[2381]: Cannot retrieve headers for https://cdimage.ubuntu.com/ubuntu-core/18/stable/current/ubuntu-core-18-amd64.img.xz: Proxy denied connection
Mar 19 13:08:58 upf-operator multipassd[2381]: Using the 'default' storage pool.
Mar 19 13:08:58 upf-operator multipassd[2381]: Cannot retrieve headers for https://cdimage.ubuntu.com/ubuntu-core/22/stable/current/ubuntu-core-22-amd64.img.xz: Proxy denied connection
Mar 19 13:08:58 upf-operator multipassd[2381]: Cannot retrieve headers for https://cdimage.ubuntu.com/ubuntu-core/16/stable/current/ubuntu-core-16-amd64.img.xz: Proxy denied connection
Mar 19 13:08:58 upf-operator multipassd[2381]: Error getting https://cdimage.ubuntu.com/ubuntu-core/appliances/streams/v1/index.json: Proxy denied connection - trying cache.
Mar 19 13:08:58 upf-operator multipassd[2381]: Could not update manifest: failed to download from 'https://cdimage.ubuntu.com/ubuntu-core/appliances/streams/v1/index.json': Error opening https://cdimage.ubuntu.>
Mar 19 13:08:58 upf-operator multipassd[2381]: Cannot retrieve headers for https://cdimage.ubuntu.com/ubuntu-core/20/stable/current/ubuntu-core-20-amd64.img.xz: Proxy denied connection
Mar 19 13:08:58 upf-operator multipassd[2381]: Could not update manifest: failed to download from 'https://cdimage.ubuntu.com/ubuntu-core/16/stable/current/ubuntu-core-16-amd64.img.xz': Proxy denied connection

Proxy envs passed to the process are:

ubuntu@upf-operator:~$ sudo cat /proc/2554/environ | tr '\0' '\n' | grep -i proxy
HTTPS_PROXY=http://squid.internal:3128
no_proxy=localhost,127.0.0.1,.jujucharms.com,.ubuntu.com,upf-operator
NO_PROXY=localhost,127.0.0.1,.jujucharms.com,.ubuntu.com,upf-operator
https_proxy=
http_proxy=
HTTP_PROXY=http://squid.internal:3128

I tried overwriting the variables using drop-in config, but it didn't help. I tried removing proxy config for the snap using snap set system and snap unset system; also without any luck.

Eventually, I was able to make it run by removing the uppercase env variables from my /etc/environment (HTTP_PROXY, HTTPS_PROXY and NO_PROXY). This doesn't seem right tho.

Would be great if someone could look into it. Please let me know in case any additional info is needed.

BR, Bartek

To Reproduce How, and what happened?

  1. Setup env as described above
  2. multipass launch 22.04

Expected behavior What did you expect to happen?

Logs Relevant logs available in the description

Additional info

townsend2010 commented 3 months ago

Hi @Gmerold!

Thanks for this bug report! I'm curious what your /etc/environment looked like when you have the upper-case http{s} proxies set and what it looks like when this does work. Thanks!

Gmerold commented 3 months ago

Hi @townsend2010!

Sure, here's the original version (not working):

ubuntu@telco-github-runner-1:~$ cat /etc/environment 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
HTTP_PROXY=http://squid.internal:3128
HTTPS_PROXY=http://squid.internal:3128
NO_PROXY="localhost,127.0.0.1,.jujucharms.com,.ubuntu.com,upf-operator"
http_proxy=http://squid.internal:3128
https_proxy=http://squid.internal:3128
no_proxy="localhost,127.0.0.1,.jujucharms.com,.ubuntu.com,upf-operator"

Then I just removed all 3 uppercase proxy variables.

townsend2010 commented 3 months ago

Hey @Gmerold!

Thanks for posting that. I think I might have found the issue and it shouldn't be too hard to fix.