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
1=== modified file 'deps/jujuclient-0.13.tar.gz'
2Binary 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
3=== modified file 'hooks/utils.py'
4--- hooks/utils.py 2013-11-07 14:41:27 +0000
5+++ hooks/utils.py 2013-11-07 18:19:14 +0000
6@@ -119,6 +119,9 @@
7 'futures-2.1.4.tar.gz',
8 'tornado-3.1.1.tar.gz',
9 'websocket-client-0.12.0.tar.gz',
10+ # XXX frankban 2013-11-07: we are currently using a customized jujuclient
11+ # version built from this branch:
12+ # lp:~frankban/python-jujuclient/pickable-enverror.
13 'jujuclient-0.13.tar.gz',
14 # XXX frankban 2013-11-07: we are currently using a customized deployer
15 # version built from this branch: lp:~frankban/juju-deployer/guienv-fixes.
16
17=== modified file 'revision'
18--- revision 2013-11-07 11:18:20 +0000
19+++ revision 2013-11-07 18:19:14 +0000
20@@ -1,1 +1,1 @@
21-93
22+94
23
24=== modified file 'server/guiserver/handlers.py'
25--- server/guiserver/handlers.py 2013-10-17 12:47:15 +0000
26+++ server/guiserver/handlers.py 2013-11-07 18:19:14 +0000
27@@ -22,7 +22,6 @@
28 import time
29
30 from tornado import (
31- escape,
32 gen,
33 web,
34 websocket,
35@@ -227,7 +226,10 @@
36 def get(self):
37 """Handle GET requests."""
38 info = self.get_info(self.application.settings)
39- self.write(escape.json_encode(info))
40+ # In Tornado Web handlers, just writing a dict JSON encodes the
41+ # response contents and sets the proper content type header
42+ # (application/json; charset=UTF-8).
43+ self.write(info)
44
45
46 class HttpsRedirectHandler(web.RequestHandler):
47
48=== modified file 'server/guiserver/tests/bundles/test_base.py'
49--- server/guiserver/tests/bundles/test_base.py 2013-11-07 11:17:54 +0000
50+++ server/guiserver/tests/bundles/test_base.py 2013-11-07 18:19:14 +0000
51@@ -17,6 +17,7 @@
52 """Tests for the bundle deployment base objects."""
53
54 from deployer import cli as deployer_cli
55+import jujuclient
56 import mock
57 from tornado import gen
58 from tornado.testing import(
59@@ -32,6 +33,15 @@
60 from guiserver.tests import helpers
61
62
63+def import_bundle_mock(apiurl, password, name, bundle, options):
64+ """Used to test bundle deployment failures.
65+
66+ This function is defined at module level so that it can be easily pickled
67+ and reused in another process.
68+ """
69+ raise jujuclient.EnvError({'Error': 'bad wolf'})
70+
71+
72 @mock.patch('time.time', mock.Mock(return_value=42))
73 class TestDeployer(helpers.BundlesTestMixin, AsyncTestCase):
74
75@@ -205,6 +215,26 @@
76 # Wait for the deployment to be completed.
77 self.wait()
78
79+ def test_import_bundle_exception_propagation(self):
80+ # An EnvError is correctly propagated from the separate process to the
81+ # main thread.
82+ deployer = self.make_deployer()
83+ import_bundle_path = 'guiserver.bundles.base.blocking.import_bundle'
84+ with mock.patch(import_bundle_path, import_bundle_mock):
85+ deployer.import_bundle(
86+ self.user, 'bundle', self.bundle, test_callback=self.stop)
87+ # Wait for the deployment to be completed.
88+ self.wait()
89+ status = deployer.status()
90+ self.assertEqual(1, len(status))
91+ expected = {
92+ 'DeploymentId': 0,
93+ 'Status': utils.COMPLETED,
94+ 'Error': "<Env Error - Details:\n { 'Error': 'bad wolf'}\n >",
95+ 'Time': 42,
96+ }
97+ self.assertEqual(expected, status[0])
98+
99 def test_invalid_watcher(self):
100 # None is returned if the watcher id is not valid.
101 deployer = self.make_deployer()
102
103=== modified file 'server/guiserver/tests/test_handlers.py'
104--- server/guiserver/tests/test_handlers.py 2013-10-17 12:47:15 +0000
105+++ server/guiserver/tests/test_handlers.py 2013-11-07 18:19:14 +0000
106@@ -431,6 +431,9 @@
107 }
108 response = self.fetch('/info')
109 self.assertEqual(200, response.code)
110+ self.assertEqual(
111+ 'application/json; charset=UTF-8',
112+ response.headers['Content-Type'])
113 info = escape.json_decode(response.body)
114 self.assertEqual(expected, info)
115
116
117=== modified file 'tests/requirements.pip'
118--- tests/requirements.pip 2013-11-07 11:17:54 +0000
119+++ tests/requirements.pip 2013-11-07 18:19:14 +0000
120@@ -24,7 +24,7 @@
121
122 # GUI server -> juju deployer.
123 bzr==2.6.0
124-jujuclient==0.13.0
125+jujuclient==0.13
126
127 # Charm tests + juju deployer.
128 websocket-client==0.12.0
129@@ -34,7 +34,7 @@
130
131 # GUI server.
132 futures==2.1.4
133--e bzr+http://launchpad.net/juju-deployer/darwin#egg=juju-deployer
134+juju-deployer==0.2.8
135 tornado==3.1.1
136
137 # Charm hooks.

Subscribers

People subscribed via source and target branches