Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(446)

Issue 9896046: state/api: Machiner API facade (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 11 months ago by dimitern
Modified:
10 years, 11 months ago
Reviewers:
mp+167211, mue, fwereade
Visibility:
Public.

Description

state/api: Machiner API facade Implemented Machiner facade providing API methods with bulk operations support, but only the subset of state calls needed by the machiner worker. Removed domain objects like Machine and Unit both server-side and client-side. Instead, the machiner facade at server-side provides all the API calls needed by the machiner. In a follow-up at the client-side there will be another Machiner facade and lightweight MachinerMachine wrapper preserving the state.Machine interface, while using the facade to do the actual calls. Thus the machiner facade effectively implements the state.State object, but for the machiner. Also removed the Pinger at both sides and some obsolete state/api/params types. Added internal server-side tests for the machiner. https://code.launchpad.net/~dimitern/juju-core/052-api-machiner-facade/+merge/167211 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 29

Patch Set 2 : state/api: Machiner API facade #

Patch Set 3 : state/api: Machiner API facade #

Total comments: 22

Patch Set 4 : state/api: Machiner API facade #

Unified diffs Side-by-side diffs Delta from patch set Stats (+392 lines, -1619 lines) Patch
A [revision details] View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M state/api/apierror.go View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M state/api/client.go View 1 chunk +5 lines, -0 lines 0 comments Download
D state/api/machine.go View 1 chunk +0 lines, -145 lines 0 comments Download
M state/api/params/params.go View 1 2 3 4 chunks +51 lines, -46 lines 0 comments Download
M state/api/state.go View 1 2 3 1 chunk +10 lines, -50 lines 0 comments Download
D state/api/unit.go View 1 chunk +0 lines, -48 lines 0 comments Download
M state/api/watcher.go View 1 2 1 chunk +0 lines, -13 lines 0 comments Download
M state/apiserver/api_test.go View 2 chunks +0 lines, -2 lines 0 comments Download
M state/apiserver/apierror.go View 1 2 3 3 chunks +14 lines, -0 lines 0 comments Download
M state/apiserver/errors_test.go View 1 chunk +0 lines, -14 lines 0 comments Download
M state/apiserver/export_test.go View 1 1 chunk +11 lines, -0 lines 0 comments Download
M state/apiserver/login_test.go View 1 2 3 3 chunks +27 lines, -7 lines 0 comments Download
D state/apiserver/machine.go View 1 chunk +0 lines, -132 lines 0 comments Download
D state/apiserver/machine_test.go View 1 chunk +0 lines, -499 lines 0 comments Download
A state/apiserver/machiner.go View 1 2 3 1 chunk +90 lines, -0 lines 0 comments Download
A state/apiserver/machiner_test.go View 1 2 3 1 chunk +151 lines, -0 lines 0 comments Download
M state/apiserver/perm_test.go View 5 chunks +1 line, -234 lines 0 comments Download
M state/apiserver/root.go View 1 2 6 chunks +27 lines, -53 lines 0 comments Download
M state/apiserver/server_test.go View 1 2 3 2 chunks +2 lines, -71 lines 0 comments Download
M state/apiserver/state.go View 2 chunks +0 lines, -67 lines 0 comments Download
M state/apiserver/state_test.go View 1 chunk +0 lines, -134 lines 0 comments Download
D state/apiserver/unit.go View 1 chunk +0 lines, -41 lines 0 comments Download
D state/apiserver/unit_test.go View 1 chunk +0 lines, -49 lines 0 comments Download
M state/apiserver/utils.go View 2 chunks +0 lines, -14 lines 0 comments Download

Messages

Total messages: 7
dimitern
Please take a look.
10 years, 11 months ago (2013-06-04 07:42:54 UTC) #1
fwereade
A few thoughts. https://codereview.appspot.com/9896046/diff/1/state/api/machiner.go File state/api/machiner.go (right): https://codereview.appspot.com/9896046/diff/1/state/api/machiner.go#newcode15 state/api/machiner.go:15: type MachinerMachine struct { This is ...
10 years, 11 months ago (2013-06-04 08:37:29 UTC) #2
dimitern
Please take a look. https://codereview.appspot.com/9896046/diff/1/state/api/machiner.go File state/api/machiner.go (right): https://codereview.appspot.com/9896046/diff/1/state/api/machiner.go#newcode15 state/api/machiner.go:15: type MachinerMachine struct { On ...
10 years, 11 months ago (2013-06-04 11:06:17 UTC) #3
dimitern
Please take a look.
10 years, 11 months ago (2013-06-04 11:16:41 UTC) #4
fwereade
LGTM modulo a quick live chat re comments -- some might appreciate a fix this ...
10 years, 11 months ago (2013-06-04 11:59:09 UTC) #5
mue
LGTM, only the already know comments and some smaller additional ones. https://codereview.appspot.com/9896046/diff/11001/state/api/apierror.go File state/api/apierror.go (right): ...
10 years, 11 months ago (2013-06-04 12:25:53 UTC) #6
dimitern
10 years, 11 months ago (2013-06-04 13:10:14 UTC) #7
*** Submitted:

state/api: Machiner API facade

Implemented Machiner facade providing API
methods with bulk operations support, but
only the subset of state calls needed by
the machiner worker.

Removed domain objects like Machine and Unit
both server-side and client-side. Instead,
the machiner facade at server-side provides
all the API calls needed by the machiner.
In a follow-up at the client-side there will
be another Machiner facade and lightweight
MachinerMachine wrapper preserving the state.Machine
interface, while using the facade to do the
actual calls.
Thus the machiner facade effectively implements
the state.State object, but for the machiner.

Also removed the Pinger at both sides and some
obsolete state/api/params types.

Added internal server-side tests for the machiner.

R=fwereade, mue
CC=
https://codereview.appspot.com/9896046

https://codereview.appspot.com/9896046/diff/11001/state/api/apierror.go
File state/api/apierror.go (right):

https://codereview.appspot.com/9896046/diff/11001/state/api/apierror.go#newco...
state/api/apierror.go:28: CodeBadVersion          = "API version not available"
On 2013/06/04 12:25:54, mue wrote:
> Would prefer "not supported".

Good point, done.

https://codereview.appspot.com/9896046/diff/11001/state/api/machiner.go
File state/api/machiner.go (right):

https://codereview.appspot.com/9896046/diff/11001/state/api/machiner.go#newco...
state/api/machiner.go:35: return "", fmt.Errorf("expected server response, got
nothing")
On 2013/06/04 11:59:09, fwereade wrote:
> expected one result, got <N>?

As agreed, will remove the client-side machiner from this CL and propose it +
tests in a follow-up, including this suggestion.

https://codereview.appspot.com/9896046/diff/11001/state/api/params/params.go
File state/api/params/params.go (right):

https://codereview.appspot.com/9896046/diff/11001/state/api/params/params.go#...
state/api/params/params.go:80: Error *Error
On 2013/06/04 12:25:54, mue wrote:
> Nothing important, but I prefer the errors here as the last member of the
> struct. Like the last value returned when calling a function. But again, not
> really important.

Done.

https://codereview.appspot.com/9896046/diff/11001/state/api/state.go
File state/api/state.go (right):

https://codereview.appspot.com/9896046/diff/11001/state/api/state.go#newcode27
state/api/state.go:27: // Just verify we're allowed to access it.
On 2013/06/04 11:59:09, fwereade wrote:
> OK, and this is all because of the Login behaviour that lets us have an open
> conn without actually being authorized, right? Rog, would you remind us what
the
> benefit of this behaviour is?
> 
> (Hmm, is it even necessary, even then? Wouldn't the Authorizer used in the
> Machiner methods be able to barf the same error regardless?)

You'll get "not logged in" from the first method you call, but I thought it's
nicer to get this right away here.

https://codereview.appspot.com/9896046/diff/11001/state/apiserver/apierror.go
File state/apiserver/apierror.go (right):

https://codereview.appspot.com/9896046/diff/11001/state/apiserver/apierror.go...
state/apiserver/apierror.go:16: errBadVersion     = stderrors.New("API version
not available")
On 2013/06/04 12:25:54, mue wrote:
> Here again "not supported".

Done.

https://codereview.appspot.com/9896046/diff/11001/state/apiserver/machiner.go
File state/apiserver/machiner.go (right):

https://codereview.appspot.com/9896046/diff/11001/state/apiserver/machiner.go...
state/apiserver/machiner.go:26: machine, err := m.st.Machine(arg.Id)
On 2013/06/04 11:59:09, fwereade wrote:
> These could in general be smooshed inside the if; YMMV.

Not really, because err is reused across all cases.

https://codereview.appspot.com/9896046/diff/11001/state/apiserver/machiner.go...
state/apiserver/machiner.go:28: // Allow only for the owner agent or the
environment manager
On 2013/06/04 11:59:09, fwereade wrote:
> s/or the environment manager//

Done.

https://codereview.appspot.com/9896046/diff/11001/state/apiserver/machiner.go...
state/apiserver/machiner.go:90: }
On 2013/06/04 11:59:09, fwereade wrote:
> There are some *very* similar methods here, but maybe not quite similar enough
> to factor out. Bah.

I actually tried having a helper taking a list of ids and a callback taking
index and *state.Machine, returning []error. But actually using it makes the
code less readable :/

https://codereview.appspot.com/9896046/diff/11001/state/apiserver/machiner_te...
File state/apiserver/machiner_test.go (right):

https://codereview.appspot.com/9896046/diff/11001/state/apiserver/machiner_te...
state/apiserver/machiner_test.go:51: setDefaultPassword(c, s.machine0)
On 2013/06/04 11:59:09, fwereade wrote:
> s/0/1/
> 
> ...but consider whether we need password at all, now we have actual unit tests
> here and have dropped all the login stuff.

Good point, will remove password setting.

https://codereview.appspot.com/9896046/diff/11001/state/apiserver/machiner_te...
state/apiserver/machiner_test.go:92: // ...machine 1 is fine thought.
On 2013/06/04 11:59:09, fwereade wrote:
> s/ght/gh/

Done.

https://codereview.appspot.com/9896046/diff/11001/state/apiserver/machiner_te...
state/apiserver/machiner_test.go:135: c.Assert(s.machine1.Life(), Equals,
state.Dead)
On 2013/06/04 11:59:09, fwereade wrote:
> Is it overkill to also check that EnsureDead works on a Dead machine, and on a
> missing one? (which I don't think it currently does... and I *think* it
should,
> although I guess it could be argued that it's irrelevant in context...
> thoughts?)

The 42 test actually proves it doesn't work on missing machines. If it's
absolutely a required behavior I can add a special case. But again, think of the
client-side - maybe we can fake it out there instead.
Also, will add a test for a Dead machine.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b