Merge lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-master/status into lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-master/trunk

Proposed by Cory Johns
Status: Merged
Merge reported by: Cory Johns
Merged at revision: not available
Proposed branch: lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-master/status
Merge into: lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-master/trunk
Diff against target: 327 lines (+130/-33)
11 files modified
hooks/callbacks.py (+22/-0)
hooks/common.py (+22/-14)
hooks/config-changed (+11/-0)
hooks/datanode-relation-changed (+11/-0)
hooks/install (+11/-0)
hooks/namenode-relation-changed (+11/-0)
hooks/secondary-relation-changed (+11/-0)
hooks/setup.py (+8/-10)
hooks/start (+11/-0)
hooks/stop (+11/-0)
resources.yaml (+1/-9)
To merge this branch: bzr merge lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-master/status
Reviewer Review Type Date Requested Status
Kevin W Monroe Approve
Review via email: mp+262926@code.launchpad.net

Description of the change

Added extended status support.

Example status (tabular) outputs:

http://pastebin.ubuntu.com/11769979/ (in progress)
http://pastebin.ubuntu.com/11770196/ (complete)

Example status-history outputs:

http://pastebin.ubuntu.com/11770192/ (hdfs-master)
http://pastebin.ubuntu.com/11770195/ (compute-slave)

To post a comment you must log in.
Revision history for this message
Cory Johns (johnsca) wrote :

I also bundled charmhelpers and its dependencies, since there is almost no churn on it now and it made the status handling code cleaner as I could depend on hookenv.status_set() always being there.

87. By Cory Johns

Nested python resources to avoid attempting to pip install future non-python resources

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

status + bundled resources LGTM, +1.

