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
=== modified file 'hooks/callbacks.py'
--- hooks/callbacks.py 2015-06-25 15:41:48 +0000
+++ hooks/callbacks.py 2015-08-17 20:36:24 +0000
@@ -24,28 +24,28 @@
24def update_blocked_status():24def update_blocked_status():
25 if unitdata.kv().get('charm.active', False):25 if unitdata.kv().get('charm.active', False):
26 return26 return
27 rels = (27 rels = [
28 ('Yarn', 'ResourceManager', ResourceManager()),
29 ('HDFS', 'NameNode', NameNode()),28 ('HDFS', 'NameNode', NameNode()),
30 )29 ]
31 missing_rel = [rel for rel, res, impl in rels if not impl.connected_units()]30 missing_rel = [rel for rel, res, impl in rels if not impl.connected_units()]
32 missing_hosts = [rel for rel, res, impl in rels if not impl.am_i_registered()]31 rels.append(('Yarn', 'ResourceManager', ResourceManager()))
33 not_ready = [(rel, res) for rel, res, impl in rels if not impl.is_ready()]32 not_ready = [(rel, res) for rel, res, impl in rels if impl.connected_units() and not impl.is_ready()]
33 missing_hosts = [rel for rel, res, impl in rels if impl.connected_units() and not impl.am_i_registered()]
34 if missing_rel:34 if missing_rel:
35 hookenv.status_set('blocked', 'Waiting for relation to %s master%s' % (35 hookenv.status_set('blocked', 'Waiting for relation to %s master%s' % (
36 ' and '.join(missing_rel),36 ' and '.join(missing_rel),
37 's' if len(missing_rel) > 1 else '',37 's' if len(missing_rel) > 1 else '',
38 )),38 )),
39 elif missing_hosts:
40 hookenv.status_set('waiting', 'Waiting for /etc/hosts registration on %s' % (
41 ' and '.join(missing_hosts),
42 ))
43 elif not_ready:39 elif not_ready:
44 unready_rels, unready_ress = zip(*not_ready)40 unready_rels, unready_ress = zip(*not_ready)
45 hookenv.status_set('waiting', 'Waiting for %s to provide %s' % (41 hookenv.status_set('waiting', 'Waiting for %s to provide %s' % (
46 ' and '.join(unready_rels),42 ' and '.join(unready_rels),
47 ' and '.join(unready_ress),43 ' and '.join(unready_ress),
48 ))44 ))
45 elif missing_hosts:
46 hookenv.status_set('waiting', 'Waiting for /etc/hosts registration on %s' % (
47 ' and '.join(missing_hosts),
48 ))
4949
5050
51def update_working_status():51def update_working_status():
@@ -56,5 +56,18 @@
5656
5757
58def update_active_status():58def update_active_status():
59 unitdata.kv().set('charm.active', True)59 hdfs_ready = NameNode().is_ready()
60 hookenv.status_set('active', 'Ready')60 yarn_connected = ResourceManager().connected_units()
61 yarn_ready = ResourceManager().is_ready()
62 if hdfs_ready and (not yarn_connected or yarn_ready):
63 unitdata.kv().set('charm.active', True)
64 hookenv.status_set('active', 'Ready%s' % (
65 '' if yarn_ready else ' (HDFS only)'
66 ))
67 else:
68 clear_active_flag()
69 update_blocked_status()
70
71
72def clear_active_flag():
73 unitdata.kv().set('charm.active', False)
6174
=== modified file 'hooks/common.py'
--- hooks/common.py 2015-08-06 18:28:14 +0000
+++ hooks/common.py 2015-08-17 20:36:24 +0000
@@ -80,26 +80,44 @@
80 ],80 ],
81 },81 },
82 {82 {
83 'name': 'plugin',83 'name': 'hdfs',
84 'provides': [84 'provides': [
85 jujubigdata.relations.HadoopPlugin(),85 jujubigdata.relations.HadoopPlugin(),
86 ],86 ],
87 'requires': [87 'requires': [
88 hadoop.is_installed,88 hadoop.is_installed,
89 hdfs_relation,
90 ],
91 'callbacks': [
92 callbacks.update_working_status,
93 hdfs_relation.register_provided_hosts,
94 jujubigdata.utils.manage_etc_hosts,
95 hdfs.configure_client,
96 callbacks.update_active_status,
97 ],
98 'cleanup': [
99 callbacks.clear_active_flag,
100 callbacks.update_blocked_status,
101 ],
102 },
103 {
104 'name': 'yarn',
105 'provides': [],
106 'requires': [
107 hadoop.is_installed,
89 yarn_relation,108 yarn_relation,
90 hdfs_relation,
91 ],109 ],
92 'callbacks': [110 'callbacks': [
93 callbacks.update_working_status,111 callbacks.update_working_status,
94 yarn_relation.register_provided_hosts,112 yarn_relation.register_provided_hosts,
95 hdfs_relation.register_provided_hosts,
96 jujubigdata.utils.manage_etc_hosts,113 jujubigdata.utils.manage_etc_hosts,
97 yarn.install_demo,114 yarn.install_demo,
98 yarn.configure_client,115 yarn.configure_client,
99 hdfs.configure_client,
100 callbacks.update_active_status,116 callbacks.update_active_status,
101 ],117 ],
102 'cleanup': [],118 'cleanup': [
119 callbacks.update_blocked_status,
120 ],
103 },121 },
104 ])122 ])
105 manager.manage()123 manager.manage()
106124
=== added file 'hooks/hadoop-plugin-relation-departed'
--- hooks/hadoop-plugin-relation-departed 1970-01-01 00:00:00 +0000
+++ hooks/hadoop-plugin-relation-departed 2015-08-17 20:36:24 +0000
@@ -0,0 +1,15 @@
1#!.venv/bin/python
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import common
15common.manage()
016
=== added file 'hooks/namenode-relation-departed'
--- hooks/namenode-relation-departed 1970-01-01 00:00:00 +0000
+++ hooks/namenode-relation-departed 2015-08-17 20:36:24 +0000
@@ -0,0 +1,16 @@
1#!.venv/bin/python
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import common
15
16common.manage()
017
=== added file 'hooks/resourcemanager-relation-departed'
--- hooks/resourcemanager-relation-departed 1970-01-01 00:00:00 +0000
+++ hooks/resourcemanager-relation-departed 2015-08-17 20:36:24 +0000
@@ -0,0 +1,16 @@
1#!.venv/bin/python
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import common
15
16common.manage()
017
=== modified file 'resources.yaml'
--- resources.yaml 2015-08-06 19:49:46 +0000
+++ resources.yaml 2015-08-17 20:36:24 +0000
@@ -4,7 +4,7 @@
4 pathlib:4 pathlib:
5 pypi: path.py>=7.05 pypi: path.py>=7.0
6 jujubigdata:6 jujubigdata:
7 pypi: jujubigdata>=3.0.0,<4.0.07 pypi: jujubigdata>=4.0.0,<5.0.0
8 charm-benchmark:8 charm-benchmark:
9 pypi: charm-benchmark>=1.0.1,<2.0.09 pypi: charm-benchmark>=1.0.1,<2.0.0
10 java-installer:10 java-installer:

Subscribers

People subscribed via source and target branches

to all changes: