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

Issue 102920048: state/*: login to /ENVUUID/api URLs

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 11 months ago by jameinel
Modified:
9 years, 11 months ago
Reviewers:
hduran, mp+221632, rog
Visibility:
Public.

Description

state/*: login to /ENVUUID/api URLs This is an evolution of: https://codereview.appspot.com/101760046/ https://code.launchpad.net/~jameinel/juju-core/login-returns-env-tag/+merge/221021 Instead of having Login itself take an Environment Tag, it changes our API so that we connect to a different URL. Instead of "wss://address:host/" we now will try to connect to "wss://address:host/ENVUUID/api". The change itself involves a few variables: 1) A new dependency "github.com/bmizerany/pat", which is a reasonably simple library that lets you put in patterns to your http.Mux, which will then transform "/:path/foo" as matching anything in ":path" and adding that as a Query argument instead. 2) Using that library to expose /:environ/api and .../log, .../charms, .../tools. This patch itself doesn't make use of the new URLs, because it is not backwards compatible, and I didn't want to quite sort out how to do the backwards compatibility yet. 3) We do use the environ/api one when we know the Environment UUID, which Login will return for us (and we will cache). I did test that this still works against a 1.18 server (it connects to the /ENVUUID/api address, but as that is a child of / it still works). I also ran into something a bit surprising, but probably ok. If you actually force the environ-uuid to be invalid in your .jenv file, the code will try to connect, and fail with InvalidEnviron. However, our connection code has lots of resilience built in, so we end up just falling back to the Config fallback open, which naturally logs in as just environUUID="", which then finds the right environment UUID and caches it. So this code doesn't fix all possible paths, but I think it improves the state of the world that I'd like to land it and get back to API versioning. https://code.launchpad.net/~jameinel/juju-core/login-env-urls/+merge/221632 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : state/*: login to /ENVUUID/api URLs #

Total comments: 18
Unified diffs Side-by-side diffs Delta from patch set Stats (+801 lines, -94 lines) Patch
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M dependencies.tsv View 1 1 chunk +1 line, -0 lines 0 comments Download
M environs/configstore/disk.go View 3 chunks +5 lines, -2 lines 0 comments Download
M environs/configstore/interface.go View 1 chunk +4 lines, -0 lines 2 comments Download
M environs/configstore/interface_test.go View 2 chunks +6 lines, -4 lines 0 comments Download
M juju/api.go View 1 7 chunks +42 lines, -14 lines 0 comments Download
M juju/apiconn_test.go View 8 chunks +139 lines, -3 lines 0 comments Download
M juju/mock_test.go View 2 chunks +5 lines, -0 lines 0 comments Download
M state/api/apiclient.go View 1 9 chunks +41 lines, -6 lines 2 comments Download
M state/api/apiclient_test.go View 1 4 chunks +49 lines, -1 line 0 comments Download
M state/api/client_test.go View 3 chunks +69 lines, -6 lines 0 comments Download
M state/api/export_test.go View 1 chunk +1 line, -0 lines 2 comments Download
M state/api/params/params.go View 1 1 chunk +2 lines, -1 line 0 comments Download
M state/api/state.go View 1 chunk +1 line, -0 lines 0 comments Download
M state/api/state_test.go View 2 chunks +21 lines, -0 lines 0 comments Download
M state/apiserver/admin.go View 2 chunks +21 lines, -1 line 0 comments Download
M state/apiserver/apiserver.go View 1 6 chunks +73 lines, -15 lines 8 comments Download
M state/apiserver/charms.go View 1 chunk +4 lines, -0 lines 0 comments Download
M state/apiserver/charms_test.go View 4 chunks +93 lines, -3 lines 0 comments Download
M state/apiserver/common/errors.go View 2 chunks +2 lines, -0 lines 2 comments Download
M state/apiserver/debuglog.go View 1 chunk +5 lines, -0 lines 0 comments Download
M state/apiserver/debuglog_test.go View 5 chunks +54 lines, -13 lines 0 comments Download
M state/apiserver/export_test.go View 1 chunk +4 lines, -0 lines 0 comments Download
M state/apiserver/httphandler.go View 1 chunk +25 lines, -0 lines 2 comments Download
M state/apiserver/login_test.go View 3 chunks +30 lines, -5 lines 0 comments Download
M state/apiserver/root_test.go View 2 chunks +28 lines, -0 lines 0 comments Download
M state/apiserver/tools.go View 1 chunk +4 lines, -0 lines 0 comments Download
M state/apiserver/tools_test.go View 4 chunks +70 lines, -20 lines 0 comments Download

Messages

Total messages: 6
jameinel
Please take a look.
9 years, 11 months ago (2014-06-01 09:43:06 UTC) #1
jameinel
Please take a look.
9 years, 11 months ago (2014-06-01 10:15:53 UTC) #2
rog
Looks great in general, with a few queries and suggestions. https://codereview.appspot.com/102920048/diff/20001/environs/configstore/interface.go File environs/configstore/interface.go (right): https://codereview.appspot.com/102920048/diff/20001/environs/configstore/interface.go#newcode25 ...
9 years, 11 months ago (2014-06-02 10:08:18 UTC) #3
hduran
On 2014/06/01 09:43:06, jameinel wrote: > Please take a look. LGTM if rog comments are ...
9 years, 11 months ago (2014-06-02 13:41:53 UTC) #4
jameinel
I had written this up, but it didn't get published because I switched to git. ...
9 years, 11 months ago (2014-06-05 13:47:19 UTC) #5
rog
9 years, 11 months ago (2014-06-05 14:05:04 UTC) #6
https://codereview.appspot.com/102920048/diff/20001/state/apiserver/apiserver.go
File state/apiserver/apiserver.go (right):

https://codereview.appspot.com/102920048/diff/20001/state/apiserver/apiserver...
state/apiserver/apiserver.go:210: handleAll(mux, "/",
http.HandlerFunc(srv.apiHandler))
On 2014/06/05 13:47:19, jameinel wrote:
> On 2014/06/02 10:08:18, rog wrote:
> > Can we please deprecate the behaviour that addressing any undefined url
gives
> us
> > the API? It was always unintentional, and now I believe it's actively
harmful.
> > It should be pretty simple to do - just write a handler that 404's any path
> > that's not /, and register it to /.
> 
> For compatibility, we still have to serve the API at /. I believe bmizerany
> actually does 404 things that aren't at /, but we can write some tests to be
> clear about it.

I haven't tried it, but from the examples in the godoc, it
looks like that's not actually the case.

For example (from the godoc):

/hello/:name/
Will match:

/hello/blake/
/hello/keith/foo
Sign in to reply to this message.

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