Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Use random apiserver address when dialing #7488
Conversation
axw
requested changes
Jun 12, 2017
It would be good to see some evidence that this actually does improve matters. Because all of the mongo writes have to go through the master, it might be better to always connect to the jujud that's running on the mongo master machine. Or not. I don't know.
| @@ -591,14 +592,27 @@ func dialAPI(info *Info, opts0 DialOpts) (*dialResult, error) { | ||
| if err != nil { | ||
| return nil, errors.Trace(err) | ||
| } | ||
| - dialInfo, err := dialWebsocketMulti(ctx, info.Addrs, path, opts) | ||
| + dialInfo, err := dialWebsocketMulti(ctx, shuffleAddresses(info.Addrs), path, opts) |
axw
Jun 12, 2017
Member
I'm -1 on applying this logic to client (non-agent) connections. Perhaps move this logic to worker/apicaller?
| if err != nil { | ||
| return nil, errors.Trace(err) | ||
| } | ||
| logger.Infof("connection established to %q", dialInfo.urlStr) | ||
| return dialInfo, nil | ||
| } | ||
| +func init() { | ||
| + rand.Seed(time.Now().UnixNano()) |
axw
Jun 12, 2017
Member
assuming you do move the code to worker/apicaller, please create a worker-specific rand.Rand rather than modifying global state
| @@ -83,12 +93,18 @@ func connectFallback( | ||
| conn api.Connection, didFallback bool, err error, | ||
| ) { | ||
| + infoCopy := *info | ||
| + if len(infoCopy.Addrs) > 1 { | ||
| + src := rand.NewSource(time.Now().UnixNano()) |
axw
Jun 12, 2017
Member
the Rand should really live longer than a single connection call, but I guess it's not really a big deal
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
|
Build failed: Tests failed |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
wallyworld commentedJun 12, 2017
Description of change
We want to ensure one controller in an HA setup is not swamped with connections.
So we shuffle the api addresses prior to dialling.
QA steps
Bootstrap, enable HA, and run some Juju operations.