Merged into to -dev/trunk in r87.

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-05-12 21:56:03 +0000
3+++ hooks/callbacks.py 2015-06-25 13:44:10 +0000
4@@ -15,3 +15,25 @@
5 Add any additional tasks / setup here. If a callback is used by mutliple
6 charms, consider refactoring it up to the jujubigdata library.
7 """
8+
9+from charmhelpers.core import hookenv
10+from charmhelpers.core import unitdata
11+from jujubigdata.relations import DataNode
12+
13+
14+def update_working_status():
15+ if unitdata.kv().get('charm.active', False):
16+ hookenv.status_set('maintenance', 'Updating configuration')
17+ return
18+ hookenv.status_set('maintenance', 'Setting up HDFS master')
19+
20+
21+def update_active_status():
22+ datanode = DataNode()
23+ if datanode.is_ready():
24+ hookenv.status_set('active', 'Ready (%s DataNodes)' % len(datanode.filtered_data()))
25+ unitdata.kv().set('charm.active', True)
26+ elif datanode.connected_units():
27+ hookenv.status_set('waiting', 'Waiting for compute slaves to provide DataNodes')
28+ else:
29+ hookenv.status_set('blocked', 'Waiting for relation to compute slaves')
30
31=== modified file 'hooks/common.py'
32--- hooks/common.py 2015-06-19 17:25:28 +0000
33+++ hooks/common.py 2015-06-25 13:44:10 +0000
34@@ -12,37 +12,39 @@
35 # limitations under the License.
36
37 import jujuresources
38-
39-
40-def status_set(status, message):
41- import subprocess
42- try:
43- subprocess.check_call(['status-set', status, message])
44- except (subprocess.CalledProcessError, OSError):
45- jujuresources.juju_log('status: {}: {}'.format(status, message), 'ERROR')
46+from charmhelpers.core import hookenv
47+from charmhelpers.core import unitdata
48+from charmhelpers.core import charmframework
49
50
51 def bootstrap_resources():
52 """
53 Install required resources defined in resources.yaml
54 """
55+ if unitdata.kv().get('charm.bootstrapped', False):
56+ return True
57+ hookenv.status_set('maintenance', 'Installing base resources')
58 mirror_url = jujuresources.config_get('resources_mirror')
59 if not jujuresources.fetch(mirror_url=mirror_url):
60- status_set('blocked', 'Resources unavailable; manual intervention required')
61+ missing = jujuresources.invalid()
62+ hookenv.status_set('blocked', 'Unable to fetch required resource%s: %s' % (
63+ 's' if len(missing) > 1 else '',
64+ ', '.join(missing),
65+ ))
66 return False
67- jujuresources.install(['pathlib', 'pyaml', 'six', 'charmhelpers', 'jujubigdata'])
68+ jujuresources.install(['pathlib', 'jujubigdata'])
69+ unitdata.kv().set('charm.bootstrapped', True)
70 return True
71
72
73 def manage():
74 if not bootstrap_resources():
75- # defer until resources are available, since charmhelpers, and thus
76- # the framework, (will be) managed by jujuresources
77+ # defer until resources are available, since jujubigdata, and thus the
78+ # classes needed for the requires blocks, (will be) managed by jujuresources
79 return
80
81- from charmhelpers.core import charmframework
82 import jujubigdata
83- import callbacks # noqa (ignore when linting)
84+ import callbacks
85
86 # list of keys required to be in the dist.yaml
87 master_reqs = ['vendor', 'hadoop_version', 'packages', 'groups', 'users',
88@@ -80,6 +82,11 @@
89 jujubigdata.relations.SecondaryNameNode(optional=True),
90 ],
91 'callbacks': [
92+ # These callbacks will be executed once the Hadoop base packages
93+ # are installed. New items can be added to the end of this list
94+ # and to hooks/callbacks.py to extend the functionality of this
95+ # charm.
96+ callbacks.update_working_status,
97 datanodes.register_connected_hosts,
98 secondary.register_connected_hosts,
99 jujubigdata.utils.manage_etc_hosts,
100@@ -89,6 +96,7 @@
101 hdfs.start_namenode,
102 hdfs.create_hdfs_dirs,
103 charmframework.helpers.open_ports(dist_config.exposed_ports('hdfs-master')),
104+ callbacks.update_active_status,
105 ],
106 'cleanup': [
107 charmframework.helpers.close_ports(dist_config.exposed_ports('hdfs-master')),
108
109=== modified file 'hooks/config-changed'
110--- hooks/config-changed 2015-02-09 18:19:59 +0000
111+++ hooks/config-changed 2015-06-25 13:44:10 +0000
112@@ -11,5 +11,16 @@
113 # See the License for the specific language governing permissions and
114 # limitations under the License.
115
116+"""
117+All hooks in this charm are managed by the Charm Framework.
118+The framework helps manage dependencies and preconditions to ensure that
119+steps are only executed when they can be successful. As such, no additional
120+code should be added to this hook; instead, please integrate new functionality
121+into the 'callbacks' list in hooks/common.py. New callbacks can be placed
122+in hooks/callbacks.py, if necessary.
123+
124+See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
125+for more information.
126+"""
127 import common
128 common.manage()
129
130=== modified file 'hooks/datanode-relation-changed'
131--- hooks/datanode-relation-changed 2015-05-12 21:56:03 +0000
132+++ hooks/datanode-relation-changed 2015-06-25 13:44:10 +0000
133@@ -11,5 +11,16 @@
134 # See the License for the specific language governing permissions and
135 # limitations under the License.
136
137+"""
138+All hooks in this charm are managed by the Charm Framework.
139+The framework helps manage dependencies and preconditions to ensure that
140+steps are only executed when they can be successful. As such, no additional
141+code should be added to this hook; instead, please integrate new functionality
142+into the 'callbacks' list in hooks/common.py. New callbacks can be placed
143+in hooks/callbacks.py, if necessary.
144+
145+See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
146+for more information.
147+"""
148 import common
149 common.manage()
150
151=== modified file 'hooks/install'
152--- hooks/install 2015-02-09 18:19:59 +0000
153+++ hooks/install 2015-06-25 13:44:10 +0000
154@@ -13,5 +13,16 @@
155 import setup
156 setup.pre_install()
157
158+"""
159+All hooks in this charm are managed by the Charm Framework.
160+The framework helps manage dependencies and preconditions to ensure that
161+steps are only executed when they can be successful. As such, no additional
162+code should be added to this hook; instead, please integrate new functionality
163+into the 'callbacks' list in hooks/common.py. New callbacks can be placed
164+in hooks/callbacks.py, if necessary.
165+
166+See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
167+for more information.
168+"""
169 import common
170 common.manage()
171
172=== modified file 'hooks/namenode-relation-changed'
173--- hooks/namenode-relation-changed 2015-05-12 21:56:03 +0000
174+++ hooks/namenode-relation-changed 2015-06-25 13:44:10 +0000
175@@ -11,5 +11,16 @@
176 # See the License for the specific language governing permissions and
177 # limitations under the License.
178
179+"""
180+All hooks in this charm are managed by the Charm Framework.
181+The framework helps manage dependencies and preconditions to ensure that
182+steps are only executed when they can be successful. As such, no additional
183+code should be added to this hook; instead, please integrate new functionality
184+into the 'callbacks' list in hooks/common.py. New callbacks can be placed
185+in hooks/callbacks.py, if necessary.
186+
187+See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
188+for more information.
189+"""
190 import common
191 common.manage()
192
193=== modified file 'hooks/secondary-relation-changed'
194--- hooks/secondary-relation-changed 2015-05-12 21:56:03 +0000
195+++ hooks/secondary-relation-changed 2015-06-25 13:44:10 +0000
196@@ -11,5 +11,16 @@
197 # See the License for the specific language governing permissions and
198 # limitations under the License.
199
200+"""
201+All hooks in this charm are managed by the Charm Framework.
202+The framework helps manage dependencies and preconditions to ensure that
203+steps are only executed when they can be successful. As such, no additional
204+code should be added to this hook; instead, please integrate new functionality
205+into the 'callbacks' list in hooks/common.py. New callbacks can be placed
206+in hooks/callbacks.py, if necessary.
207+
208+See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
209+for more information.
210+"""
211 import common
212 common.manage()
213
214=== modified file 'hooks/setup.py'
215--- hooks/setup.py 2015-03-03 21:30:47 +0000
216+++ hooks/setup.py 2015-06-25 13:44:10 +0000
217@@ -12,24 +12,22 @@
218 import subprocess
219 from glob import glob
220
221+
222 def pre_install():
223 """
224 Do any setup required before the install hook.
225 """
226 install_pip()
227- install_jujuresources()
228+ install_bundled_resources()
229
230
231 def install_pip():
232 subprocess.check_call(['apt-get', 'install', '-yq', 'python-pip', 'bzr'])
233
234
235-def install_jujuresources():
236- """
237- Install the bundled jujuresources library, if not present.
238- """
239- try:
240- import jujuresources # noqa
241- except ImportError:
242- jr_archive = glob('resources/jujuresources-*.tar.gz')[0]
243- subprocess.check_call(['pip', 'install', jr_archive])
244+def install_bundled_resources():
245+ """
246+ Install the bundled resources libraries.
247+ """
248+ archives = glob('resources/python/*')
249+ subprocess.check_call(['pip', 'install'] + archives)
250
251=== modified file 'hooks/start'
252--- hooks/start 2015-02-09 18:19:59 +0000
253+++ hooks/start 2015-06-25 13:44:10 +0000
254@@ -11,5 +11,16 @@
255 # See the License for the specific language governing permissions and
256 # limitations under the License.
257
258+"""
259+All hooks in this charm are managed by the Charm Framework.
260+The framework helps manage dependencies and preconditions to ensure that
261+steps are only executed when they can be successful. As such, no additional
262+code should be added to this hook; instead, please integrate new functionality
263+into the 'callbacks' list in hooks/common.py. New callbacks can be placed
264+in hooks/callbacks.py, if necessary.
265+
266+See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
267+for more information.
268+"""
269 import common
270 common.manage()
271
272=== modified file 'hooks/stop'
273--- hooks/stop 2015-02-09 18:19:59 +0000
274+++ hooks/stop 2015-06-25 13:44:10 +0000
275@@ -11,5 +11,16 @@
276 # See the License for the specific language governing permissions and
277 # limitations under the License.
278
279+"""
280+All hooks in this charm are managed by the Charm Framework.
281+The framework helps manage dependencies and preconditions to ensure that
282+steps are only executed when they can be successful. As such, no additional
283+code should be added to this hook; instead, please integrate new functionality
284+into the 'callbacks' list in hooks/common.py. New callbacks can be placed
285+in hooks/callbacks.py, if necessary.
286+
287+See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
288+for more information.
289+"""
290 import common
291 common.manage()
292
293=== modified file 'resources.yaml'
294--- resources.yaml 2015-06-19 17:25:28 +0000
295+++ resources.yaml 2015-06-25 13:44:10 +0000
296@@ -3,16 +3,8 @@
297 resources:
298 pathlib:
299 pypi: path.py>=7.0
300- pyaml:
301- pypi: pyaml
302- six:
303- pypi: six
304 jujubigdata:
305- pypi: jujubigdata>=2.0.0,<3.0.0
306- charmhelpers:
307- pypi: http://bazaar.launchpad.net/~bigdata-dev/bigdata-data/trunk/download/kevin.monroe%40canonical.com-20150610215108-gq4ud2rriy1sp1h6/charmhelpers0.3.1.ta-20150610215050-vxrqhizdsrqwnmcm-1/charmhelpers-0.3.1.tar.gz
308- hash: 061fe7204289b96fab5d3ca02883040ea3026526ebf0ad38e21457527a18d139
309- hash_type: sha256
310+ pypi: jujubigdata>=2.0.2,<3.0.0
311 java-installer:
312 # This points to a script which manages installing Java.
313 # If replaced with an alternate implementation, it must output *only* two
314
315=== removed file 'resources/jujuresources-0.2.5.tar.gz'
316Binary files resources/jujuresources-0.2.5.tar.gz 2015-03-03 19:57:43 +0000 and resources/jujuresources-0.2.5.tar.gz 1970-01-01 00:00:00 +0000 differ
317=== added directory 'resources/python'
318=== added file 'resources/python/PyYAML-3.11.tar.gz'
319Binary files resources/python/PyYAML-3.11.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/PyYAML-3.11.tar.gz 2015-06-25 13:44:10 +0000 differ
320=== added file 'resources/python/charmhelpers-0.3.1.tar.gz'
321Binary files resources/python/charmhelpers-0.3.1.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/charmhelpers-0.3.1.tar.gz 2015-06-25 13:44:10 +0000 differ
322=== added file 'resources/python/jujuresources-0.2.8.tar.gz'
323Binary files resources/python/jujuresources-0.2.8.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/jujuresources-0.2.8.tar.gz 2015-06-25 13:44:10 +0000 differ
324=== added file 'resources/python/pyaml-15.5.7.tar.gz'
325Binary files resources/python/pyaml-15.5.7.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/pyaml-15.5.7.tar.gz 2015-06-25 13:44:10 +0000 differ
326=== added file 'resources/python/six-1.9.0-py2.py3-none-any.whl'
327Binary files resources/python/six-1.9.0-py2.py3-none-any.whl 1970-01-01 00:00:00 +0000 and resources/python/six-1.9.0-py2.py3-none-any.whl 2015-06-25 13:44:10 +0000 differ

Subscribers

People subscribed via source and target branches

to all changes: