Merge lp:~lazypower/charms/trusty/etcd/trunk into lp:charms/trusty/etcd

Proposed by Charles Butler
Status: Merged
Merged at revision: 20
Proposed branch: lp:~lazypower/charms/trusty/etcd/trunk
Merge into: lp:charms/trusty/etcd
Diff against target: 63 lines (+26/-1)
3 files modified
hooks/client-relation-changed (+10/-0)
hooks/client-relation-joined (+8/-1)
hooks/hooks.py (+8/-0)
To merge this branch: bzr merge lp:~lazypower/charms/trusty/etcd/trunk
Reviewer Review Type Date Requested Status
Review Queue (community) automated testing Approve
Matt Bruzek (community) Approve
Review via email: mp+283220@code.launchpad.net

Description of the change

Updates to ETCD client realtionship behavior to match the emerging blueprint in interface:etcd interface layer.

https://github.com/chuckbutler/interface-etcd

To post a comment you must log in.
Revision history for this message
Matt Bruzek (mbruzek) wrote :

+1 LGTM

review: Approve
Revision history for this message
Review Queue (review-queue) wrote :

The results (PASS) are in and available here: http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/2261/

review: Approve (automated testing)
Revision history for this message
Review Queue (review-queue) wrote :

The results (PASS) are in and available here: http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/2240/

review: Approve (automated testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'hooks/client-relation-changed'
2--- hooks/client-relation-changed 1970-01-01 00:00:00 +0000
3+++ hooks/client-relation-changed 2016-01-19 21:20:53 +0000
4@@ -0,0 +1,10 @@
5+#!/bin/bash
6+set -ex
7+
8+leader=$(is-leader)
9+if [[ $leader == True ]]; then
10+ connection_string=$(chlp unitdata get etcd.connection_string)
11+ # maintain some backwords compatibility with the existing interface until it
12+ # is phased out w/ the layer rewrite.
13+ relation-set connection_string=$connection_string port=4001 public_address=`unit-get public-address`
14+fi
15
16=== modified file 'hooks/client-relation-joined'
17--- hooks/client-relation-joined 2014-08-31 20:16:26 +0000
18+++ hooks/client-relation-joined 2016-01-19 21:20:53 +0000
19@@ -1,3 +1,10 @@
20 #!/bin/bash
21 set -ex
22-relation-set port=4001 hostname=`unit-get private-address` public_hostname=`unit-get public-address`
23+
24+leader=$(is-leader)
25+if [[ $leader == True ]]; then
26+ connection_string=$(chlp unitdata get etcd.connection_string)
27+ # maintain some backwords compatibility with the existing interface until it
28+ # is phased out w/ the layer rewrite.
29+ relation-set connection_string=$connection_string port=4001 public_address=`unit-get public-address`
30+fi
31
32=== modified file 'hooks/hooks.py'
33--- hooks/hooks.py 2016-01-13 21:49:59 +0000
34+++ hooks/hooks.py 2016-01-19 21:20:53 +0000
35@@ -1,5 +1,7 @@
36 #!/usr/bin/env python
37 from charmhelpers.core import hookenv
38+from charmhelpers.core.hookenv import unit_get
39+from charmhelpers.core.hookenv import is_leader
40 from charmhelpers.core import unitdata
41 from charmhelpers.core import templating
42 from charmhelpers.core import host
43@@ -118,6 +120,7 @@
44 cluster_rels = hook_data.rels['cluster'][1].keys()
45 # introspect the cluster, and form the cluster string.
46 # https://github.com/coreos/etcd/blob/master/Documentation/configuration.md#-initial-cluster
47+ client_cluster = ['http://{}:7001'.format(unit_get('private-address'))]
48 if hook_data.rels['cluster'][1]:
49 reldata = hook_data.rels['cluster'][1][cluster_rels[0]]
50 for unit in reldata:
51@@ -125,9 +128,14 @@
52 cluster = '{}{}=http://{}:7001,'.format(cluster,
53 unit.replace('/', ''),
54 private)
55+ client_cluster.append('http://{}:7001'.format(private))
56 else:
57 cluster = "{}=http://{}:7001".format(unit_name, private_address)
58
59+ # Only the leader will be communicating with clients. Because he is
60+ # the grand poobah of Juju's ETCD story. The end.
61+ if is_leader():
62+ db.set('etcd.connection_string', ','.join(client_cluster))
63 return cluster.rstrip(',')
64
65

Subscribers

People subscribed via source and target branches

to all changes: