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

Write proxy env files for new proxy settings #11713

Closed
wants to merge 2 commits into from
Closed

Write proxy env files for new proxy settings #11713

wants to merge 2 commits into from

Conversation

dshcherb
Copy link

Description of change

Write /etc/juju-proxy.conf and /etc/juju-proxy-systemd.conf when
juju-* proxy settings are set, not only when legacy proxy settings are
set.

QA steps

juju model-config juju-http-proxy=http://192.0.2.1 juju-https-proxy=http://192.0.2.2 juju-no-proxy=192.0.2.0/24
juju deploy cs:ubuntu
juju run --unit ubuntu/0 'grep -i proxy /etc/juju-proxy.conf'
juju run --unit ubuntu/0 'grep -i proxy /etc/juju-proxy-systemd.conf'
# Validate the settings according to the model-config.

Documentation changes

None, maybe worth a release note.

Bug reference

https://bugs.launchpad.net/juju/+bug/1883656

/etc/juju-proxy.conf and /etc/juju-proxy-systemd.conf are only written
for legacy proxy settings. This change adds the same behavior for
the new-style proxy settings.

Note: Those files can be relied upon in charms or scripts they render
but do not by themselves modify the environment unless explicit action
is taken by a charm author.

LP: #1883656
@jujubot
Copy link
Collaborator

jujubot commented Jun 16, 2020

Can one of the admins verify this patch?

4 similar comments
@jujubot
Copy link
Collaborator

jujubot commented Jun 16, 2020

Can one of the admins verify this patch?

@jujubot
Copy link
Collaborator

jujubot commented Jun 16, 2020

Can one of the admins verify this patch?

@jujubot
Copy link
Collaborator

jujubot commented Jun 16, 2020

Can one of the admins verify this patch?

@jujubot
Copy link
Collaborator

jujubot commented Jun 16, 2020

Can one of the admins verify this patch?

Comment on lines 330 to 331
exportedProxyEnv := proxySettings.AsScriptEnvironment()
w.conf.AddScripts(strings.Split(exportedProxyEnv, "\n")...)
Copy link
Member

Choose a reason for hiding this comment

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

We only want to do this for legacy settings I think, right?

Copy link
Author

Choose a reason for hiding this comment

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

If I am not mistaken, this affects the cloud-init shell only (runcmd) on first boot.

		exportedProxyEnv := proxySettings.AsScriptEnvironment()
		w.conf.AddScripts(strings.Split(exportedProxyEnv, "\n")...)

About this one I am not sure since there are potential preruncmd and postruncmd commands added by a user via model-config.

If we follow the same principle here, I think we could:

  • expose JUJU_CHARM_{HTTP, HTTPS, NO}_PROXY in the cloud-init shell environment and document that those should be used explicitly;
  • tell users that /etc/juju-proxy.conf can be sourced in any custom postruncmds.
    • wouldn't work on Windows since we don't write a file there.

cloudconfig/userdatacfg_unix.go Outdated Show resolved Hide resolved
Comment on lines 325 to 328
if w.icfg.JujuProxySettings.HasProxySet() {
proxySettings = w.icfg.JujuProxySettings
} else if w.icfg.LegacyProxySettings.HasProxySet() {
proxySettings = w.icfg.LegacyProxySettings
Copy link
Member

Choose a reason for hiding this comment

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

Need to cater for the case where neither juju nor legacy settings are set

Copy link
Author

Choose a reason for hiding this comment

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

If none are set we can just rely on empty strings in the proxy.Settings struct.

https://github.com/juju/proxy/blob/master/proxy.go#L58-L64

I think I need to have a unit test for that though.

* only write to /etc/profile.d/juju-proxy.sh if legacy settings are used
* modify the proxyupdater behavior as well as the userdata generator.
@dshcherb
Copy link
Author

I have updated the PR (ca712e5), although further updates are required to unit tests for the proxyupdater.

Before adding those, I would like to have a further discussion about:

  • whether writing to /etc/juju-proxy.conf is acceptable
  • currently writing to a file on Windows isn't present.

@dshcherb dshcherb marked this pull request as draft June 19, 2020 19:08
@dshcherb
Copy link
Author

I converted this to a draft and will likely close it given the above comment and the fact that we cat steal proxy settings from juju-run:

https://bugs.launchpad.net/charm-glance-simplestreams-sync/+bug/1883656/comments/9

@pengale pengale closed this Dec 17, 2020
@pengale
Copy link
Contributor

pengale commented Dec 17, 2020

Closing to clean up hanging PRs. Feel free to reopen if this is still fresh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants