Merge ~aluria/charm-openstack-service-checks/+git/charm-openstack-service-checks:bug/1825860 into ~canonical-bootstack/charm-openstack-service-checks:master

Proposed by Alvaro Uria
Status: Merged
Approved by: Alvaro Uria
Approved revision: 30e91ec2b3ad893864e1344df795b41716d2237e
Merged at revision: 248082420e89f6f693bd8ab70e1605f73f495980
Proposed branch: ~aluria/charm-openstack-service-checks/+git/charm-openstack-service-checks:bug/1825860
Merge into: ~canonical-bootstack/charm-openstack-service-checks:master
Diff against target: 74 lines (+18/-8)
2 files modified
lib/lib_openstack_service_checks.py (+9/-4)
reactive/openstack_service_checks.py (+9/-4)
Reviewer Review Type Date Requested Status
David O Neill (community) Approve
Review via email: mp+366526@code.launchpad.net

Commit message

Support checks removal

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Alvaro Uria (aluria) wrote :
Revision history for this message
David O Neill (dmzoneill) :
review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 248082420e89f6f693bd8ab70e1605f73f495980

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lib_openstack_service_checks.py b/lib/lib_openstack_service_checks.py
2index 2c99366..0ce2ac6 100644
3--- a/lib/lib_openstack_service_checks.py
4+++ b/lib/lib_openstack_service_checks.py
5@@ -203,9 +203,9 @@ class OSCHelper():
6 skip_service.add(service_name)
7 break
8
9+ check_url = urlparse(endpoint.url)
10 if self.charm_config.get('check_{}_urls'.format(endpoint.interface)):
11 cmd_params = ['/usr/lib/nagios/plugins/check_http']
12- check_url = urlparse(endpoint.url)
13 host, port = check_url.netloc.split(':')
14 cmd_params.append('-H {} -p {}'.format(host, port))
15 cmd_params.append('-u {}'.format(endpoint.healthcheck_url))
16@@ -214,17 +214,22 @@ class OSCHelper():
17 if check_url.scheme == 'https':
18 cmd_params.append('-S')
19 # Add an extra check for TLS cert expiry
20- cmd_params.append('-C {},{}'.format(self.charm_config['tls_warn_days'] or 30,
21- self.charm_config['tls_crit_days'] or 14))
22+ cmd_params_cert = cmd_params.copy()
23+ cmd_params_cert.append('-C {},{}'.format(self.charm_config['tls_warn_days'] or 30,
24+ self.charm_config['tls_crit_days'] or 14))
25 nrpe.add_check(shortname='{}_{}_cert'.format(service_name, endpoint.interface),
26 description='Certificate expiry check for {} {}'.format(service_name,
27 endpoint.interface),
28- check_cmd=' '.join(cmd_params))
29+ check_cmd=' '.join(cmd_params_cert))
30
31 # Add the actual health check for the URL
32 nrpe.add_check(shortname='{}_{}'.format(service_name, endpoint.interface),
33 description='Endpoint url check for {} {}'.format(service_name, endpoint.interface),
34 check_cmd=' '.join(cmd_params))
35+ else:
36+ nrpe.remove_check(shortname='{}_{}'.format(service_name, endpoint.interface))
37+ if check_url.scheme == 'https':
38+ nrpe.remove_check(shortname='{}_{}_cert'.format(service_name, endpoint.interface))
39 nrpe.write()
40
41 def get_keystone_client(self, creds):
42diff --git a/reactive/openstack_service_checks.py b/reactive/openstack_service_checks.py
43index c122bf1..846466f 100644
44--- a/reactive/openstack_service_checks.py
45+++ b/reactive/openstack_service_checks.py
46@@ -19,7 +19,7 @@ import base64
47 import subprocess
48
49 from charmhelpers.core import hookenv, host, unitdata
50-from charms.reactive import clear_flag, set_flag, when, when_not
51+from charms.reactive import any_flags_set, clear_flag, is_flag_set, set_flag, when, when_not
52
53 from lib_openstack_service_checks import (
54 OSCHelper,
55@@ -204,11 +204,16 @@ def do_restart():
56 set_flag('openstack-service-checks.started')
57
58
59-@when('config.changed.os-credentials')
60 @when('nrpe-external-master.available')
61 def do_reconfigure_nrpe():
62- clear_flag('openstack-service-checks.configured')
63- clear_flag('openstack-service-checks.endpoints.configured')
64+ os_credentials_flag = 'config.changed.os-credentials'
65+ flags = ['config.changed.check_{}_urls'.format(interface) for interface in ['admin', 'internal', 'public']]
66+ flags.extend(os_credentials_flag)
67+
68+ if any_flags_set(*flags):
69+ if is_flag_set(os_credentials_flag):
70+ clear_flag('openstack-service-checks.configured')
71+ clear_flag('openstack-service-checks.endpoints.configured')
72
73
74 @when_not('nrpe-external-master.available')

Subscribers

People subscribed via source and target branches