MachineAgent using EnsureMongoServer
https://code.launchpad.net/~natefinch/juju-core/030-MA-HA/+merge/209954
(do not edit description out of merge proposal)
Just some preliminary notes, I haven't looked too deeply. https://codereview.appspot.com/72500043/diff/60001/agent/mongo/mongo.go File agent/mongo/mongo.go (right): https://codereview.appspot.com/72500043/diff/60001/agent/mongo/mongo.go#newcode205 agent/mongo/mongo.go:205: ...
https://codereview.appspot.com/72500043/diff/80001/cmd/jujud/bootstrap.go
File cmd/jujud/bootstrap.go (right):
https://codereview.appspot.com/72500043/diff/80001/cmd/jujud/bootstrap.go#new...
cmd/jujud/bootstrap.go:99: st, _, err := c.Conf.config.InitializeState(
On 2014/04/03 15:36:13, nate.finch wrote:
> On 2014/03/28 01:26:55, axw wrote:
> > What where is the bootstrap machine's mongo installed?
> It's done inside initialize state.
Sorry if I'm being slow, but I still don't see how this can work. I just merged
it into trunk and it doesn't work for the local provider.
It appears that the ensureMongoServer call below is meant to install the upstart
service. The agent.InitializeState method requires mongo to be available
(otherwise what's it intialising?), so that's a bit back-to-front I think.
I moved InitializeState down to the bottom of this function, but bootstrap still
gets stuck trying to dial in MaybeInitiateMongoServer. I don't quite know what
I'm doing with mongo, but I'll keep poking around a bit longer.
https://codereview.appspot.com/72500043/diff/140001/cmd/jujud/bootstrap.go
File cmd/jujud/bootstrap.go (right):
https://codereview.appspot.com/72500043/diff/140001/cmd/jujud/bootstrap.go#ne...
cmd/jujud/bootstrap.go:153: if err := ensureMongoServer(agentConfig.DataDir(),
envCfg.StatePort()); err != nil {
I think this has to come before the InitializeState call above.
https://codereview.appspot.com/72500043/diff/140001/cmd/jujud/bootstrap.go#ne...
cmd/jujud/bootstrap.go:157: return
maybeInitiateMongoServer(mongo.InitiateMongoParams{
It seems a bit wasteful to make another connection to mongo when just did that
to for InitializeState. I suggest defer st.Close() after coming out of the
ChangeConfig above, and then use st.MongoSession().
There's another reason to prefer this: you can only use the localhost exception
up until the admin database has users populated. Reusing the session simplifies
authentication.
https://codereview.appspot.com/72500043/diff/140001/cmd/jujud/bootstrap.go#ne...
cmd/jujud/bootstrap.go:157: return
maybeInitiateMongoServer(mongo.InitiateMongoParams{
I found that I had to set dialInfo.Direct=true when initiating the replicaset,
otherwise mgo just sits in a loop and never progresses. Not sure if this is a
bug or expected behaviour.
On 2014/04/04 07:51:24, axw wrote:
> https://codereview.appspot.com/72500043/diff/140001/cmd/jujud/bootstrap.go
> File cmd/jujud/bootstrap.go (right):
>
>
https://codereview.appspot.com/72500043/diff/140001/cmd/jujud/bootstrap.go#ne...
> cmd/jujud/bootstrap.go:153: if err := ensureMongoServer(agentConfig.DataDir(),
> envCfg.StatePort()); err != nil {
> I think this has to come before the InitializeState call above.
>
>
https://codereview.appspot.com/72500043/diff/140001/cmd/jujud/bootstrap.go#ne...
> cmd/jujud/bootstrap.go:157: return
> maybeInitiateMongoServer(mongo.InitiateMongoParams{
> It seems a bit wasteful to make another connection to mongo when just did that
> to for InitializeState. I suggest defer st.Close() after coming out of the
> ChangeConfig above, and then use st.MongoSession().
Scratch that: seems that the replicaset config must be configured before all
else.
> There's another reason to prefer this: you can only use the localhost
exception
> up until the admin database has users populated. Reusing the session
simplifies
> authentication.
>
>
https://codereview.appspot.com/72500043/diff/140001/cmd/jujud/bootstrap.go#ne...
> cmd/jujud/bootstrap.go:157: return
> maybeInitiateMongoServer(mongo.InitiateMongoParams{
> I found that I had to set dialInfo.Direct=true when initiating the replicaset,
> otherwise mgo just sits in a loop and never progresses. Not sure if this is a
> bug or expected behaviour.
Also, you can't just change Addrs[0] to the preferredHost, because then the
localhost exception fails.
I think you probably want a separate field for the preferred address in
InitiateMongoParams.
stil LGTM https://codereview.appspot.com/72500043/diff/220001/cmd/jujud/bootstrap_test.go File cmd/jujud/bootstrap_test.go (right): https://codereview.appspot.com/72500043/diff/220001/cmd/jujud/bootstrap_test.go#newcode438 cmd/jujud/bootstrap_test.go:438: maybePanic(err) sorry for not picking up on ...
actually this does not LGTM without the following fix. https://codereview.appspot.com/72500043/diff/220001/cmd/jujud/bootstrap.go File cmd/jujud/bootstrap.go (right): https://codereview.appspot.com/72500043/diff/220001/cmd/jujud/bootstrap.go#newcode167 cmd/jujud/bootstrap.go:167: ...
actually this does not LGTM without the following fix.
https://codereview.appspot.com/72500043/diff/220001/cmd/jujud/bootstrap.go
File cmd/jujud/bootstrap.go (right):
https://codereview.appspot.com/72500043/diff/220001/cmd/jujud/bootstrap.go#ne...
cmd/jujud/bootstrap.go:167: MemberHostPort: mongo.SelectPeerAddress(addrs),
This doesn't seem right - SelectPeerAddress will not return a host:port.
Have you actually tried this live?
I think you probably want:
peerAddr := mongo.SelectPeerAddress(addrs)
if peerAddr == "" {
return fmt.Errorf("no appropriate peer address found in %q", addrs)
}
peerHostPort := net.JoinHostPort(peerAddr, fmt.Sprint(port))
memberHostPort := net.JoinHostPort(mongo.SelectPeer
...
MemberHostPort: memberHostPort,
Issue 72500043: MachineAgent using EnsureMongoServer
Created 11 years, 1 month ago by natefinch
Modified 11 years ago
Reviewers: mp+209954_code.launchpad.net, jameinel, wwitzel3, axw, rog
Base URL:
Comments: 81