config-changed hook fails: nrpe_helpers.py:nagios_hostname in _metadata_unit with FileNotFoundError error for metadata.yaml of related unit on another host
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Charm Helpers |
Fix Released
|
Undecided
|
Unassigned | ||
NRPE Charm |
Fix Released
|
Undecided
|
Xav Paice | ||
Nagios Charm |
Fix Released
|
Undecided
|
Xav Paice |
Bug Description
Due to recent changes, nrpe_helpers.
On Juju 2.1 or earlier, it does this by walking all relations of the unit and inspecting it's metadata file using _metadata_unit.
This fails because it attempts to inspect units on another host, i.e. the parent nagios unit and _metadata_unit fires a FileNotFoundError exception for the file that doesn't exist.
You can simulate this on Juju 2.2 by commenting out the Juju 2.2 checks at the start and deploying the nagios and nrpe charms on separate machines.
Traceback (most recent call last):
File "/var/lib/
services.
File "/var/lib/
nrpe_
File "/var/lib/
self[
File "/var/lib/
principle_
File "/var/lib/
md = _metadata_
File "/var/lib/
with open(os.
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/
Related branches
- Stuart Bishop (community): Approve
-
Diff: 22 lines (+6/-1)1 file modifiedcharmhelpers/core/hookenv.py (+6/-1)
- James Hebden (community): Approve
-
Diff: 23 lines (+6/-1)1 file modifiedhooks/charmhelpers/core/hookenv.py (+6/-1)
- James Hebden (community): Approve
-
Diff: 107 lines (+42/-23)2 files modifiedhooks/charmhelpers/core/hookenv.py (+6/-1)
hooks/charmhelpers/fetch/ubuntu.py (+36/-22)
Changed in charm-helpers: | |
status: | New → Confirmed |
Changed in nrpe-charm: | |
status: | New → Confirmed |
tags: | added: canonical-bootstack |
Changed in charm-helpers: | |
status: | Confirmed → Fix Committed |
Changed in charm-helpers: | |
status: | Fix Committed → Fix Released |
Changed in nrpe-charm: | |
assignee: | nobody → Xav Paice (xavpaice) |
Changed in nagios-charm: | |
assignee: | nobody → Xav Paice (xavpaice) |
status: | Fix Committed → Fix Released |
This also affects the Nagios charm, e.g.:
(added pdb.set_trace() to L210 of core/hookenv.py)
root@juju- machine- 0-lxc-6: /var/lib/ juju/agents/ unit-nagios- 0/charm# ./hooks/ upgrade- charm juju/agents/ unit-nagios- 0/charm/ hooks/charmhelp ers/core/ hookenv. py(218) principal_ unit() 'JUJU_UNIT_ NAME']
> /var/lib/
-> for reltype in relation_types():
(Pdb) principal_unit
(Pdb) os.environ[
'nagios/0'
(Pdb) relation_types()
['website', 'monitors', 'nagios']
(Pdb) relation_ ids('monitors' ) units(' monitors: 143')
[u'monitors:143', u'monitors:144', u'monitors:148']
(Pdb) related_
[u'nrpe/0', u'nrpe/1', u'nrpe/10', u'nrpe/11', u'nrpe/12', u'nrpe/13', u'nrpe/14', u'nrpe/15', u'nrpe/16', u'nrpe/17', u'nrpe/19', u'nrpe/2', u'nrpe/20', u'nrpe/3', u'nrpe/4', u'nrpe/5', u'nrpe/6', u'nrpe/7', u'nrpe/8', u'nrpe/9']
(Pdb) _metadata_ unit('nrpe/ 1') juju/agents/ unit-nrpe- 1/charm/ metadata. yaml'
*** IOError: [Errno 2] No such file or directory: '/var/lib/
(Pdb) relation_ ids('nagios' )
[]
This change seems to come about from rev 773 (merge/rebase) which adds the principal_unit().