Merge lp:~lazypower/charm-helpers/add-workload-version into lp:charm-helpers
| Status: | Merged |
|---|---|
| Merged at revision: | 622 |
| Proposed branch: | lp:~lazypower/charm-helpers/add-workload-version |
| Merge into: | lp:charm-helpers |
| Diff against target: |
40 lines (+19/-0) 2 files modified
charmhelpers/core/hookenv.py (+14/-0) tests/core/test_hookenv.py (+5/-0) |
| To merge this branch: | bzr merge lp:~lazypower/charm-helpers/add-workload-version |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Stuart Bishop | 2016-09-07 | Approve on 2016-09-08 | |
| charmers | 2016-09-07 | Pending | |
|
Review via email:
|
|||
Description of the Change
Adds:
- application-
- Test coverage to support the added code
| Stuart Bishop (stub) wrote : | # |
Per irc discussion.
I have charms that support both 1.25 and 2.0
If I want to call application_
try:
application
except NotImplementedE
pass
I think charmhelpers should do that, so in the PostgreSQL charm I can just do 'application_
Ignore my rant about version sniffing, since this way is consistent with the rest of the code base (someone has 'fixed' the counter examples).
| Charles Butler (lazypower) wrote : | # |
I'm not against that proposal stub. Just to be precise, if we go through to modify the other methods, we're looking at changing the behavior of:
- leader_set
- leader_get
- is_leader
- payload_register
- payload_unregister
- payload_status_set
- resource_get
- network_
We should probably file an issue and work through that elsewhere, but I don't know that we can reasonably change the behavior of charm-helpers.
- 623. By Charles Butler on 2016-09-07
-
Refactor the application-
version- set stanza to only log if not on a 2.0+ host.
| Stuart Bishop (stub) wrote : | # |
I'm not suggesting changing the behaviour of any other functions. Calling any of the ones you cite from an old version of Juju should most certainly fail, because charms calling them are relying on their behavour and effects. application_
| Charles Butler (lazypower) wrote : | # |
Ok, I misunderstood the context of your reply, but seems like we got there anyway! \o/ Thanks stub.


I'd rather see this do nothing than fail if it is called from 1.25. It currently raises a not implemented error, which will bite people maintaining charms that need to support old Juju. Unlike other tools like leader-set, I think this is more like status_set where it is better to just make do (in this case, do nothing). I'll let this approach through though, as it is somewhat a matter of opinion. But my personal opinion is I'd rather not have to guard all my calls in the PostgreSQL charm and have charm-helpers DWIM if it happens to be running with Juju 1.25.
I personally hate the @translate_exc approach, since it masks lots of other errors than 'not running a recent enough version of juju'. I much prefer "if has_juju_ version( '2.0')" , even though group think is that you should do it this way with all its caveats and hidden bugs rather than to concisely state that this is a Juju 2.0 feature. But I won't block review on this point since someone else has gone to the trouble of rewriting things using the less readable and more error prone approach :-/