Merge lp:~ajkavanagh/charm-helpers/add-service-checks-lp1524388 into lp:charm-helpers
| Status: | Merged |
|---|---|
| Merged at revision: | 531 |
| Proposed branch: | lp:~ajkavanagh/charm-helpers/add-service-checks-lp1524388 |
| Merge into: | lp:charm-helpers |
| Diff against target: |
329 lines (+256/-2) 4 files modified
charmhelpers/contrib/network/ip.py (+15/-0) charmhelpers/contrib/openstack/utils.py (+73/-2) tests/contrib/network/test_ip.py (+9/-0) tests/contrib/openstack/test_openstack_utils.py (+159/-0) |
| To merge this branch: | bzr merge lp:~ajkavanagh/charm-helpers/add-service-checks-lp1524388 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Liam Young | 2016-02-10 | Approve on 2016-02-17 | |
| David Ames | Approve on 2016-02-16 | ||
|
Review via email:
|
|||
Description of the Change
Add service running and ports open checks to set_os_
This adds optional checks to the set_os_
make sure that the services that the charm says should be running are
actually running (according to service_running()) and also, optionally,
that the ports that are supposed to be open are open (on 0.0.0.0) and
have something listening to them.
| David Ames (thedac) wrote : | # |
| Alex Kavanagh (ajkavanagh) wrote : | # |
I've updated charm-helpers to support the simple list of services (oversight, apologies), added tests, and also updated the keystone example branch (lp:~ajkavanagh/charms/trusty/keystone/add-service-checks-lp1524388) to use the new version.
I've also changed the set_os_
# set the status according to the current state of the contexts
set_
configs, REQUIRED_
The utils function services() and determine_ports() 'appear' (for keystone, at least) the list of running services and the ports it manages. Is this true, and thus, does it answer the question you posed for discussion?


Needs fixing:
We are going to want to set the state to 'blocked' which means user action is required. The state 'unknown' is reserved for before a state has been declared or for charms which never set state.
Hacking around a bit with your keystone example (I had to add servcies to the set_os_ workload_ status) . When I used a simple ['keystone'] it fails:
# set the status according to the current state of the contexts os_workload_ status( INTERFACES, charm_func= check_optional_ relations,
services= ['keystone' ])
set_
configs, REQUIRED_
Traceback (most recent call last): update- status" , line 654, in <module> update- status" , line 650, in main status( CONFIGS) juju/agents/ unit-keystone- 0/charm/ hooks/keystone_ utils.py" , line 1845, in assess_status ['keystone' ]) juju/agents/ unit-keystone- 0/charm/ hooks/charmhelp ers/contrib/ openstack/ utils.py" , line 936, in set_os_ workload_ status
File "hooks/
main()
File "hooks/
assess_
File "/var/lib/
services=
File "/var/lib/
_s = [s['service'] for s in services]
TypeError: string indices must be integers, not str
Using the full dictionary works beautifully. os_workload_ status( INTERFACES, charm_func= check_optional_ relations,
services= [{'service' : 'keystone', 'ports': [5000, 4990, 35357, 35347]}])
set_
configs, REQUIRED_
For discussion:
We need to have a discussion about the default ports for a service vrs our haproxy with non-default ports for the service. For example keystone's default is 5000 which haproxy listens for but our charm has the keystone service itself listen on 4990.
Is there anyway we can automatically "guess" these?