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

Issue 100810045: APIWorker should only connect to API on localhost

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

Description

APIWorker should only connect to API on localhost In some cases, APIWorker might try to connect to a different address than localhost in State Servers, for this APIInfo was modified to add localhost with the configured StateServerPort to the Addrs list if not present. To make sure localhost option will be picked first Open now sorts the Addrs list before trying to connect to make sure local ones will be tried first. https://code.launchpad.net/~hduran-8/juju-core/apiworker_force_local_connection/+merge/221221 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : APIWorker should only connect to API on localhost #

Total comments: 4

Patch Set 3 : APIWorker should only connect to API on localhost #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+155 lines, -9 lines) Patch
A [revision details] View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M agent/agent.go View 1 2 1 chunk +17 lines, -1 line 1 comment Download
M agent/agent_test.go View 1 2 1 chunk +34 lines, -2 lines 1 comment Download
M cmd/jujud/agent_test.go View 1 2 2 chunks +11 lines, -5 lines 0 comments Download
M state/api/apiclient.go View 1 2 3 chunks +16 lines, -1 line 2 comments Download
M state/api/apiclient_test.go View 1 2 1 chunk +75 lines, -0 lines 1 comment Download

Messages

Total messages: 7
hduran
Please take a look.
9 years, 11 months ago (2014-05-28 19:06:50 UTC) #1
natefinch
I think we need to test that we're actually passing the results of the address ...
9 years, 11 months ago (2014-05-28 20:19:18 UTC) #2
fwereade
Forgive the pontification, but I think this demands a bit more thought. As it is ...
9 years, 11 months ago (2014-05-28 20:33:11 UTC) #3
hduran
Please take a look.
9 years, 11 months ago (2014-05-30 02:03:01 UTC) #4
natefinch
LGTM with a couple minor modifications. https://codereview.appspot.com/100810045/diff/40001/agent/agent.go File agent/agent.go (right): https://codereview.appspot.com/100810045/diff/40001/agent/agent.go#newcode615 agent/agent.go:615: if eachAddress == ...
9 years, 11 months ago (2014-05-30 14:12:29 UTC) #5
wwitzel3
https://codereview.appspot.com/100810045/diff/40001/state/api/apiclient.go File state/api/apiclient.go (right): https://codereview.appspot.com/100810045/diff/40001/state/api/apiclient.go#newcode111 state/api/apiclient.go:111: We should use the built-in sort here. http://golang.org/pkg/sort/ type ...
9 years, 11 months ago (2014-05-30 14:12:32 UTC) #6
jameinel
9 years, 11 months ago (2014-06-01 10:00:53 UTC) #7
On 2014/05/30 14:12:32, wwitzel3 wrote:
> https://codereview.appspot.com/100810045/diff/40001/state/api/apiclient.go
> File state/api/apiclient.go (right):
> 
>
https://codereview.appspot.com/100810045/diff/40001/state/api/apiclient.go#ne...
> state/api/apiclient.go:111: 
> We should use the built-in sort here.
> 
> http://golang.org/pkg/sort/
> 
> type LocalhostFirst []string
> 
> func (a LocalhostFirst) Len() int { return len(a) }
> func (a LocalhostFirst) Swap(i int, j int) { a[i], a[j] = a[j], a[i] }
> func (a LocalhostFirst) Less(i int, j int) bool { return
strings.HasPrefix(a[i],
> "localhost") }
> 
> return sort.Sort(LocalhostFirst(addrs))

So I think the sort.Sort is actually incorrect, having worked in this code a
bit.

Specifically, this breaks the order for *everything else*. And we intentionally
move the last-successful-connection to the beginning of the list, so the order
isn't random.

So for things like EC2, where you have public and private (etc) addresses, this
now essentially randomizes which one we are going to try to connect to first.
(Actually, it probably sorts the private addresses first because 10. comes
before 172.).

I can see the point of wanting to try localhost first, and in HA mode we really
do want localhost. However, I think what we *really* want is to check "if
JobManageEnviron" then *only* connect to localhost, right?
Sign in to reply to this message.

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