Merge lp:~axino/charm-helpers/set-primary-charm-on-nrpe-relation into lp:charm-helpers
- set-primary-charm-on-nrpe-relation
- Merge into devel
Status: | Merged |
---|---|
Merged at revision: | 621 |
Proposed branch: | lp:~axino/charm-helpers/set-primary-charm-on-nrpe-relation |
Merge into: | lp:charm-helpers |
Diff against target: |
66 lines (+18/-4) 2 files modified
charmhelpers/contrib/charmsupport/nrpe.py (+15/-1) tests/contrib/charmsupport/test_nrpe.py (+3/-3) |
To merge this branch: | bzr merge lp:~axino/charm-helpers/set-primary-charm-on-nrpe-relation |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stuart Bishop (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
(Stolen from https:/
In IS we have scenarios where a unit may have its primary charm and multiple subordinate charms related to nrpe{,-
The nrpe-external-
This leads to situations where the hostname generated uses the subordinate charm's service name rather than the primary charm.
The only way to guarantee that the primary charm is used, is to set the information on the relation in the charm and then test for it in the nrpe-external-
This MP is one half of the solution. Primary charms will default to True and subordinate charms can set primary=False.
Explicitly set when a charm is the primary charm (vs a subordinate charm) in the npre-external-
For use when multiple charms primary and subordinate are related to nrpe{,-
The default is set to True as this is the case 99% of the time.
Only subordinate charms which are related to nrpe{,-
- 555. By Charles Butler
-
[r=beisner,
a=lazypower] Anton Skriptsov 2016-03-22 add NexentaEdge's charms to no_origin list - 556. By David Ames
-
[jamespage, r=thedac] Add extra-binding awareness to openstack api endpoint resolver
- 557. By James Page
-
Add InternalEndpoin
tContext to contrib. openstack. context - 558. By Edward Hope-Morley
-
[gnuoy,r=hopem]
When checking if a System V service is running, query
service --all-status which keeps track of the services
and their return codes.Closes-Bug: 1564842
- 559. By David Ames
-
[thedac, r=jamespage] Apparmor context class for OpenStack charms
The class will validate aa-profile-mode config settings and either set
the profile to enforce, complain or disable. - 560. By David Ames
-
[coreycb, r=thedac] Add support for keystone liberty release 8.1.0
- 561. By David Ames
-
[jamespage, r=thedac] Add support for specifying the datapath type of an ovs bridge
- 562. By Ryan Beisner
-
[chris.macnaughton, r=1chb1n] Allow the validate_
unit_process_ ids test helper to accept a list of valid values - 563. By Ryan Beisner
-
[chris.macnaughton, r=1chb1n] Trivial lint fix
- 564. By James Page
-
Allow custom functions to be used to restart services in the restart_on_change functions.
- 565. By James Page
-
[trivial] Add 2.7.0 to the list of swift mitaka releases.
- 566. By Ryan Beisner
-
[xfactor973, r=1chb1n] Add the final update_pool call in Ceph pool creation to set the replica count (bug 1565120)
- 567. By Ryan Beisner
-
[xfactor973, r=1chb1n] Add mandatory flag for ceph jewel and above
- 568. By Liam Young
-
[gnuoy, r=james-page] Add openstack mitaka compatible template for keystone-authtoken
- 569. By Edward Hope-Morley
-
[hopem,r=gnuoy]
Fix contib.
storage. linux.ceph pool_exists()
Partially-Closes- Bug: 1572506 - 570. By James Page
-
Switch is_device_mounted to use lsblk
This will correct detect a wider range of 'is use' states compared
to parsing the output of /proc/mounts, including block devices that
are part of LVM volumes. - 571. By James Page
-
Add support for mitaka/neutron 8.1.x series
- 572. By David Ames
-
[thedac,r=tinwood] Actively check for stopped message(s) in service_running
- 573. By James Page
-
Fix ipv6 address recongition under xenial.
- 574. By James Page
-
Refactor service_running to determine init approach
Use of "service --status-all" has some challenges on trusty where
a recent lsb-base update resulted in all calls being diverted to
upstart, where return codes for non-running daemons are still 0.Detect whether to use upstart or the base init.d script to
determine whether a service is running, and look at either the
upstart output, or for a non-zero return code from an init.d
status call. - 575. By James Page
-
Add support for generation of systemd unit files for OpenStack
deploy from source. - 576. By James Page
-
Add support for Netwon and Ocata OpenStack release
Drop back to matching major versions only for projects that use semantic versioning.
- 577. By Edward Hope-Morley
-
[hopem,r=jamespage]
Add CephConfContext to contrib.
storage. linux.ceph Also moved contrib.
openstack. context. config_ flags_parser to
contrib.openstack. utils and created contrib. openstack. exceptions
Related-Bug: 1522375 - 578. By James Page
-
Add support for fallback matching on major.minor version for Swift
This allows trunk package builds to be used with the charms.
- 579. By James Page
-
Ensure is_ip detects both IPv4 and IPv6 addresses
- 580. By Edward Hope-Morley
-
[trivial] context should use set().difference not set().symmetric
_difference when validating keys - 581. By Matt Bruzek
-
[jamesbeedy] Added uid and gid specification functionality for adduser and addgroup.
[mbruzek] Added a newline to fix lint. - 582. By Ryan Beisner
-
[jamespage,
r=1chb1n] Update amulet helpers to deploy charms from the charm store As part of the migration to git/gerrit and with the introduction of
layered charms, the charm store really needs to be the definative
source of truth for all charms during test.Switch the charm resolver code to pick the correct charms from the
charm store for amulet tests.This does change behaviour in that base charms are deployed aligned
to the test series where possible; otherwise the most recent Ubuntu
series is used instead - results in mysql/trusty + keystone/xenial
for example. - 583. By James Page
-
Enable default git repo generation if a default openstack-
origin- git value is specified. - 584. By David Ames
-
[thedac, r=tinwood] DNS HA Helpers
Start the process of moving HA helpers into the openstack contrib area
Add the helper for API charms to use DNS HA
Add validation for new DNS config options in HA
Allow resolve_address to override with DNS or not - 585. By Stuart Bishop
-
[marcoceppi, r=stub] Fix bzr branch installer
- 586. By Stuart Bishop
-
[george-edison55, r=stub] Fix fetch.install_
remote( ) when multiple handlers match the URL - 587. By Stuart Bishop
-
[chris-gondolin, r=stub] Option to specify a revno when fetching from a bzr repo
- 588. By Stuart Bishop
-
[stub] Add test to bzr revno fetcher, fix casting of bzr revno
- 589. By Stuart Bishop
-
[freyes, r=stub] Mock contrib.
network. ufw.modprobe in tests as required - 590. By James Page
-
Updates for DNS-HA support in non-api OpenStack charms.
- 591. By James Page
-
Rebase
- 592. By Liam Young
-
[gnuoy, r=james-page] Decode result of check_output in network_
get_primary_ address Under python3.5 check_output returns bytes which need decoding. This change
adds the decode to network_get_primary_ address and brings it in line with other
core hookenv functions. - 593. By James Page
-
Fixes for deploy from source for openstack
- 594. By James Page
-
Fixes for apparmor support for openstack contrib module
- 595. By James Page
-
Misc fixes and improvements for deploy-from-source.
- 596. By James Page
-
Add missing openstack.ha package to setup.py
- 597. By Marco Ceppi <marco@T430>
-
[james-page] Re-license charm-helpers inline with agreed licensing approaches for charms, interfaces and layers.
- 598. By Marco Ceppi <marco@T430>
-
version bump
- 599. By Marco Ceppi <marco@T430>
-
flake8 fixes
- 600. By James Page
-
[trivial] Support nrpe for testing on wily and xenial
- 601. By James Page
-
Add option to allow location of user home directory to be provided when creating users.
- 602. By Ryan Beisner
-
[chris.macnaughton, r=1chb1n] Add ceph-proxy to source charms for openstack amulet helper
- 603. By Ryan Beisner
-
[thedac, r=1chb1n] Send LSB release to apparmor context templates
Set the LSB release to be consumed by apparmor context profiles
- 604. By David Ames
-
[billy-olsen, r=thedac] Allow float for worker-multiplier.
- 605. By James Page
-
Misc updates for deploy from source
Improve OpenStack release determination.
- 606. By Jorge Niedbalski
-
[billy-olsen, r=niedbalski, cholcombe] Partially fixes bug LP: #1492742
- 607. By Jorge Niedbalski
-
[niedbalski, r=] Fix broken tests for py2.7
- 608. By Stuart Bishop
-
[stub,r=james-page] Make fetch.apt_cache() quiet by default
- 609. By Stuart Bishop
-
[fginther, r=stub] Install python3-jinja2 when running Python3
- 610. By James Page
-
Add 2.9.0 to list of releases for newton
- 611. By David Ames
-
[thedac, r=gnuoy] Make apt_install fatal=True for dnspython install
- 612. By Liam Young
-
[gnuoy, r=jamespage] Only write out CA cert if it has changed
Only write out CA cert and run the update-
ca-certificates if the cert has
actually changed. This reduces the risk of certs being pulled from under services
which are trying to do client side certificate validation on remote https
endpoints. - 613. By Liam Young
-
[1chb1n, r=gnuoy] Consume env var AMULET_
SETUP_TIMEOUT if set - 614. By Liam Young
-
[corey.bryant, r=gnuoy] Install networking-hyperv when deploying neutron-api from source.
- 615. By Stuart Bishop
-
[axino, r=stub] nrpe: make add_init_
service_ checks support systemd - 616. By Liam Young
-
[ajkavanagh r=gnuoy] Add a v3 version of service catalog checking
This adds a keystone v3 version of service catalog checking to the
contrib/openstack/ amulet/ utils.py file. - 617. By Liam Young
-
[gnuoy, trivial] Lint fix
- 618. By James Page
-
Set a minimum PG count of 2, to avoid math domain errors in small OSD setups
- 619. By Ryan Beisner
-
[thedac, 1chb1n] Add support for Mitaka NSX
Update Neutron plugins for NSX on Mitaka
- 620. By Marco Ceppi <marco@T430>
-
[dbuliga] Added support for CentOS
- 621. By Junien F
-
Explicitly set when a charm is the primary charm (vs a subordinate charm) in the npre-external-
master relation.
For use when multiple charms primary and subordinate are related to nrpe{,-external- master} on the same unit.
The default is set to True as this is the case 99% of the time.
Only subordinate charms which are related to nrpe{,-external- master} need to set primary=False on the relation.
Preview Diff
1 | === modified file 'charmhelpers/contrib/charmsupport/nrpe.py' | |||
2 | --- charmhelpers/contrib/charmsupport/nrpe.py 2016-07-29 10:15:48 +0000 | |||
3 | +++ charmhelpers/contrib/charmsupport/nrpe.py 2016-09-06 06:26:52 +0000 | |||
4 | @@ -109,6 +109,13 @@ | |||
5 | 109 | # def local_monitors_relation_changed(): | 109 | # def local_monitors_relation_changed(): |
6 | 110 | # update_nrpe_config() | 110 | # update_nrpe_config() |
7 | 111 | # | 111 | # |
8 | 112 | # 4.a If your charm is a subordinate charm set primary=False | ||
9 | 113 | # | ||
10 | 114 | # from charmsupport.nrpe import NRPE | ||
11 | 115 | # (...) | ||
12 | 116 | # def update_nrpe_config(): | ||
13 | 117 | # nrpe_compat = NRPE(primary=False) | ||
14 | 118 | # | ||
15 | 112 | # 5. ln -s hooks.py nrpe-external-master-relation-changed | 119 | # 5. ln -s hooks.py nrpe-external-master-relation-changed |
16 | 113 | # ln -s hooks.py local-monitors-relation-changed | 120 | # ln -s hooks.py local-monitors-relation-changed |
17 | 114 | 121 | ||
18 | @@ -221,9 +228,10 @@ | |||
19 | 221 | nagios_exportdir = '/var/lib/nagios/export' | 228 | nagios_exportdir = '/var/lib/nagios/export' |
20 | 222 | nrpe_confdir = '/etc/nagios/nrpe.d' | 229 | nrpe_confdir = '/etc/nagios/nrpe.d' |
21 | 223 | 230 | ||
23 | 224 | def __init__(self, hostname=None): | 231 | def __init__(self, hostname=None, primary=True): |
24 | 225 | super(NRPE, self).__init__() | 232 | super(NRPE, self).__init__() |
25 | 226 | self.config = config() | 233 | self.config = config() |
26 | 234 | self.primary = primary | ||
27 | 227 | self.nagios_context = self.config['nagios_context'] | 235 | self.nagios_context = self.config['nagios_context'] |
28 | 228 | if 'nagios_servicegroups' in self.config and self.config['nagios_servicegroups']: | 236 | if 'nagios_servicegroups' in self.config and self.config['nagios_servicegroups']: |
29 | 229 | self.nagios_servicegroups = self.config['nagios_servicegroups'] | 237 | self.nagios_servicegroups = self.config['nagios_servicegroups'] |
30 | @@ -239,6 +247,12 @@ | |||
31 | 239 | else: | 247 | else: |
32 | 240 | self.hostname = "{}-{}".format(self.nagios_context, self.unit_name) | 248 | self.hostname = "{}-{}".format(self.nagios_context, self.unit_name) |
33 | 241 | self.checks = [] | 249 | self.checks = [] |
34 | 250 | # Iff in an nrpe-external-master relation hook, set primary status | ||
35 | 251 | relation = relation_ids('nrpe-external-master') | ||
36 | 252 | if relation: | ||
37 | 253 | log("Setting charm primary status {}".format(primary)) | ||
38 | 254 | for rid in relation_ids('nrpe-external-master'): | ||
39 | 255 | relation_set(relation_id=rid, relation_settings={'primary': self.primary}) | ||
40 | 242 | 256 | ||
41 | 243 | def add_check(self, *args, **kwargs): | 257 | def add_check(self, *args, **kwargs): |
42 | 244 | self.checks.append(Check(*args, **kwargs)) | 258 | self.checks.append(Check(*args, **kwargs)) |
43 | 245 | 259 | ||
44 | === modified file 'tests/contrib/charmsupport/test_nrpe.py' | |||
45 | --- tests/contrib/charmsupport/test_nrpe.py 2016-07-29 10:15:48 +0000 | |||
46 | +++ tests/contrib/charmsupport/test_nrpe.py 2016-09-06 06:26:52 +0000 | |||
47 | @@ -90,8 +90,8 @@ | |||
48 | 90 | self.assertEqual(None, checker.write()) | 90 | self.assertEqual(None, checker.write()) |
49 | 91 | 91 | ||
50 | 92 | expected = 'Nagios user not set up, nrpe checks not updated' | 92 | expected = 'Nagios user not set up, nrpe checks not updated' |
53 | 93 | self.patched['log'].assert_called_once_with(expected) | 93 | self.patched['log'].assert_called_with(expected) |
54 | 94 | self.check_call_counts(log=1, config=1, getpwnam=1, getgrnam=1) | 94 | self.check_call_counts(log=2, config=1, getpwnam=1, getgrnam=1) |
55 | 95 | 95 | ||
56 | 96 | def test_write_no_checker(self): | 96 | def test_write_no_checker(self): |
57 | 97 | self.patched['config'].return_value = {'nagios_context': 'test', | 97 | self.patched['config'].return_value = {'nagios_context': 'test', |
58 | @@ -175,7 +175,7 @@ | |||
59 | 175 | self.patched['relation_set'].assert_has_calls(relation_set_calls, any_order=True) | 175 | self.patched['relation_set'].assert_has_calls(relation_set_calls, any_order=True) |
60 | 176 | self.check_call_counts(config=1, getpwnam=1, getgrnam=1, | 176 | self.check_call_counts(config=1, getpwnam=1, getgrnam=1, |
61 | 177 | exists=4, open=2, listdir=1, | 177 | exists=4, open=2, listdir=1, |
63 | 178 | relation_ids=2, relation_set=2) | 178 | relation_ids=4, relation_set=3) |
64 | 179 | 179 | ||
65 | 180 | 180 | ||
66 | 181 | class NRPECheckTestCase(NRPEBaseTestCase): | 181 | class NRPECheckTestCase(NRPEBaseTestCase): |
Calling relation_set without an explicit relation_id only works if inside a relation hook, so that needs to be fixed (see inline comments). Otherwise looking fine.