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

Proposed by Cory Johns
Status: Merged
Merged at revision: 67
Proposed branch: lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-secondary/status
Merge into: lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-secondary/trunk
Diff against target: 284 lines (+108/-26)
9 files modified
hooks/callbacks.py (+25/-0)
hooks/common.py (+19/-6)
hooks/config-changed (+11/-0)
hooks/install (+11/-0)
hooks/secondary-relation-changed (+11/-1)
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-secondary/status
Reviewer Review Type Date Requested Status
amir sanjar (community) Approve
Review via email: mp+262925@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.

67. By Cory Johns

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

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

Subscribers

People subscribed via source and target branches

to all changes: