Merge lp:~michael.nelson/charms/trusty/logstash/fix-missing-host-client-changed into lp:~canonical-is-sa/charms/trusty/logstash/logstash2

Proposed by Michael Nelson
Status: Merged
Merged at revision: 57
Proposed branch: lp:~michael.nelson/charms/trusty/logstash/fix-missing-host-client-changed
Merge into: lp:~canonical-is-sa/charms/trusty/logstash/logstash2
Diff against target: 13 lines (+2/-1)
1 file modified
hooks/client-relation-changed (+2/-1)
To merge this branch: bzr merge lp:~michael.nelson/charms/trusty/logstash/fix-missing-host-client-changed
Reviewer Review Type Date Requested Status
Michael Foley (community) Approve
Review via email: mp+276941@code.launchpad.net

Commit message

Add guard for first client-relation-changed without host data.

Description of the change

We hit this issue on ci [1], but turns out it was reproducible locally (I'd only tested upgrading).

After a bit of debugging (by writing relations to a tmp file, because the issue disappears before you can do resolved --retry), I found the relation data for this can look like:

[{u'private-address': u'10.0.3.112', u'host': u'10.0.3.112', u'cluster-name': u'canonical-is-logging-devel', '__unit__': u'elasticsearch/0', '__relid__': u'client:5', u'port': u'9200'}, {u'private-address': u'10.0.3.104', '__unit__': u'elasticsearch/1', '__relid__': u'client:5'}]

The first client has all the data, the second does not yet.
. This change just adds a guard for that scenario.

Tested locally.

[1] https://ci.admin.canonical.com/job/wip-is-logging-kibana-1511/125/console

To post a comment you must log in.
Revision history for this message
Michael Foley (foli) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/client-relation-changed'
2--- hooks/client-relation-changed 2015-11-06 04:06:29 +0000
3+++ hooks/client-relation-changed 2015-11-08 22:37:06 +0000
4@@ -32,7 +32,8 @@
5 log('No client relations. Assuming nothing to do.')
6 sys.exit(0)
7 hosts = json.dumps(
8- ["%s:%s" % (client['host'], client['port']) for client in rels])
9+ ["%s:%s" % (client['host'], client['port']) for client in rels
10+ if 'host' in client])
11
12 out = os.path.join(BASEPATH, 'conf.d', 'output-elasticsearch.conf')
13 with open(out, 'w') as p:

Subscribers

People subscribed via source and target branches