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

Proposed by Cory Johns on 2015-06-24
Status: Merged
Merge reported by: Cory Johns
Merged at revision: not available
Proposed branch: lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/status
Merge into: lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk
Diff against target: 220 lines (+75/-41)
4 files modified
hooks/callbacks.py (+43/-0)
hooks/common.py (+23/-22)
hooks/setup.py (+8/-10)
resources.yaml (+1/-9)
To merge this branch: bzr merge lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/status
Reviewer Review Type Date Requested Status
Kevin W Monroe 2015-06-24 Approve on 2015-06-29
Review via email: mp+262924@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.
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.

100. By Cory Johns on 2015-06-25

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

Kevin W Monroe (kwmonroe) wrote :

status + bundled resources LGTM, +1.

Merged into to -dev/trunk in r100.

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:52:43 +0000
3+++ hooks/callbacks.py 2015-06-25 13:44:23 +0000
4@@ -15,3 +15,46 @@
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 NameNode, ResourceManager
12+
13+
14+def update_blocked_status():
15+ if unitdata.kv().get('charm.active', False):
16+ return
17+ rels = (
18+ ('Yarn', 'ResourceManager', ResourceManager()),
19+ ('HDFS', 'NameNode', NameNode()),
20+ )
21+ missing_rel = [rel for rel, res, impl in rels if not impl.connected_units()]
22+ missing_hosts = [rel for rel, res, impl in rels if not impl.am_i_registered()]
23+ not_ready = [(rel, res) for rel, res, impl in rels if not impl.is_ready()]
24+ if missing_rel:
25+ hookenv.status_set('blocked', 'Waiting for relation to %s master%s' % (
26+ ' and '.join(missing_rel),
27+ 's' if len(missing_rel) > 1 else '',
28+ )),
29+ elif missing_hosts:
30+ hookenv.status_set('waiting', 'Waiting for /etc/hosts registration on %s' % (
31+ ' and '.join(missing_hosts),
32+ ))
33+ elif not_ready:
34+ unready_rels, unready_ress = zip(*not_ready)
35+ hookenv.status_set('waiting', 'Waiting for %s to provide %s' % (
36+ ' and '.join(unready_rels),
37+ ' and '.join(unready_ress),
38+ ))
39+
40+
41+def update_working_status():
42+ if unitdata.kv().get('charm.active', False):
43+ hookenv.status_set('maintenance', 'Updating configuration')
44+ return
45+ hookenv.status_set('maintenance', 'Setting up Hadoop libraries')
46+
47+
48+def update_active_status():
49+ unitdata.kv().set('charm.active', True)
50+ hookenv.status_set('active', 'Ready')
51
52=== modified file 'hooks/common.py'
53--- hooks/common.py 2015-06-19 17:25:57 +0000
54+++ hooks/common.py 2015-06-25 13:44:23 +0000
55@@ -15,29 +15,39 @@
56 """
57
58 import jujuresources
59+from charmhelpers.core import hookenv
60+from charmhelpers.core import unitdata
61+from charmhelpers.core import charmframework
62
63
64 def bootstrap_resources():
65 """
66 Install required resources defined in resources.yaml
67 """
68+ if unitdata.kv().get('charm.bootstrapped', False):
69+ return True
70+ hookenv.status_set('maintenance', 'Installing base resources')
71 mirror_url = jujuresources.config_get('resources_mirror')
72 if not jujuresources.fetch(mirror_url=mirror_url):
73- jujuresources.juju_log('Resources unavailable; manual intervention required', 'ERROR')
74+ missing = jujuresources.invalid()
75+ hookenv.status_set('blocked', 'Unable to fetch required resource%s: %s' % (
76+ 's' if len(missing) > 1 else '',
77+ ', '.join(missing),
78+ ))
79 return False
80- jujuresources.install(['pathlib', 'pyaml', 'six', 'charmhelpers', 'jujubigdata', 'charm-benchmark'])
81+ jujuresources.install(['pathlib', 'jujubigdata', 'charm-benchmark'])
82+ unitdata.kv().set('charm.bootstrapped', True)
83 return True
84
85
86 def manage():
87 if not bootstrap_resources():
88- # defer until resources are available, since charmhelpers, and thus
89- # the framework, are required (will require manual intervention)
90+ # defer until resources are available, since jujubigdata, and thus the
91+ # classes needed for the requires blocks, (will be) managed by jujuresources
92 return
93
94- from charmhelpers.core import charmframework
95 import jujubigdata
96- import callbacks # noqa (ignore when linting)
97+ import callbacks
98
99 # list of keys required to be in the dist.yaml
100 client_reqs = ['vendor', 'hadoop_version', 'packages', 'groups', 'users',
101@@ -57,37 +67,28 @@
102 ],
103 'callbacks': [
104 hadoop.install,
105+ callbacks.update_blocked_status,
106 ],
107 },
108 {
109- 'name': 'plugin-hdfs',
110+ 'name': 'plugin',
111 'provides': [
112 jujubigdata.relations.HadoopPlugin(),
113 ],
114 'requires': [
115 hadoop.is_installed,
116+ yarn_relation,
117 hdfs_relation,
118 ],
119 'callbacks': [
120+ callbacks.update_working_status,
121+ yarn_relation.register_provided_hosts,
122 hdfs_relation.register_provided_hosts,
123 jujubigdata.utils.manage_etc_hosts,
124- hdfs.configure_client,
125- ],
126- 'cleanup': [],
127- },
128- {
129- 'name': 'plugin-yarn',
130- 'provides': [
131- ],
132- 'requires': [
133- hadoop.is_installed,
134- yarn_relation,
135- ],
136- 'callbacks': [
137- yarn_relation.register_provided_hosts,
138- jujubigdata.utils.manage_etc_hosts,
139 yarn.install_demo,
140 yarn.configure_client,
141+ hdfs.configure_client,
142+ callbacks.update_active_status,
143 ],
144 'cleanup': [],
145 },
146
147=== modified file 'hooks/setup.py'
148--- hooks/setup.py 2015-03-03 21:29:00 +0000
149+++ hooks/setup.py 2015-06-25 13:44:23 +0000
150@@ -12,24 +12,22 @@
151 import subprocess
152 from glob import glob
153
154+
155 def pre_install():
156 """
157 Do any setup required before the install hook.
158 """
159 install_pip()
160- install_jujuresources()
161+ install_bundled_resources()
162
163
164 def install_pip():
165 subprocess.check_call(['apt-get', 'install', '-yq', 'python-pip', 'bzr'])
166
167
168-def install_jujuresources():
169- """
170- Install the bundled jujuresources library, if not present.
171- """
172- try:
173- import jujuresources # noqa
174- except ImportError:
175- jr_archive = glob('resources/jujuresources-*.tar.gz')[0]
176- subprocess.check_call(['pip', 'install', jr_archive])
177+def install_bundled_resources():
178+ """
179+ Install the bundled resources libraries.
180+ """
181+ archives = glob('resources/python/*')
182+ subprocess.check_call(['pip', 'install'] + archives)
183
184=== modified file 'resources.yaml'
185--- resources.yaml 2015-06-19 17:25:57 +0000
186+++ resources.yaml 2015-06-25 13:44:23 +0000
187@@ -3,18 +3,10 @@
188 resources:
189 pathlib:
190 pypi: path.py>=7.0
191- pyaml:
192- pypi: pyaml
193- six:
194- pypi: six
195 jujubigdata:
196- pypi: jujubigdata>=2.0.0,<3.0.0
197+ pypi: jujubigdata>=2.0.2,<3.0.0
198 charm-benchmark:
199 pypi: charm-benchmark>=1.0.1,<2.0.0
200- charmhelpers:
201- 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
202- hash: 061fe7204289b96fab5d3ca02883040ea3026526ebf0ad38e21457527a18d139
203- hash_type: sha256
204 java-installer:
205 # This points to a script which manages installing Java.
206 # If replaced with an alternate implementation, it must output *only* two
207
208=== removed file 'resources/jujuresources-0.2.5.tar.gz'
209Binary files resources/jujuresources-0.2.5.tar.gz 2015-03-03 19:56:49 +0000 and resources/jujuresources-0.2.5.tar.gz 1970-01-01 00:00:00 +0000 differ
210=== added directory 'resources/python'
211=== added file 'resources/python/PyYAML-3.11.tar.gz'
212Binary 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:23 +0000 differ
213=== added file 'resources/python/charmhelpers-0.3.1.tar.gz'
214Binary 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:23 +0000 differ
215=== added file 'resources/python/jujuresources-0.2.8.tar.gz'
216Binary 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:23 +0000 differ
217=== added file 'resources/python/pyaml-15.5.7.tar.gz'
218Binary 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:23 +0000 differ
219=== added file 'resources/python/six-1.9.0-py2.py3-none-any.whl'
220Binary 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:23 +0000 differ

Subscribers

People subscribed via source and target branches

to all changes: