Merge lp:~barryprice/charms/xenial/daisy-retracer/trunk into lp:~daisy-pluckers/charms/xenial/daisy-retracer/trunk

Proposed by Barry Price
Status: Merged
Merged at revision: 213
Proposed branch: lp:~barryprice/charms/xenial/daisy-retracer/trunk
Merge into: lp:~daisy-pluckers/charms/xenial/daisy-retracer/trunk
Diff against target: 14 lines (+4/-0)
1 file modified
hooks/common (+4/-0)
To merge this branch: bzr merge lp:~barryprice/charms/xenial/daisy-retracer/trunk
Reviewer Review Type Date Requested Status
Daisy Pluckers Pending
Review via email: mp+400239@code.launchpad.net

Commit message

Ensure nrpe relation actually has a unit ID before attempting to use it

Seen deploying a couple of new units recently, when RELATION_ID was defined, but a relation-list didn't yet return any units:

+ nrpe_setup
++ relation-ids nrpe-external-master
+ RELATION_ID=nrpe-external-master:193
+ '[' -z nrpe-external-master:193 ']'
++ relation-list -r nrpe-external-master:193
+ relation_unit=
++ relation-get -r nrpe-external-master:193 nagios_host_context
ERROR no unit or application specified
+ nagios_host_context=

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/common'
2--- hooks/common 2020-06-09 01:54:06 +0000
3+++ hooks/common 2021-03-26 09:45:25 +0000
4@@ -310,6 +310,10 @@
5 return 0
6 fi
7 relation_unit=$(relation-list -r $RELATION_ID)
8+ if [ -z "$relation_unit" ]; then
9+ echo "No nrpe-external-master relation unit yet. Skipping nrpe setup"
10+ return 0
11+ fi
12 nagios_host_context=$(relation-get -r $RELATION_ID nagios_host_context $relation_unit)
13 export NAGIOS_HOSTNAME=$(relation-get -r $RELATION_ID nagios_hostname $relation_unit)
14 export INSTANCE_TYPE

Subscribers

People subscribed via source and target branches

to all changes: