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

Issue 9614043: state/api: Machine API needed by machiner (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 3 months ago by dimitern
Modified:
12 years, 3 months ago
Reviewers:
gz, rog, mp+164920, TheMue
Visibility:
Public.

Description

state/api: Machine API needed by machiner This introduces several new API calls, needed by the worker/machiner to handle machines through the API: * Life * EnsureDead * SetAgentAlive * SetStatus In the course of this some refactoring of the API server was in order: * Introduced presence.Pinger support * Watchers and pingers are now both handled as resources which have a Stop() method * Added a couple of root-level permission checking calls: - authOwner(), taking an entity with a Tag() method and returning true if the authenticated user's tag matches the entity's tag - authEnvironManager() returning true if the authenticated user matches the environment manager (machine with JobManageEnviron) Permission checks are performed to ensure only agents (or managers) can access the new machine API calls. A few other drive-by changes done as well as suggested. https://code.launchpad.net/~dimitern/juju-core/040-machine-api-calls-needed-by-machiner/+merge/164920 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 48

Patch Set 2 : state/api: Machine API needed by machiner #

Total comments: 6

Patch Set 3 : state/api: Machine API needed by machiner #

Unified diffs Side-by-side diffs Delta from patch set Stats (+479 lines, -100 lines) Patch
A [revision details] View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M state/api/apiclient.go View 1 1 chunk +49 lines, -0 lines 0 comments Download
M state/api/error.go View 1 1 chunk +1 line, -0 lines 0 comments Download
M state/api/params/params.go View 1 4 chunks +23 lines, -1 line 0 comments Download
M state/api/params/params_test.go View 1 1 chunk +1 line, -1 line 0 comments Download
M state/apiserver/api_test.go View 1 2 8 chunks +232 lines, -1 line 0 comments Download
M state/apiserver/apiserver.go View 1 11 chunks +156 lines, -90 lines 0 comments Download
M state/apiserver/error.go View 1 2 chunks +3 lines, -0 lines 0 comments Download
M state/machine.go View 1 1 chunk +5 lines, -0 lines 0 comments Download
M state/megawatcher.go View 1 1 chunk +1 line, -1 line 0 comments Download
M state/megawatcher_internal_test.go View 1 5 chunks +5 lines, -5 lines 0 comments Download
M state/presence/presence.go View 1 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 9
dimitern
Please take a look.
12 years, 3 months ago (2013-05-21 15:11:37 UTC) #1
rog
LGTM with the error code fix and some other minor suggestions. https://codereview.appspot.com/9614043/diff/1/state/api/apiclient.go File state/api/apiclient.go (right): ...
12 years, 3 months ago (2013-05-21 15:37:20 UTC) #2
TheMue
Mostly LGTM, only minor comments additional to Rogers. https://codereview.appspot.com/9614043/diff/1/state/api/apiclient.go File state/api/apiclient.go (right): https://codereview.appspot.com/9614043/diff/1/state/api/apiclient.go#newcode370 state/api/apiclient.go:370: type ...
12 years, 3 months ago (2013-05-21 15:44:01 UTC) #3
rog
https://codereview.appspot.com/9614043/diff/1/state/apiserver/apiserver.go File state/apiserver/apiserver.go (right): https://codereview.appspot.com/9614043/diff/1/state/apiserver/apiserver.go#newcode268 state/apiserver/apiserver.go:268: ew := w.r.(*state.EntityWatcher) On 2013/05/21 15:44:01, TheMue wrote: > ...
12 years, 3 months ago (2013-05-21 16:05:14 UTC) #4
gz
LGTM, some rambling comments, not all of them actionable, so ignore as appropriate. https://codereview.appspot.com/9614043/diff/1/state/api/apiclient.go File ...
12 years, 3 months ago (2013-05-21 16:19:40 UTC) #5
dimitern
Please take a look. https://codereview.appspot.com/9614043/diff/1/state/api/apiclient.go File state/api/apiclient.go (right): https://codereview.appspot.com/9614043/diff/1/state/api/apiclient.go#newcode352 state/api/apiclient.go:352: // a HasAssignedUnitsError. On 2013/05/21 ...
12 years, 3 months ago (2013-05-21 16:41:25 UTC) #6
rog
LGTM with a separate error code test. https://codereview.appspot.com/9614043/diff/1/state/api/apiclient.go File state/api/apiclient.go (right): https://codereview.appspot.com/9614043/diff/1/state/api/apiclient.go#newcode335 state/api/apiclient.go:335: // returns ...
12 years, 3 months ago (2013-05-21 16:52:33 UTC) #7
dimitern
Thanks gz, here are some answers to the best of my understanding. https://codereview.appspot.com/9614043/diff/1/state/api/apiclient.go File state/api/apiclient.go ...
12 years, 3 months ago (2013-05-21 16:52:53 UTC) #8
dimitern
12 years, 3 months ago (2013-05-21 17:26:27 UTC) #9
*** Submitted:

state/api: Machine API needed by machiner

This introduces several new API calls, needed by the
worker/machiner to handle machines through the API:
* Life
* EnsureDead
* SetAgentAlive
* SetStatus

In the course of this some refactoring of the API
server was in order:
* Introduced presence.Pinger support
* Watchers and pingers are now both handled as resources
  which have a Stop() method
* Added a couple of root-level permission checking calls:
- authOwner(), taking an entity with a Tag() method and returning
  true if the authenticated user's tag matches the entity's tag
- authEnvironManager() returning true if the authenticated user
  matches the environment manager (machine with JobManageEnviron)

Permission checks are performed to ensure only agents (or managers)
can access the new machine API calls.

A few other drive-by changes done as well as suggested.

R=rog, TheMue, gz
CC=
https://codereview.appspot.com/9614043

https://codereview.appspot.com/9614043/diff/3002/state/apiserver/api_test.go
File state/apiserver/api_test.go (right):

https://codereview.appspot.com/9614043/diff/3002/state/apiserver/api_test.go#...
state/apiserver/api_test.go:304: c.Check(api.ErrCode(err), Equals,
api.CodeHasAssignedUnits)
On 2013/05/21 16:52:33, rog wrote:
> this isn't the right place for the errcode check, i think.
> there should be a separate test that checks the err code.

Done.

https://codereview.appspot.com/9614043/diff/3002/state/machine.go
File state/machine.go (right):

https://codereview.appspot.com/9614043/diff/3002/state/machine.go#newcode210
state/machine.go:210: func IsHasAssignedUnitsError(err error) bool {
On 2013/05/21 16:52:33, rog wrote:
> is has :-)

Well.. it has has :)

https://codereview.appspot.com/9614043/diff/3002/state/presence/presence.go
File state/presence/presence.go (right):

https://codereview.appspot.com/9614043/diff/3002/state/presence/presence.go#n...
state/presence/presence.go:416: // Pinger periodically reports that a specific
key is alive, so that
On 2013/05/21 16:52:33, rog wrote:
> I think this can remain as it was. As long as it's a full sentence, the rule
> isn't hard and fast.

Nah, let's keep to our defined standards.
A lot more stupid cases come to mind.
Sign in to reply to this message.

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