Merge lp:~hatch/juju-gui/better-bundle-error into lp:juju-gui/experimental

Proposed by Jeff Pihach
Status: Merged
Merged at revision: 1171
Proposed branch: lp:~hatch/juju-gui/better-bundle-error
Merge into: lp:juju-gui/experimental
Diff against target: 101 lines (+18/-9)
5 files modified
app/store/env/fakebackend.js (+7/-2)
app/store/env/sandbox.js (+4/-3)
test/test_fakebackend.js (+4/-2)
test/test_sandbox_go.js (+1/-1)
test/test_sandbox_python.js (+2/-1)
To merge this branch: bzr merge lp:~hatch/juju-gui/better-bundle-error
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+193455@code.launchpad.net

Description of the change

Improve the error reporting of bundle imports

https://codereview.appspot.com/17540044/

To post a comment you must log in.
Revision history for this message
Jeff Pihach (hatch) wrote :
Download full text (5.0 KiB)

Reviewers: mp+193455_code.launchpad.net,

Message:
Please take a look.

Description:
Improve the error reporting of bundle imports

https://code.launchpad.net/~hatch/juju-gui/better-bundle-error/+merge/193455

(do not edit description out of merge proposal)

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

Affected files (+20, -9 lines):
   A [revision details]
   M app/store/env/fakebackend.js
   M app/store/env/sandbox.js
   M test/test_fakebackend.js
   M test/test_sandbox_go.js
   M test/test_sandbox_python.js

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: test/test_fakebackend.js
=== modified file 'test/test_fakebackend.js'
--- test/test_fakebackend.js 2013-10-30 21:58:08 +0000
+++ test/test_fakebackend.js 2013-10-31 16:35:27 +0000
@@ -204,11 +204,13 @@
        // The service name is provided explicitly.
        fakebackend.deploy(
            'cs:precise/haproxy-18', callback, {name: 'wordpress'});
- assert.equal(result.error, 'A service with this name already
exists.');
+ assert.equal(result.error,
+ 'A service with this name already exists. (wordpress)');
        // The service name is derived from charm.
        result = undefined;
        fakebackend.deploy('cs:precise/wordpress-15', callback);
- assert.equal(result.error, 'A service with this name already
exists.');
+ assert.equal(result.error,
+ 'A service with this name already exists. (wordpress)');
      });

      it('reuses already-loaded charms with the same explicit id.',
function() {

Index: test/test_sandbox_go.js
=== modified file 'test/test_sandbox_go.js'
--- test/test_sandbox_go.js 2013-10-11 13:47:43 +0000
+++ test/test_sandbox_go.js 2013-10-31 16:35:27 +0000
@@ -333,7 +333,7 @@
        state.deploy('cs:precise/wordpress-15', function() {});
        var callback = function(result) {
          assert.equal(
- result.err, 'A service with this name already exists.');
+ result.err, 'A service with this name already exists.
(wordpress)');
          done();
        };
        env.deploy('cs:precise/wordpress-15', undefined, undefined,
undefined,

Index: test/test_sandbox_python.js
=== modified file 'test/test_sandbox_python.js'
--- test/test_sandbox_python.js 2013-09-26 22:03:11 +0000
+++ test/test_sandbox_python.js 2013-10-31 16:35:27 +0000
@@ -409,7 +409,8 @@
        env.after('defaultSeriesChange', function() {
          var callback = function(result) {
            assert.equal(
- result.err, 'A service with this name already exists.');
+ result.err,
+ 'A service with this name already exists. (wordpress)');
            done();
          };
          env.deploy(

Index: app/store/env/fakebackend.js
=== modified file 'app/store/env/fakebackend.js'
--- app/store/env/fakebackend.js 2013-10-30 21:58:08 +0000
+++ app/store/env/fakebackend.js 2013-10-31 16:35:27 +0000
...

Read more...

Revision history for this message
Gary Poster (gary) wrote :

After adding the additional string changes I requested, this LGTM except
for the sandbox change. The fakebackend should be internally consistent
between error and Error. ISTM that error is consistently used as the
attr name. Where is Error coming from?

QAOK.

Thank you!

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js
File app/store/env/fakebackend.js (right):

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode304
app/store/env/fakebackend.js:304: callbacks.failure({error: 'Invalid
charm id.'}));
Please include the charm id here.

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode386
app/store/env/fakebackend.js:386: options.name + ')'});
Let's put it within the sentence:

A service with this name already exists (FOO).

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode400
app/store/env/fakebackend.js:400: console.log(options);
Maybe log the e too?

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode475
app/store/env/fakebackend.js:475: return {error: 'Invalid service id.'};
Please include serviceName in string

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode489
app/store/env/fakebackend.js:489: return {error: 'Error removing units:
' + result.error};
Maybe "Error removing units [array] of ${serviceName}: "

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode491
app/store/env/fakebackend.js:491: return {error: 'Warning removing
units: ' + result.warning};
...units [array] of ${serviceName}

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode513
app/store/env/fakebackend.js:513: return {error: 'Invalid service id.'};
include serviceName

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode581
app/store/env/fakebackend.js:581: return {error: 'Invalid number of
units.'};
Include serviceName and maybe numUnits

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode866
app/store/env/fakebackend.js:866: result = {error: 'Specified relation
is unavailable.'};
...eh, specifying the endpoints would be nice, but seems annoying. :-)

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode868
app/store/env/fakebackend.js:868: result = {error: 'Ambiguous
relationship is not allowed.'};
Same.

https://codereview.appspot.com/17540044/diff/1/app/store/env/sandbox.js
File app/store/env/sandbox.js (right):

https://codereview.appspot.com/17540044/diff/1/app/store/env/sandbox.js#newcode1315
app/store/env/sandbox.js:1315: response.Error = reply.Error ||
reply.error;
Yeah, this is broken. We should not have to do that. The fakebackend
should be internally consistent. It looked like it was to me. What is
not consistent within fakebackend?

https://codereview.appspot.com/17540044/

Revision history for this message
Jeff Pihach (hatch) wrote :
Download full text (3.2 KiB)

Thanks for the review - comments and changes are included below.

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js
File app/store/env/fakebackend.js (right):

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode304
app/store/env/fakebackend.js:304: callbacks.failure({error: 'Invalid
charm id.'}));
On 2013/10/31 17:30:21, gary.poster wrote:
> Please include the charm id here.

Done.

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode386
app/store/env/fakebackend.js:386: options.name + ')'});
On 2013/10/31 17:30:21, gary.poster wrote:
> Let's put it within the sentence:

> A service with this name already exists (FOO).

Done.

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode400
app/store/env/fakebackend.js:400: console.log(options);
On 2013/10/31 17:30:21, gary.poster wrote:
> Maybe log the e too?

Done.

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode475
app/store/env/fakebackend.js:475: return {error: 'Invalid service id.'};
On 2013/10/31 17:30:21, gary.poster wrote:
> Please include serviceName in string

Done.

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode489
app/store/env/fakebackend.js:489: return {error: 'Error removing units:
' + result.error};
On 2013/10/31 17:30:21, gary.poster wrote:
> Maybe "Error removing units [array] of ${serviceName}: "

Done.

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode491
app/store/env/fakebackend.js:491: return {error: 'Warning removing
units: ' + result.warning};
On 2013/10/31 17:30:21, gary.poster wrote:
> ...units [array] of ${serviceName}

Done.

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode513
app/store/env/fakebackend.js:513: return {error: 'Invalid service id.'};
On 2013/10/31 17:30:21, gary.poster wrote:
> include serviceName

Done.

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode581
app/store/env/fakebackend.js:581: return {error: 'Invalid number of
units.'};
On 2013/10/31 17:30:21, gary.poster wrote:
> Include serviceName and maybe numUnits

Done.

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode866
app/store/env/fakebackend.js:866: result = {error: 'Specified relation
is unavailable.'};
:-) I added a console log of the endpoints so at least the data is
available to the user if necessary

https://codereview.appspot.com/17540044/diff/1/app/store/env/fakebackend.js#newcode868
app/store/env/fakebackend.js:868: result = {error: 'Ambiguous
relationship is not allowed.'};
Same

https://codereview.appspot.com/17540044/diff/1/app/store/env/sandbox.js
File app/store/env/sandbox.js (right):

https://codereview.appspot.com/17540044/diff/1/app/store/env/sandbox.js#newcode1315
app/store/env/sandbox.js:1315: response.Error = reply.Error ||
reply.error;
the fakebackend uses .error as I would expect. You can see this with the
'statics' UNAUTHENTICATED_ERROR and VALUE_ERROR both use 'error' as
their key.

The Go env uses 'Error' as it's key probably to match the api respon...

Read more...

Revision history for this message
Jeff Pihach (hatch) wrote :

*** Submitted:

Improve the error reporting of bundle imports

R=gary.poster
CC=
https://codereview.appspot.com/17540044

https://codereview.appspot.com/17540044/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/store/env/fakebackend.js'
2--- app/store/env/fakebackend.js 2013-10-30 21:58:08 +0000
3+++ app/store/env/fakebackend.js 2013-10-31 16:38:55 +0000
4@@ -381,10 +381,13 @@
5 options.name = charm.get('package_name');
6 }
7 if (this.db.services.getById(options.name)) {
8- return callback({error: 'A service with this name already exists.'});
9+ console.log(options);
10+ return callback({error: 'A service with this name already exists. (' +
11+ options.name + ')'});
12 }
13 if (options.configYAML) {
14 if (!Y.Lang.isString(options.configYAML)) {
15+ console.log(options);
16 return callback(
17 {error: 'Developer error: configYAML is not a string.'});
18 }
19@@ -394,6 +397,7 @@
20 options.config = jsyaml.safeLoad(options.configYAML);
21 } catch (e) {
22 if (e instanceof jsyaml.YAMLException) {
23+ console.log(options);
24 return callback({error: 'Error parsing YAML.\n' + e});
25 }
26 throw e;
27@@ -1560,7 +1564,8 @@
28 callback({DeploymentId: self._deploymentId});
29 }, function(err) {
30 deployStatus.Status = 'failed';
31- callback({Error: err.toString()});
32+ console.log(err);
33+ callback({Error: err.error});
34 });
35 },
36
37
38=== modified file 'app/store/env/sandbox.js'
39--- app/store/env/sandbox.js 2013-10-11 13:47:43 +0000
40+++ app/store/env/sandbox.js 2013-10-31 16:38:55 +0000
41@@ -1310,9 +1310,10 @@
42 DeployerId: reply.DeploymentId
43 }
44 };
45- if (reply.Error) {
46- response.Error = reply.Error;
47- }
48+ // Because the error can come in two different formats
49+ // depending on the backend we need to check both.
50+ response.Error = reply.Error || reply.error;
51+
52 client.receive(response);
53 };
54 state.importDeployer(data.Params.YAML, data.Params.Name,
55
56=== modified file 'test/test_fakebackend.js'
57--- test/test_fakebackend.js 2013-10-30 21:58:08 +0000
58+++ test/test_fakebackend.js 2013-10-31 16:38:55 +0000
59@@ -204,11 +204,13 @@
60 // The service name is provided explicitly.
61 fakebackend.deploy(
62 'cs:precise/haproxy-18', callback, {name: 'wordpress'});
63- assert.equal(result.error, 'A service with this name already exists.');
64+ assert.equal(result.error,
65+ 'A service with this name already exists. (wordpress)');
66 // The service name is derived from charm.
67 result = undefined;
68 fakebackend.deploy('cs:precise/wordpress-15', callback);
69- assert.equal(result.error, 'A service with this name already exists.');
70+ assert.equal(result.error,
71+ 'A service with this name already exists. (wordpress)');
72 });
73
74 it('reuses already-loaded charms with the same explicit id.', function() {
75
76=== modified file 'test/test_sandbox_go.js'
77--- test/test_sandbox_go.js 2013-10-11 13:47:43 +0000
78+++ test/test_sandbox_go.js 2013-10-31 16:38:55 +0000
79@@ -333,7 +333,7 @@
80 state.deploy('cs:precise/wordpress-15', function() {});
81 var callback = function(result) {
82 assert.equal(
83- result.err, 'A service with this name already exists.');
84+ result.err, 'A service with this name already exists. (wordpress)');
85 done();
86 };
87 env.deploy('cs:precise/wordpress-15', undefined, undefined, undefined,
88
89=== modified file 'test/test_sandbox_python.js'
90--- test/test_sandbox_python.js 2013-09-26 22:03:11 +0000
91+++ test/test_sandbox_python.js 2013-10-31 16:38:55 +0000
92@@ -409,7 +409,8 @@
93 env.after('defaultSeriesChange', function() {
94 var callback = function(result) {
95 assert.equal(
96- result.err, 'A service with this name already exists.');
97+ result.err,
98+ 'A service with this name already exists. (wordpress)');
99 done();
100 };
101 env.deploy(

Subscribers

People subscribed via source and target branches