Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy settings update #33

Merged
merged 13 commits into from
Oct 2, 2024
Merged

Proxy settings update #33

merged 13 commits into from
Oct 2, 2024

Conversation

matthew-hagemann
Copy link
Collaborator

@matthew-hagemann matthew-hagemann commented Sep 25, 2024

The Docker snap did not have an easy way to enable us to pass proxy settings to the docker daemon before starting. This prevented us from having a simple lifecycle to manage operating the charm from behind a proxy.

This PR aims to:

  • Install docker via a snap, not a deb (snap does not read from /etc/docker/daemon.json)
  • Remove unused juju library code now that we have swapped from Snaps to debs
  • Write proxy settings to /etc/docker/daemon.json before docker daemon is started

@matthew-hagemann matthew-hagemann marked this pull request as draft September 25, 2024 15:07
@matthew-hagemann matthew-hagemann force-pushed the proxy-settings-update branch 2 times, most recently from 844f5c1 to 70e470e Compare September 27, 2024 14:11
@matthew-hagemann matthew-hagemann marked this pull request as ready for review September 30, 2024 06:55
src/charm.py Outdated
if proxy_url:
os.environ["HTTP_PROXY"] = proxy_url
os.environ["HTTPS_PROXY"] = proxy_url
http_proxy_env = os.environ.get("JUJU_CHARM_HTTP_PROXY")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get supports a default value if the key is missing so you could combine these lines with the ones on 263, 264 as:

http_proxy_str = os.environ.get("JUJU_CHARM_HTTP_PROXY", "")

src/container_runner.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@sminez sminez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good 👍

just a couple of changes as called out in comments

@@ -18,6 +18,32 @@
DOCKER_DAEMON_CONFIG_PATH = Path("/etc/docker/daemon.json")


def _try_set_proxy_settings():
"""If Juju proxy environment variables are present, set procy environment variables and write Docker proxy settings to /etc/docker/daemon.json."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "procy"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks! I'll fix that before I merge 🙂

@sminez sminez self-requested a review October 2, 2024 12:24
Copy link
Collaborator

@sminez sminez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a typo in one of the doc comments but that's not really a blocker for merging

@sminez sminez self-requested a review October 2, 2024 12:25
@matthew-hagemann matthew-hagemann merged commit fbacf92 into main Oct 2, 2024
5 checks passed
@matthew-hagemann matthew-hagemann deleted the proxy-settings-update branch October 2, 2024 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants