Merge lp://qastaging/~michael.nelson/charm-helpers/relation-get-return-none-outside-relation-hook into lp://qastaging/charm-helpers

Proposed by Michael Nelson
Status: Merged
Approved by: Gareth Woolridge
Approved revision: 87
Merged at revision: 87
Proposed branch: lp://qastaging/~michael.nelson/charm-helpers/relation-get-return-none-outside-relation-hook
Merge into: lp://qastaging/charm-helpers
Diff against target: 68 lines (+27/-0)
3 files modified
README.test (+1/-0)
charmhelpers/core/hookenv.py (+5/-0)
tests/core/test_hookenv.py (+21/-0)
To merge this branch: bzr merge lp://qastaging/~michael.nelson/charm-helpers/relation-get-return-none-outside-relation-hook
Reviewer Review Type Date Requested Status
Gareth Woolridge Approve
Review via email: mp+191946@code.qastaging.launchpad.net

Commit message

relation_get() returns None outside relation hook (instead of error).

Description of the change

With recent versions of juju-core, relation_get() raises an error if called outside of a relation hook without a -r relation_id specified [1]. The current execution_environment helper (which is used lots in charm-helpers) calls relation_get().

The actual error corresponds to an exit 2 error status [2]. I've differentiated on the error code because other (more serious) errors returned by relation-get use 1 [3]

[1] https://pastebin.canonical.com/99283/ Note that relation-list --help says this explicitly while relation-get --help does not.
[2] https://pastebin.canonical.com/99281/
[3] https://pastebin.canonical.com/99282/

To post a comment you must log in.
Revision history for this message
Gareth Woolridge (moon127) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches