Merge lp:~frankban/charms/precise/juju-gui/improve-error-handling into lp:~juju-gui/charms/precise/juju-gui/trunk

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 122
Proposed branch: lp:~frankban/charms/precise/juju-gui/improve-error-handling
Merge into: lp:~juju-gui/charms/precise/juju-gui/trunk
Diff against target: 137 lines (+43/-5)
6 files modified
hooks/utils.py (+3/-0)
revision (+1/-1)
server/guiserver/handlers.py (+4/-2)
server/guiserver/tests/bundles/test_base.py (+30/-0)
server/guiserver/tests/test_handlers.py (+3/-0)
tests/requirements.pip (+2/-2)
To merge this branch: bzr merge lp:~frankban/charms/precise/juju-gui/improve-error-handling
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+194398@code.launchpad.net

Description of the change

Improve bundle deployment error handling.

Workaround for http://bugs.python.org/issue1692335.

Include a customized jujuclient tarball in the
charm, The diff with the original is here:
http://pastebin.ubuntu.com/6377430/

Add a first fix to the testing environment creation
so that the local dependencies are installed
when available.

Also fixed the headers sent by the info handler.

Tests: make unittest

QA:
I used this bundle: http://pastebin.ubuntu.com/6377441/
to live test the branch.
Bootstrap a juju environment, run `make deploy` and then
switch the gui source to lp:juju-gui.
When everything is ready, try to deploy the bundle above:
it will fail because it includes local charms, but the
server will not explode, and it will be possible
to deploy other valid bundles after the first one.
The GUI user does not receive notifications, and that's
normal since deployments are not yet watched by the GUI.
Go to https://[GUI URL]/gui-server-info and you should
find the deployment status to be completed with the
expected error.

https://codereview.appspot.com/23000043/

To post a comment you must log in.
Revision history for this message
Francesco Banconi (frankban) wrote :
Download full text (6.7 KiB)

Reviewers: mp+194398_code.launchpad.net,

Message:
Please take a look.

Description:
Improve bundle deployment error handling.

Workaround for http://bugs.python.org/issue1692335.

Include a customized jujuclient tarball in the
charm, The diff with the original is here:
http://pastebin.ubuntu.com/6377430/

Add a first fix to the testing environment creation
so that the local dependencies are installed
when available.

Also fixed the headers sent by the info handler.

Tests: make unittest

QA:
I used this bundle: http://pastebin.ubuntu.com/6377441/
to live test the branch.
Bootstrap a juju environment, run `make deploy` and then
switch the gui source to lp:juju-gui.
When everything is ready, try to deploy the bundle above:
it will fail because it includes local charms, but the
server will not explode, and it will be possible
to deploy other valid bundles after the first one.
The GUI user does not receive notifications, and that's
normal since deployments are not yet watched by the GUI.
Go to https://[GUI URL]/gui-server-info and you should
find the deployment status to be completed with the
expected error.

https://code.launchpad.net/~frankban/charms/precise/juju-gui/improve-error-handling/+merge/194398

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/23000043/

Affected files (+44, -4 lines):
   A [revision details]
   M deps/jujuclient-0.13.tar.gz
   M hooks/utils.py
   M revision
   M server/guiserver/handlers.py
   M server/guiserver/tests/bundles/test_base.py
   M server/guiserver/tests/test_handlers.py
   M tests/requirements.pip

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision:
<email address hidden>
+New revision:
<email address hidden>

Index: revision
=== modified file 'revision'
--- revision 2013-11-07 11:18:20 +0000
+++ revision 2013-11-07 16:02:01 +0000
@@ -1,1 +1,1 @@
-93
+94

Index: deps/jujuclient-0.13.tar.gz
=== modified file 'deps/jujuclient-0.13.tar.gz'
Binary files deps/jujuclient-0.13.tar.gz 2013-11-06 18:48:54 +0000 and
deps/jujuclient-0.13.tar.gz 2013-11-07 17:27:20 +0000 differ

Index: hooks/utils.py
=== modified file 'hooks/utils.py'
--- hooks/utils.py 2013-11-07 14:41:27 +0000
+++ hooks/utils.py 2013-11-07 17:27:20 +0000
@@ -119,6 +119,9 @@
      'futures-2.1.4.tar.gz',
      'tornado-3.1.1.tar.gz',
      'websocket-client-0.12.0.tar.gz',
+ # XXX frankban 2013-11-07: we are currently using a customized
jujuclient
+ # version built from this branch:
+ # lp:~frankban/python-jujuclient/pickable-enverror.
      'jujuclient-0.13.tar.gz',
      # XXX frankban 2013-11-07: we are currently using a customized deployer
      # version built from this branch:
lp:~frankban/juju-deployer/guienv-fixes.

Index: server/guiserver/handlers.py
=== modified file 'server/guiserver/handlers.py'
--- server/guiserver/handlers.py 2013-10-17 12:47:15 +0000
+++ server/guiserver/handlers.py 2013-11-07 18:04:32 +0000
@@ -22,7 +22,6 @@
  import time

 ...

Read more...

Revision history for this message
Richard Harding (rharding) wrote :
Revision history for this message
Brad Crittenden (bac) wrote :
Revision history for this message
Francesco Banconi (frankban) wrote :

*** Submitted:

Improve bundle deployment error handling.

Workaround for http://bugs.python.org/issue1692335.

Include a customized jujuclient tarball in the
charm, The diff with the original is here:
http://pastebin.ubuntu.com/6377430/

Add a first fix to the testing environment creation
so that the local dependencies are installed
when available.

Also fixed the headers sent by the info handler.

Tests: make unittest

QA:
I used this bundle: http://pastebin.ubuntu.com/6377441/
to live test the branch.
Bootstrap a juju environment, run `make deploy` and then
switch the gui source to lp:juju-gui.
When everything is ready, try to deploy the bundle above:
it will fail because it includes local charms, but the
server will not explode, and it will be possible
to deploy other valid bundles after the first one.
The GUI user does not receive notifications, and that's
normal since deployments are not yet watched by the GUI.
Go to https://[GUI URL]/gui-server-info and you should
find the deployment status to be completed with the
expected error.

R=rharding, bac
CC=
https://codereview.appspot.com/23000043

https://codereview.appspot.com/23000043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'deps/jujuclient-0.13.tar.gz'
0Binary files deps/jujuclient-0.13.tar.gz 2013-11-06 18:48:54 +0000 and deps/jujuclient-0.13.tar.gz 2013-11-07 18:19:14 +0000 differ0Binary files deps/jujuclient-0.13.tar.gz 2013-11-06 18:48:54 +0000 and deps/jujuclient-0.13.tar.gz 2013-11-07 18:19:14 +0000 differ
=== modified file 'hooks/utils.py'
--- hooks/utils.py 2013-11-07 14:41:27 +0000
+++ hooks/utils.py 2013-11-07 18:19:14 +0000
@@ -119,6 +119,9 @@
119 'futures-2.1.4.tar.gz',119 'futures-2.1.4.tar.gz',
120 'tornado-3.1.1.tar.gz',120 'tornado-3.1.1.tar.gz',
121 'websocket-client-0.12.0.tar.gz',121 'websocket-client-0.12.0.tar.gz',
122 # XXX frankban 2013-11-07: we are currently using a customized jujuclient
123 # version built from this branch:
124 # lp:~frankban/python-jujuclient/pickable-enverror.
122 'jujuclient-0.13.tar.gz',125 'jujuclient-0.13.tar.gz',
123 # XXX frankban 2013-11-07: we are currently using a customized deployer126 # XXX frankban 2013-11-07: we are currently using a customized deployer
124 # version built from this branch: lp:~frankban/juju-deployer/guienv-fixes.127 # version built from this branch: lp:~frankban/juju-deployer/guienv-fixes.
125128
=== modified file 'revision'
--- revision 2013-11-07 11:18:20 +0000
+++ revision 2013-11-07 18:19:14 +0000
@@ -1,1 +1,1 @@
193194
22
=== modified file 'server/guiserver/handlers.py'
--- server/guiserver/handlers.py 2013-10-17 12:47:15 +0000
+++ server/guiserver/handlers.py 2013-11-07 18:19:14 +0000
@@ -22,7 +22,6 @@
22import time22import time
2323
24from tornado import (24from tornado import (
25 escape,
26 gen,25 gen,
27 web,26 web,
28 websocket,27 websocket,
@@ -227,7 +226,10 @@
227 def get(self):226 def get(self):
228 """Handle GET requests."""227 """Handle GET requests."""
229 info = self.get_info(self.application.settings)228 info = self.get_info(self.application.settings)
230 self.write(escape.json_encode(info))229 # In Tornado Web handlers, just writing a dict JSON encodes the
230 # response contents and sets the proper content type header
231 # (application/json; charset=UTF-8).
232 self.write(info)
231233
232234
233class HttpsRedirectHandler(web.RequestHandler):235class HttpsRedirectHandler(web.RequestHandler):
234236
=== modified file 'server/guiserver/tests/bundles/test_base.py'
--- server/guiserver/tests/bundles/test_base.py 2013-11-07 11:17:54 +0000
+++ server/guiserver/tests/bundles/test_base.py 2013-11-07 18:19:14 +0000
@@ -17,6 +17,7 @@
17"""Tests for the bundle deployment base objects."""17"""Tests for the bundle deployment base objects."""
1818
19from deployer import cli as deployer_cli19from deployer import cli as deployer_cli
20import jujuclient
20import mock21import mock
21from tornado import gen22from tornado import gen
22from tornado.testing import(23from tornado.testing import(
@@ -32,6 +33,15 @@
32from guiserver.tests import helpers33from guiserver.tests import helpers
3334
3435
36def import_bundle_mock(apiurl, password, name, bundle, options):
37 """Used to test bundle deployment failures.
38
39 This function is defined at module level so that it can be easily pickled
40 and reused in another process.
41 """
42 raise jujuclient.EnvError({'Error': 'bad wolf'})
43
44
35@mock.patch('time.time', mock.Mock(return_value=42))45@mock.patch('time.time', mock.Mock(return_value=42))
36class TestDeployer(helpers.BundlesTestMixin, AsyncTestCase):46class TestDeployer(helpers.BundlesTestMixin, AsyncTestCase):
3747
@@ -205,6 +215,26 @@
205 # Wait for the deployment to be completed.215 # Wait for the deployment to be completed.
206 self.wait()216 self.wait()
207217
218 def test_import_bundle_exception_propagation(self):
219 # An EnvError is correctly propagated from the separate process to the
220 # main thread.
221 deployer = self.make_deployer()
222 import_bundle_path = 'guiserver.bundles.base.blocking.import_bundle'
223 with mock.patch(import_bundle_path, import_bundle_mock):
224 deployer.import_bundle(
225 self.user, 'bundle', self.bundle, test_callback=self.stop)
226 # Wait for the deployment to be completed.
227 self.wait()
228 status = deployer.status()
229 self.assertEqual(1, len(status))
230 expected = {
231 'DeploymentId': 0,
232 'Status': utils.COMPLETED,
233 'Error': "<Env Error - Details:\n { 'Error': 'bad wolf'}\n >",
234 'Time': 42,
235 }
236 self.assertEqual(expected, status[0])
237
208 def test_invalid_watcher(self):238 def test_invalid_watcher(self):
209 # None is returned if the watcher id is not valid.239 # None is returned if the watcher id is not valid.
210 deployer = self.make_deployer()240 deployer = self.make_deployer()
211241
=== modified file 'server/guiserver/tests/test_handlers.py'
--- server/guiserver/tests/test_handlers.py 2013-10-17 12:47:15 +0000
+++ server/guiserver/tests/test_handlers.py 2013-11-07 18:19:14 +0000
@@ -431,6 +431,9 @@
431 }431 }
432 response = self.fetch('/info')432 response = self.fetch('/info')
433 self.assertEqual(200, response.code)433 self.assertEqual(200, response.code)
434 self.assertEqual(
435 'application/json; charset=UTF-8',
436 response.headers['Content-Type'])
434 info = escape.json_decode(response.body)437 info = escape.json_decode(response.body)
435 self.assertEqual(expected, info)438 self.assertEqual(expected, info)
436439
437440
=== modified file 'tests/requirements.pip'
--- tests/requirements.pip 2013-11-07 11:17:54 +0000
+++ tests/requirements.pip 2013-11-07 18:19:14 +0000
@@ -24,7 +24,7 @@
2424
25# GUI server -> juju deployer.25# GUI server -> juju deployer.
26bzr==2.6.026bzr==2.6.0
27jujuclient==0.13.027jujuclient==0.13
2828
29# Charm tests + juju deployer.29# Charm tests + juju deployer.
30websocket-client==0.12.030websocket-client==0.12.0
@@ -34,7 +34,7 @@
3434
35# GUI server.35# GUI server.
36futures==2.1.436futures==2.1.4
37-e bzr+http://launchpad.net/juju-deployer/darwin#egg=juju-deployer37juju-deployer==0.2.8
38tornado==3.1.138tornado==3.1.1
3939
40# Charm hooks.40# Charm hooks.

Subscribers

People subscribed via source and target branches