canonical / layer-basic

Base layer for building charms using the reactive pattern
Apache License 2.0
11 stars 43 forks source link

pip fails behind a proxy #154

Open auria opened 4 years ago

auria commented 4 years ago

layer-basic fails to install python_packages (see [1]) behind a proxy because pip doesn't have information to use said proxy (even if juju-https-proxy model parameter is configured).

I think proxy env vars should be parsed (see [4] for charm-helpers approach) and HTTPS_PROXY value used in $HOME/.config/pip/pip.conf (see [2] and [3]).

[global] proxy = http://proxy_host:proxy_port/

I don't know if the expected approach is to use exec.d but I think it should be transparent for a user of a charm that is trying to deploy it on a restricted environment.

Thank you.

1, https://github.com/juju-solutions/layer-basic/blob/0ee8abaaed92be45ca63740d740be588d3783b1a/lib/charms/layer/basic.py#L121

  1. https://pip.pypa.io/en/stable/user_guide/#using-a-proxy-server
  2. https://pip.pypa.io/en/stable/user_guide/#config-file
  3. https://github.com/juju/charm-helpers/blob/3b98ce58c049e00127313fc10001be33d2776953/charmhelpers/core/hookenv.py#L1525
fnordahl commented 4 years ago

The solution is to add dependencies to the charm wheelhouse.txt instead of using python_packages in layer.yaml.

Using the wheelhouse.txt will make charm-tools download all the dependencies on charm build which is then distributed with the charm so that layer-basic can install the required dependencies from it at deploy time.

Some charms have had to temporarily use python_packages to work around a issue which should be fixed by merging #156