Merge lp:~michael.nelson/charms/trusty/landscape-client/fix-juju2-env-uuiD into lp:charms/trusty/landscape-client

Proposed by Michael Nelson
Status: Needs review
Proposed branch: lp:~michael.nelson/charms/trusty/landscape-client/fix-juju2-env-uuiD
Merge into: lp:charms/trusty/landscape-client
Diff against target: 20 lines (+7/-1)
1 file modified
hooks/hooks.py (+7/-1)
To merge this branch: bzr merge lp:~michael.nelson/charms/trusty/landscape-client/fix-juju2-env-uuiD
Reviewer Review Type Date Requested Status
Landscape Pending
Review via email: mp+316415@code.launchpad.net

Commit message

Allow the juju2 JUJU_MODEL_UUID to be used if the (juju1) JUJU_ENV_UUID is not available.

Description of the change

AFAICT, the landscape-client charm depends on the juju 1.x env variable JUJU_ENV_UUID: http://paste.ubuntu.com/23938838/

I checked the juju source to verify the env var name: http://paste.ubuntu.com/23939030/

To fix my existing units, I had to upgrade-charm and then:

$ juju run --application landscape hooks/container-relation-joined

One thing concerns me, and that is that PaulGear mentioned he checked a juju2 environment which is using the landscape-client charm and it was fine (without this patch).

To post a comment you must log in.
Revision history for this message
Francis Ginther (fginther) wrote :

This fix is already in https://code.launchpad.net/~landscape/landscape-client-charm/trunk which supports both trusty and xenial. It is also in the lastest charm store revisions:

cs:trusty/landscape-client-14
cs:xenial/landscape-client-1

The MP which addresses this issue is https://code.launchpad.net/~adam-collard/landscape-client-charm/juju-2-support/+merge/295697.

It looks like this branch just needs to be retired (although that would likely impact numerous existing mojo specs). Will dig a little on what the right answer should be here.

Revision history for this message
Michael Nelson (michael.nelson) wrote :

Hmm. In our internal deployments (sorry for the internal link), we have a total of 74 separate deployments which reference the apparently unmaintained lp:charms/trusty/landscape-client . I wonder if it'd be worth merging all the recent changes there?

https://pastebin.canonical.com/178394/

Revision history for this message
Michael Nelson (michael.nelson) wrote :

I'm happy to switch to the cs version too, for my own deployment, but would baulk at updating all 74 in the paste above.

Unmerged revisions

56. By Michael Nelson

Add support for juju2's JUJU_MODEL_UUID

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2016-03-30 20:04:13 +0000
3+++ hooks/hooks.py 2017-02-06 04:54:58 +0000
4@@ -69,10 +69,16 @@
5 juju_broker.log("In container-relation-joined for %s"
6 "" % landscape_broker.local_unit)
7 landscape_broker.config.reload()
8+
9+ # juju1 uses JUJU_ENV_UUID in hook contexts, whereas juju2 JUJU_MODE_UUID
10+ env_uuid = juju_broker.environment.get(
11+ "JUJU_ENV_UUID", juju_broker.environment.get(
12+ "JUJU_MODEL_UUID"))
13+
14 # We use the remote unit for the unit name, since we want to associate this
15 # client with the unit it's managing, not its own unit.
16 juju_info = {
17- "environment-uuid": juju_broker.environment.get("JUJU_ENV_UUID"),
18+ "environment-uuid": env_uuid,
19 "machine-id": juju_broker.get_machine_id(),
20 "api-addresses": juju_broker.environment.get("JUJU_API_ADDRESSES")}
21

Subscribers

People subscribed via source and target branches