Charm looks for JUJU_ENV_UUID but that does not exist in juju 2 models

Bug #1572575 reported by Andreas Hasenack
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
landscape-client-charm
Fix Released
High
Adam Collard
landscape-client (Juju Charms Collection)
Fix Released
High
Adam Collard
swift-proxy (Juju Charms Collection)
Fix Released
High
James Page
swift-storage (Juju Charms Collection)
Fix Released
High
James Page

Bug Description

In juju 1, the environment UUID is set in the JUJU_ENV_UUID shell variable, and the landscape-client charm uses that.

With juju 2, however, that variable is replaced by JUJU_MODEL_UUID.

The landscape-clientc charm, to be compatible with both juju major versions, needs to check for both these variables.

When deployed with juju 1, this backtrace happens at registration time:
2016-04-20 13:17:05,486 ERROR [MainThread] Error running event handler landscape.broker.registration.RegistrationHandler._handle_pre_exchange() for event type 'pre-exchange' with args () {}.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/landscape/reactor.py", line 92, in fire
    results.append(handler(*args, **kwargs))
  File "/usr/lib/python2.7/dist-packages/landscape/broker/registration.py", line 213, in _handle_pre_exchange
    self._exchange.send(message)
  File "/usr/lib/python2.7/dist-packages/landscape/broker/exchange.py", line 455, in send
    message_id = self._message_store.add(message)
  File "/usr/lib/python2.7/dist-packages/landscape/broker/store.py", line 367, in add
    message = schema.coerce(message)
  File "/usr/lib/python2.7/dist-packages/landscape/schema.py", line 230, in coerce
    return super(Message, self).coerce(value)
  File "/usr/lib/python2.7/dist-packages/landscape/schema.py", line 167, in coerce
    % (k, value, self.schema[k], e))
InvalidError: Value of 'juju-info' key of dict {'tags': None, 'timestamp': 1461158225, 'api': '3.3', 'container-info': 'lxc', 'account_name': 'standalone', 'vm-info': '', 'registration_password': 'secret', 'computer_title': 'juju-c206b053-523a-42dd-8e12-321073390de6-machine-1', 'hostname': 'juju-c206b053-523a-42dd-8e12-321073390de6-machine-1.lxd', 'juju-info': {'environment-uuid': None, 'api-addresses': [u'10.0.100.50:17070'], 'machine-id': u'1'}, 'type': 'register'} could not coerce with <landscape.schema.KeyDict object at 0x7f1734b01510>: Value of 'environment-uuid' key of dict {'environment-uuid': None, 'api-addresses': [u'10.0.100.50:17070'], 'machine-id': u'1'} could not coerce with <landscape.schema.Unicode object at 0x7f1734b01410>: None isn't a unicode

environmentuuid is null
# cat /var/lib/landscape/client/juju-info.json ;echo
{"environment-uuid": null, "api-addresses": "10.0.100.50:17070", "machine-id": "1"}

I guess this is another bug: the landscape-client charm should fail hard if it can't get the environment-uuid, as that is absolutely required.

Related branches

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

And juju status remains happy throughout:

[Units]
ID WORKLOAD-STATUS JUJU-STATUS VERSION MACHINE PORTS PUBLIC-ADDRESS MESSAGE
haproxy/0 unknown idle 2.0-beta4 0 80/tcp,443/tcp,10000/tcp 10.0.100.150
  landscape-client/3 unknown executing 2.0-beta4 10.0.100.150
landscape-server/0 active idle 2.0-beta4 1 10.0.100.115
  landscape-client/0 unknown executing 2.0-beta4 10.0.100.115
postgresql/0 active idle 2.0-beta4 2 5432/tcp 10.0.100.140 Live master
  landscape-client/2 unknown executing 2.0-beta4 10.0.100.140
rabbitmq-server/0 active idle 2.0-beta4 3 5672/tcp 10.0.100.29 Unit is ready
  landscape-client/1 unknown executing 2.0-beta4 10.0.100.29
ubuntu/0 unknown idle 2.0-beta4 4 10.0.100.229

tags: removed: bug-squad
tags: added: juju-2.0-api
David Britton (dpb)
Changed in landscape-client (Juju Charms Collection):
importance: Undecided → High
tags: added: bug-squad
tags: removed: kanban
David Britton (dpb)
Changed in landscape-client-charm:
importance: Undecided → High
Revision history for this message
Brad Marshall (brad-marshall) wrote :

This also affects swift-storage - I'm getting an error:

2016-05-23 04:47:17 INFO swift-storage-relation-joined Traceback (most recent call last):
2016-05-23 04:47:17 INFO swift-storage-relation-joined File "/var/lib/juju/agents/unit-swift-storage-z1-0/charm/hooks/swift-storage-relation-joined", line 202, in <module>
2016-05-23 04:47:17 INFO swift-storage-relation-joined main()
2016-05-23 04:47:17 INFO swift-storage-relation-joined File "/var/lib/juju/agents/unit-swift-storage-z1-0/charm/hooks/swift-storage-relation-joined", line 194, in main
2016-05-23 04:47:17 INFO swift-storage-relation-joined hooks.execute(sys.argv)
2016-05-23 04:47:17 INFO swift-storage-relation-joined File "/var/lib/juju/agents/unit-swift-storage-z1-0/charm/hooks/charmhelpers/core/hookenv.py", line 717, in execute
2016-05-23 04:47:17 INFO swift-storage-relation-joined self._hooks[hook_name]()
2016-05-23 04:47:17 INFO swift-storage-relation-joined File "/var/lib/juju/agents/unit-swift-storage-z1-0/charm/hooks/swift-storage-relation-joined", line 128, in swift_sto
rage_relation_joined
2016-05-23 04:47:17 INFO swift-storage-relation-joined remember_devices(devs)
2016-05-23 04:47:17 INFO swift-storage-relation-joined File "/var/lib/juju/agents/unit-swift-storage-z1-0/charm/hooks/lib/swift_storage_utils.py", line 381, in remember_dev
ices
2016-05-23 04:47:17 INFO swift-storage-relation-joined env_uuid = os.environ['JUJU_ENV_UUID']
2016-05-23 04:47:17 INFO swift-storage-relation-joined File "/usr/lib/python2.7/UserDict.py", line 40, in __getitem__
2016-05-23 04:47:17 INFO swift-storage-relation-joined raise KeyError(key)
2016-05-23 04:47:17 INFO swift-storage-relation-joined KeyError: 'JUJU_ENV_UUID'
2016-05-23 04:47:18 ERROR juju.worker.uniter.operation runhook.go:107 hook "swift-storage-relation-joined" failed: exit status 1

And we end up with swift-storage in hook failure.

This is with the following package versions:

$ dpkg-query -W juju-2.0
juju-2.0 2.0-beta7-0ubuntu1~14.04.2~juju1

$ dpkg-query -W maas
maas 2.0.0~beta5+bzr5026-0ubuntu1~xenial1

tags: added: canonical-bootstack
Revision history for this message
Brad Marshall (brad-marshall) wrote :

FWIW I updated both swift-proxy and swift-storage to use JUJU_MODEL_UUID instead of JUJU_ENV_UUID, and it seemed to work fine.

Revision history for this message
James Page (james-page) wrote :

Brad - sounds like a sensible fix - I'll work that into a review that's also backwards compatible.

Changed in swift-proxy (Juju Charms Collection):
status: New → Triaged
Changed in swift-storage (Juju Charms Collection):
status: New → Triaged
Changed in swift-proxy (Juju Charms Collection):
importance: Undecided → High
Changed in swift-storage (Juju Charms Collection):
importance: Undecided → High
Changed in swift-proxy (Juju Charms Collection):
assignee: nobody → James Page (james-page)
Changed in swift-storage (Juju Charms Collection):
assignee: nobody → James Page (james-page)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-swift-proxy (master)

Fix proposed to branch: master
Review: https://review.openstack.org/319787

Changed in swift-proxy (Juju Charms Collection):
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-swift-storage (master)

Fix proposed to branch: master
Review: https://review.openstack.org/319790

Changed in swift-storage (Juju Charms Collection):
status: Triaged → In Progress
James Page (james-page)
Changed in swift-storage (Juju Charms Collection):
milestone: none → 16.07
Changed in swift-proxy (Juju Charms Collection):
milestone: none → 16.07
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-swift-proxy (master)

Reviewed: https://review.openstack.org/319787
Committed: https://git.openstack.org/cgit/openstack/charm-swift-proxy/commit/?id=0fa129873bf056120a403790b167ca198e8b26fc
Submitter: Jenkins
Branch: master

commit 0fa129873bf056120a403790b167ca198e8b26fc
Author: James Page <email address hidden>
Date: Mon May 23 10:08:57 2016 +0100

    Use JUJU_MODEL_UUID for Juju 2.0

    Juju 2.0 renames the environment variable JUJU_ENV_UUID
    to JUJU_MODEL_UUID; use this environment variable as a
    fallback if JUJU_ENV_UUID is not set to support Juju 2.0,
    whilst continuing to provide support for Juju < 2.0.

    Change-Id: I26ae366c84d3cd9a9c2471385effd2a6202e9314
    Closes-Bug: 1572575

Changed in swift-proxy (Juju Charms Collection):
status: In Progress → Fix Committed
Changed in landscape-client-charm:
status: New → Triaged
Changed in landscape-client (Juju Charms Collection):
status: New → Triaged
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-swift-storage (master)

Reviewed: https://review.openstack.org/319790
Committed: https://git.openstack.org/cgit/openstack/charm-swift-storage/commit/?id=fc1943af8fff3c191e51857445f61e6ec4e54d85
Submitter: Jenkins
Branch: master

commit fc1943af8fff3c191e51857445f61e6ec4e54d85
Author: James Page <email address hidden>
Date: Mon May 23 10:21:26 2016 +0100

    Use JUJU_MODEL_UUID for Juju 2.0

    Juju 2.0 renames the environment variable JUJU_ENV_UUID
    to JUJU_MODEL_UUID; use this environment variable as a
    fallback if JUJU_ENV_UUID is not set to support Juju 2.0,
    whilst continuing to provide support for Juju < 2.0.

    Change-Id: I0e9ebbe59032e3d15864ee1f9bd49b404b339a3b
    Closes-Bug: 1572575

Changed in swift-storage (Juju Charms Collection):
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-swift-proxy (stable/16.04)

Fix proposed to branch: stable/16.04
Review: https://review.openstack.org/320523

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-swift-storage (stable/16.04)

Fix proposed to branch: stable/16.04
Review: https://review.openstack.org/320527

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-swift-proxy (stable/16.04)

Reviewed: https://review.openstack.org/320523
Committed: https://git.openstack.org/cgit/openstack/charm-swift-proxy/commit/?id=2cee569e759bbc7d0828609bad0ff10a93215f8c
Submitter: Jenkins
Branch: stable/16.04

commit 2cee569e759bbc7d0828609bad0ff10a93215f8c
Author: James Page <email address hidden>
Date: Mon May 23 10:08:57 2016 +0100

    Use JUJU_MODEL_UUID for Juju 2.0

    Juju 2.0 renames the environment variable JUJU_ENV_UUID
    to JUJU_MODEL_UUID; use this environment variable as a
    fallback if JUJU_ENV_UUID is not set to support Juju 2.0,
    whilst continuing to provide support for Juju < 2.0.

    Change-Id: I26ae366c84d3cd9a9c2471385effd2a6202e9314
    Closes-Bug: 1572575
    (cherry picked from commit 0fa129873bf056120a403790b167ca198e8b26fc)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-swift-storage (stable/16.04)

Reviewed: https://review.openstack.org/320527
Committed: https://git.openstack.org/cgit/openstack/charm-swift-storage/commit/?id=5a0b6139ee32942f8e6d60609ede70148dbdd1e8
Submitter: Jenkins
Branch: stable/16.04

commit 5a0b6139ee32942f8e6d60609ede70148dbdd1e8
Author: James Page <email address hidden>
Date: Mon May 23 10:21:26 2016 +0100

    Use JUJU_MODEL_UUID for Juju 2.0

    Juju 2.0 renames the environment variable JUJU_ENV_UUID
    to JUJU_MODEL_UUID; use this environment variable as a
    fallback if JUJU_ENV_UUID is not set to support Juju 2.0,
    whilst continuing to provide support for Juju < 2.0.

    Change-Id: I0e9ebbe59032e3d15864ee1f9bd49b404b339a3b
    Closes-Bug: 1572575
    (cherry picked from commit fc1943af8fff3c191e51857445f61e6ec4e54d85)

Changed in landscape-client-charm:
assignee: nobody → Adam Collard (adam-collard)
Changed in landscape-client (Juju Charms Collection):
assignee: nobody → Adam Collard (adam-collard)
status: Triaged → In Progress
Changed in landscape-client-charm:
status: Triaged → In Progress
Changed in landscape-client (Juju Charms Collection):
status: In Progress → Invalid
Changed in landscape-client-charm:
status: In Progress → Invalid
description: updated
Changed in landscape-client:
status: New → In Progress
importance: Undecided → Medium
importance: Medium → High
assignee: nobody → Adam Collard (adam-collard)
Changed in landscape-client (Ubuntu):
status: New → In Progress
assignee: nobody → Adam Collard (adam-collard)
Changed in landscape-client-charm:
status: Invalid → In Progress
Changed in landscape-client (Juju Charms Collection):
status: Invalid → In Progress
Changed in landscape-client (Ubuntu):
status: In Progress → Invalid
Changed in landscape-client:
status: In Progress → Invalid
description: updated
Revision history for this message
Adam Collard (adam-collard) wrote :

Sorry for the bug spam, mis-read the grep.

Filed a bug against Juju docs here: https://github.com/juju/docs/issues/1116

James Page (james-page)
Changed in swift-storage (Juju Charms Collection):
status: Fix Committed → Fix Released
Changed in swift-proxy (Juju Charms Collection):
status: Fix Committed → Fix Released
no longer affects: landscape-client
no longer affects: landscape-client (Ubuntu)
Changed in landscape-client-charm:
status: In Progress → Fix Committed
Changed in landscape-client (Juju Charms Collection):
status: In Progress → Fix Committed
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Fix released for the client charm:
cs:trusty/landscape-client-14
cs:xenial/landscape-client-1

Changed in landscape-client-charm:
status: Fix Committed → Fix Released
Changed in landscape-client (Juju Charms Collection):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.