Merge lp:~bigdata-dev/charms/trusty/hdp-zookeeper/trunk into lp:charms/trusty/hdp-zookeeper

Proposed by amir sanjar
Status: Merged
Merged at revision: 20
Proposed branch: lp:~bigdata-dev/charms/trusty/hdp-zookeeper/trunk
Merge into: lp:charms/trusty/hdp-zookeeper
Diff against target: 145 lines (+31/-17)
7 files modified
README.md (+5/-0)
bundles.yaml (+0/-10)
config.yaml (+5/-0)
hooks/bdutils.py (+4/-1)
hooks/hooks.py (+5/-4)
tests/10-deploy (+2/-2)
tests/bundles.yaml (+10/-0)
To merge this branch: bzr merge lp:~bigdata-dev/charms/trusty/hdp-zookeeper/trunk
Reviewer Review Type Date Requested Status
Charles Butler (community) Approve
charmers Pending
Review via email: mp+243358@code.launchpad.net

Description of the change

adding single node support - having single node zookeeper is NOT RECOMMENDED for production

To post a comment you must log in.
Revision history for this message
Charles Butler (lazypower) wrote :

Greetings Amir,

While this is a nice addition to the zookeeper charm, supporting single node deployment - it doesn't appear there was a test added to validate this configuration, nor was the readme updated to reflect the option of a single node deployment.

If you could get those added I'd be more than happy to re-review this branch for inclusion in the upstream charm.

review: Needs Fixing
21. By amir sanjar

merging code review suggestion

Revision history for this message
Charles Butler (lazypower) wrote :

+1 LGTM

Thanks for the fixes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2014-09-09 02:07:17 +0000
3+++ README.md 2014-12-08 20:19:18 +0000
4@@ -13,6 +13,11 @@
5 To learn more about ZooKeeper visit the upstream [docs](http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.1.3/bk_installing_manually_book/content/rpm-zookeeper.html)
6
7 # Deployment Strategy
8+
9+Instruction to create a zookeeper node :
10+
11+ juju deploy hdp-zookeeper hdp-zookeeper
12+
13
14 Step by step instructions to create a zookeeper quorum :
15
16
17=== removed file 'bundles.yaml'
18--- bundles.yaml 2014-08-27 17:02:39 +0000
19+++ bundles.yaml 1970-01-01 00:00:00 +0000
20@@ -1,10 +0,0 @@
21-hdp-zookeeper-quorum:
22- services:
23- "hdp-zookeeper":
24- charm: "cs:~asanjar/trusty/hdp-zookeeper"
25- num_units: 3
26- annotations:
27- "gui-x": "1201.0940759645143"
28- "gui-y": "462.5"
29- relations: []
30- series: trusty
31
32=== modified file 'config.yaml'
33--- config.yaml 2014-08-02 02:02:26 +0000
34+++ config.yaml 2014-12-08 20:19:18 +0000
35@@ -3,3 +3,8 @@
36 type: string
37 default: "/grid/hadoop/zookeeper/data"
38 description: "Directory where ZooKeeper will store data."
39+ zk-port:
40+ type: int
41+ default: 2181
42+ description: ZooKeeper Client Access Port
43+
44
45=== modified file 'hooks/bdutils.py'
46--- hooks/bdutils.py 2014-08-02 02:02:26 +0000
47+++ hooks/bdutils.py 2014-12-08 20:19:18 +0000
48@@ -58,14 +58,17 @@
49 f.writelines(contents)
50
51 def fileRemoveKey(filePath, key):
52- log ("===> fileRemoveK ({}, {})".format(filePath, key))
53+ log ("===> fileRemoveKey ({}, {})".format(filePath, key))
54 found = False
55+ print key
56 with open(filePath) as f:
57 contents = f.readlines()
58+ print contents
59 for l in range(0, len(contents)):
60 if contents[l].startswith(key):
61 contents.pop(l)
62 found = True
63+ break
64 if found:
65 with open(filePath, 'wb') as f:
66 f.writelines(contents)
67
68=== modified file 'hooks/hooks.py'
69--- hooks/hooks.py 2014-10-23 00:40:20 +0000
70+++ hooks/hooks.py 2014-12-08 20:19:18 +0000
71@@ -9,7 +9,7 @@
72 from hdputils import install_base_pkg, updateHDPDirectoryScript, config_all_nodes, setHadoopEnvVar, home, hdpScript
73 from bdutils import setDirPermission, fileSetKV, fileRemoveKey
74 from charmhelpers.lib.utils import config_get
75-from charmhelpers.core.hookenv import log, Hooks, relation_get, open_port, related_units, local_unit, unit_get
76+from charmhelpers.core.hookenv import log, Hooks, relation_get, open_port, related_units, local_unit, unit_get, relation_set
77 from charmhelpers.core.host import add_user_to_group
78
79 sys.path.insert(0, os.path.join(os.environ['CHARM_DIR'], 'lib'))
80@@ -79,6 +79,8 @@
81 df.writelines(getid(local_unit()))
82 zkhost = unit_get('private-address')
83 fileSetKV(zoocfg, "dataDir=", data_path)
84+ # cleaning up zookeeper config
85+ fileRemoveKey(zoocfg, "server.1=")
86 fileSetKV(zoocfg, "server"+"."+getid(local_unit())+"=", zkhost+":2888:3888")
87 setZKConf()
88
89@@ -98,12 +100,10 @@
90 packages =['ntp', 'openjdk-7-jdk',"zookeeper"]
91 install_base_pkg(packages)
92 config_zk_nodes()
93- fileSetKV(zoocfg, "server"+"."+getid(local_unit())+"=", unit_get('private-address')+":2888:3888")
94- open_port(2181)
95+ open_port(config_get('zk-port'))
96 open_port(2888)
97 open_port(3888)
98
99- log('Installing hdp-zookeeper')
100
101
102 @hooks.hook('config-changed')
103@@ -152,6 +152,7 @@
104 @hooks.hook('zookeeper-relation-joined')
105 def zookeeper_relation_joined():
106 log('==> zookeeper_relation_joined')
107+ relation_set(port=config_get('zk-port'))
108
109 if __name__ == "__main__":
110 # execute a hook based on the name the program is called by
111
112=== modified file 'tests/10-deploy'
113--- tests/10-deploy 2014-08-27 23:52:36 +0000
114+++ tests/10-deploy 2014-12-08 20:19:18 +0000
115@@ -8,7 +8,7 @@
116 class TestDeployment(object):
117 def __init__(self):
118 self.d = amulet.Deployment(series='trusty')
119- f = open('bundles.yaml')
120+ f = open(os.path.join(os.path.dirname(__file__), 'bundles.yaml'))
121 bun = f.read()
122 self.d.load(yaml.safe_load(bun))
123 #self.d.add('hdp-zookeeper', charm='~/development/charms/trusty/hdp-zookeeper', units=3)
124@@ -50,4 +50,4 @@
125
126 if __name__ == '__main__':
127 runner = TestDeployment()
128- runner.run()
129\ No newline at end of file
130+ runner.run()
131
132=== added file 'tests/bundles.yaml'
133--- tests/bundles.yaml 1970-01-01 00:00:00 +0000
134+++ tests/bundles.yaml 2014-12-08 20:19:18 +0000
135@@ -0,0 +1,10 @@
136+hdp-zookeeper-quorum:
137+ services:
138+ "hdp-zookeeper":
139+ charm: "cs:~asanjar/trusty/hdp-zookeeper"
140+ num_units: 3
141+ annotations:
142+ "gui-x": "1201.0940759645143"
143+ "gui-y": "462.5"
144+ relations: []
145+ series: trusty

Subscribers

People subscribed via source and target branches