Merge lp://qastaging/~paulgear/charm-helpers/nrpe-service-immediate-check into lp://qastaging/charm-helpers

Proposed by Paul Gear
Status: Merged
Merged at revision: 700
Proposed branch: lp://qastaging/~paulgear/charm-helpers/nrpe-service-immediate-check
Merge into: lp://qastaging/charm-helpers
Diff against target: 71 lines (+21/-10)
2 files modified
charmhelpers/contrib/charmsupport/nrpe.py (+19/-10)
tests/contrib/charmsupport/test_nrpe.py (+2/-0)
To merge this branch: bzr merge lp://qastaging/~paulgear/charm-helpers/nrpe-service-immediate-check
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
charmers Pending
Review via email: mp+300682@code.qastaging.launchpad.net

Description of the change

Add an option for immediate execution of nrpe service checks. This is necessary because (for sysvinit-based services) the cron file installed only runs the check every 5 minutes.

If a nagios service check is created but the check does not fire before the end of a CI run which does nagios checks at the end, the nagios check will return an error and the CI run will fail.

This change works around that by allowing a charm to specify that a check should be run immediately, to ensure the check file is created.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Minor inline comments.

I think the default should be immediate_check=True. Charms need to explicitly call add_init_service_checks(), and any charm doing that for a bogus service that hangs on the status check is already broken. It is better to discover that now rather than later when there are a zillion hung /usr/local/lib/nagios/plugins/check_exit_status.pl processes. Or just add timeout(1) to the command line.

review: Abstain
613. By Paul Gear

Implement Stuart's recommendations

614. By Paul Gear

Merge devel trunk

Revision history for this message
Paul Gear (paulgear) wrote :

Updated with Stuart's recommendations.

Revision history for this message
Stuart Bishop (stub) wrote :

======================================================================
ERROR: tests.contrib.charmsupport.test_nrpe.NRPEMiscTestCase.test_add_init_service_checks
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
  File "/home/stub/charms/charm-helpers/trunk/tests/contrib/charmsupport/test_nrpe.py", line 315, in test_add_init_service_checks
    nrpe.add_init_service_checks(bill, services, 'testunit')
  File "/home/stub/charms/charm-helpers/trunk/charmhelpers/contrib/charmsupport/nrpe.py", line 394, in add_init_service_checks
    os.chmod(checkpath, 0o644)
OSError: [Errno 2] No such file or directory: '/var/lib/nagios/service-check-haproxy.txt'

Revision history for this message
Stuart Bishop (stub) :
review: Approve
Revision history for this message
Stuart Bishop (stub) wrote :

I've fixed the test

Revision history for this message
Ryan Beisner (1chb1n) wrote :

After syncing this into the Glance charm, we see failure:

2017-03-03 22:22:19 INFO worker.uniter.jujuc server.go:172 running hook tool "juju-log" ["Check command not found: check_status_file.py"]
2017-03-03 22:22:19 DEBUG worker.uniter.jujuc server.go:173 hook context id "glance/0-config-changed-2954441461654224842"; dir "/var/lib/juju/agents/unit-glance-0/charm"
2017-03-03 22:22:19 INFO juju-log Check command not found: check_status_file.py
2017-03-03 22:22:19 INFO config-changed Traceback (most recent call last):
2017-03-03 22:22:19 INFO config-changed File "/var/lib/juju/agents/unit-glance-0/charm/hooks/config-changed", line 632, in <module>
2017-03-03 22:22:19 INFO config-changed hooks.execute(sys.argv)
2017-03-03 22:22:19 INFO config-changed File "/var/lib/juju/agents/unit-glance-0/charm/hooks/charmhelpers/core/hookenv.py", line 731, in execute
2017-03-03 22:22:19 INFO config-changed self._hooks[hook_name]()
2017-03-03 22:22:19 INFO config-changed File "/var/lib/juju/agents/unit-glance-0/charm/hooks/charmhelpers/contrib/openstack/utils.py", line 1864, in wrapped_f
2017-03-03 22:22:19 INFO config-changed restart_functions)
2017-03-03 22:22:19 INFO config-changed File "/var/lib/juju/agents/unit-glance-0/charm/hooks/charmhelpers/core/host.py", line 655, in restart_on_change_helper
2017-03-03 22:22:19 INFO config-changed r = lambda_f()
2017-03-03 22:22:19 INFO config-changed File "/var/lib/juju/agents/unit-glance-0/charm/hooks/charmhelpers/contrib/openstack/utils.py", line 1863, in <lambda>
2017-03-03 22:22:19 INFO config-changed (lambda: f(*args, **kwargs)), restart_map, stopstart,
2017-03-03 22:22:19 INFO config-changed File "/var/lib/juju/agents/unit-glance-0/charm/hooks/charmhelpers/contrib/hardening/harden.py", line 79, in _harden_inner2
2017-03-03 22:22:19 INFO config-changed return f(*args, **kwargs)
2017-03-03 22:22:19 INFO config-changed File "/var/lib/juju/agents/unit-glance-0/charm/hooks/config-changed", line 405, in config_changed
2017-03-03 22:22:19 INFO config-changed update_nrpe_config()
2017-03-03 22:22:19 INFO config-changed File "/var/lib/juju/agents/unit-glance-0/charm/hooks/config-changed", line 593, in update_nrpe_config
2017-03-03 22:22:19 INFO config-changed nrpe.add_init_service_checks(nrpe_setup, services(), current_unit)
2017-03-03 22:22:19 INFO config-changed File "/var/lib/juju/agents/unit-glance-0/charm/hooks/charmhelpers/contrib/charmsupport/nrpe.py", line 387, in add_init_service_checks
2017-03-03 22:22:19 INFO config-changed f = open(checkpath, 'w')
2017-03-03 22:22:19 INFO config-changed IOError: [Errno 2] No such file or directory: '/var/lib/nagios/service-check-haproxy.txt'

Revision history for this message
Ryan Beisner (1chb1n) wrote :

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