Skip to content

Commit

Permalink
Port calico proxy fix (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
joedborg authored and johnsca committed Jul 29, 2020
1 parent 8f45a2e commit ef31705
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion reactive/calico.py
Expand Up @@ -16,7 +16,7 @@
from charms.reactive.helpers import data_changed
from charmhelpers.core import hookenv
from charmhelpers.core.hookenv import log, status_set, resource_get, \
unit_private_ip, is_leader
unit_private_ip, is_leader, env_proxy_settings
from charmhelpers.core.host import service, service_restart
from charmhelpers.core.templating import render

Expand All @@ -40,6 +40,22 @@
CALICO_UPGRADE_DIR = '/opt/calico-upgrade'


def set_http_proxy():
"""
Check if we have any values for
juju_http*_proxy and apply them.
"""
juju_environment = env_proxy_settings()
if juju_environment and not juju_environment.get('disable-juju-proxy'):
upper = ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY']
lower = list(map(str.lower, upper))
keys = upper + lower
for key in keys:
from_juju = juju_environment.get(key, None)
if from_juju:
os.environ[key] = from_juju


@hook('upgrade-charm')
def upgrade_charm():
remove_state('calico.binaries.installed')
Expand All @@ -63,6 +79,7 @@ def pull_calico_node_image():
if not image or os.path.getsize(image) == 0:
status_set('maintenance', 'Pulling calico-node image')
image = hookenv.config('calico-node-image')
set_http_proxy()
CTL.pull(image)
else:
status_set('maintenance', 'Loading calico-node image')
Expand Down

0 comments on commit ef31705

Please sign in to comment.