Merge lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/status-removed into lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk

Proposed by Cory Johns
Status: Merged
Merged at revision: 112
Proposed branch: lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/status-removed
Merge into: lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk
Diff against target: 191 lines (+95/-17)
6 files modified
hooks/callbacks.py (+24/-11)
hooks/common.py (+23/-5)
hooks/hadoop-plugin-relation-departed (+15/-0)
hooks/namenode-relation-departed (+16/-0)
hooks/resourcemanager-relation-departed (+16/-0)
resources.yaml (+1/-1)
To merge this branch: bzr merge lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/status-removed
Reviewer Review Type Date Requested Status
Kevin W Monroe Approve
Review via email: mp+267598@code.launchpad.net

Description of the change

Fixed status reporting not being accurate when relations were removed

To post a comment you must log in.
Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

LGTM

review: Approve
113. By Cory Johns

Added support for HDFS-only deployment

114. By Cory Johns

Bumped jujubigdata version to include required changes

Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

Sneaking these additional commits in post-approval was sneaky. They LGTM and are merged in trunk now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/callbacks.py'
2--- hooks/callbacks.py 2015-06-25 15:41:48 +0000
3+++ hooks/callbacks.py 2015-08-17 20:36:24 +0000
4@@ -24,28 +24,28 @@
5 def update_blocked_status():
6 if unitdata.kv().get('charm.active', False):
7 return
8- rels = (
9- ('Yarn', 'ResourceManager', ResourceManager()),
10+ rels = [
11 ('HDFS', 'NameNode', NameNode()),
12- )
13+ ]
14 missing_rel = [rel for rel, res, impl in rels if not impl.connected_units()]
15- missing_hosts = [rel for rel, res, impl in rels if not impl.am_i_registered()]
16- not_ready = [(rel, res) for rel, res, impl in rels if not impl.is_ready()]
17+ rels.append(('Yarn', 'ResourceManager', ResourceManager()))
18+ not_ready = [(rel, res) for rel, res, impl in rels if impl.connected_units() and not impl.is_ready()]
19+ missing_hosts = [rel for rel, res, impl in rels if impl.connected_units() and not impl.am_i_registered()]
20 if missing_rel:
21 hookenv.status_set('blocked', 'Waiting for relation to %s master%s' % (
22 ' and '.join(missing_rel),
23 's' if len(missing_rel) > 1 else '',
24 )),
25- elif missing_hosts:
26- hookenv.status_set('waiting', 'Waiting for /etc/hosts registration on %s' % (
27- ' and '.join(missing_hosts),
28- ))
29 elif not_ready:
30 unready_rels, unready_ress = zip(*not_ready)
31 hookenv.status_set('waiting', 'Waiting for %s to provide %s' % (
32 ' and '.join(unready_rels),
33 ' and '.join(unready_ress),
34 ))
35+ elif missing_hosts:
36+ hookenv.status_set('waiting', 'Waiting for /etc/hosts registration on %s' % (
37+ ' and '.join(missing_hosts),
38+ ))
39
40
41 def update_working_status():
42@@ -56,5 +56,18 @@
43
44
45 def update_active_status():
46- unitdata.kv().set('charm.active', True)
47- hookenv.status_set('active', 'Ready')
48+ hdfs_ready = NameNode().is_ready()
49+ yarn_connected = ResourceManager().connected_units()
50+ yarn_ready = ResourceManager().is_ready()
51+ if hdfs_ready and (not yarn_connected or yarn_ready):
52+ unitdata.kv().set('charm.active', True)
53+ hookenv.status_set('active', 'Ready%s' % (
54+ '' if yarn_ready else ' (HDFS only)'
55+ ))
56+ else:
57+ clear_active_flag()
58+ update_blocked_status()
59+
60+
61+def clear_active_flag():
62+ unitdata.kv().set('charm.active', False)
63
64=== modified file 'hooks/common.py'
65--- hooks/common.py 2015-08-06 18:28:14 +0000
66+++ hooks/common.py 2015-08-17 20:36:24 +0000
67@@ -80,26 +80,44 @@
68 ],
69 },
70 {
71- 'name': 'plugin',
72+ 'name': 'hdfs',
73 'provides': [
74 jujubigdata.relations.HadoopPlugin(),
75 ],
76 'requires': [
77 hadoop.is_installed,
78+ hdfs_relation,
79+ ],
80+ 'callbacks': [
81+ callbacks.update_working_status,
82+ hdfs_relation.register_provided_hosts,
83+ jujubigdata.utils.manage_etc_hosts,
84+ hdfs.configure_client,
85+ callbacks.update_active_status,
86+ ],
87+ 'cleanup': [
88+ callbacks.clear_active_flag,
89+ callbacks.update_blocked_status,
90+ ],
91+ },
92+ {
93+ 'name': 'yarn',
94+ 'provides': [],
95+ 'requires': [
96+ hadoop.is_installed,
97 yarn_relation,
98- hdfs_relation,
99 ],
100 'callbacks': [
101 callbacks.update_working_status,
102 yarn_relation.register_provided_hosts,
103- hdfs_relation.register_provided_hosts,
104 jujubigdata.utils.manage_etc_hosts,
105 yarn.install_demo,
106 yarn.configure_client,
107- hdfs.configure_client,
108 callbacks.update_active_status,
109 ],
110- 'cleanup': [],
111+ 'cleanup': [
112+ callbacks.update_blocked_status,
113+ ],
114 },
115 ])
116 manager.manage()
117
118=== added file 'hooks/hadoop-plugin-relation-departed'
119--- hooks/hadoop-plugin-relation-departed 1970-01-01 00:00:00 +0000
120+++ hooks/hadoop-plugin-relation-departed 2015-08-17 20:36:24 +0000
121@@ -0,0 +1,15 @@
122+#!.venv/bin/python
123+# Licensed under the Apache License, Version 2.0 (the "License");
124+# you may not use this file except in compliance with the License.
125+# You may obtain a copy of the License at
126+#
127+# http://www.apache.org/licenses/LICENSE-2.0
128+#
129+# Unless required by applicable law or agreed to in writing, software
130+# distributed under the License is distributed on an "AS IS" BASIS,
131+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132+# See the License for the specific language governing permissions and
133+# limitations under the License.
134+
135+import common
136+common.manage()
137
138=== added file 'hooks/namenode-relation-departed'
139--- hooks/namenode-relation-departed 1970-01-01 00:00:00 +0000
140+++ hooks/namenode-relation-departed 2015-08-17 20:36:24 +0000
141@@ -0,0 +1,16 @@
142+#!.venv/bin/python
143+# Licensed under the Apache License, Version 2.0 (the "License");
144+# you may not use this file except in compliance with the License.
145+# You may obtain a copy of the License at
146+#
147+# http://www.apache.org/licenses/LICENSE-2.0
148+#
149+# Unless required by applicable law or agreed to in writing, software
150+# distributed under the License is distributed on an "AS IS" BASIS,
151+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
152+# See the License for the specific language governing permissions and
153+# limitations under the License.
154+
155+import common
156+
157+common.manage()
158
159=== added file 'hooks/resourcemanager-relation-departed'
160--- hooks/resourcemanager-relation-departed 1970-01-01 00:00:00 +0000
161+++ hooks/resourcemanager-relation-departed 2015-08-17 20:36:24 +0000
162@@ -0,0 +1,16 @@
163+#!.venv/bin/python
164+# Licensed under the Apache License, Version 2.0 (the "License");
165+# you may not use this file except in compliance with the License.
166+# You may obtain a copy of the License at
167+#
168+# http://www.apache.org/licenses/LICENSE-2.0
169+#
170+# Unless required by applicable law or agreed to in writing, software
171+# distributed under the License is distributed on an "AS IS" BASIS,
172+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
173+# See the License for the specific language governing permissions and
174+# limitations under the License.
175+
176+import common
177+
178+common.manage()
179
180=== modified file 'resources.yaml'
181--- resources.yaml 2015-08-06 19:49:46 +0000
182+++ resources.yaml 2015-08-17 20:36:24 +0000
183@@ -4,7 +4,7 @@
184 pathlib:
185 pypi: path.py>=7.0
186 jujubigdata:
187- pypi: jujubigdata>=3.0.0,<4.0.0
188+ pypi: jujubigdata>=4.0.0,<5.0.0
189 charm-benchmark:
190 pypi: charm-benchmark>=1.0.1,<2.0.0
191 java-installer:

Subscribers

People subscribed via source and target branches

to all changes: