Skip to content

Commit

Permalink
mongo: check all addresses when deciding if machine is master
Browse files Browse the repository at this point in the history
The recent fix for LP #1397376 meant that on MAAS the replicaset
master address no longer matches the address returned by
SelectPeerAddress - no state server thought it was the master. This
breaks upgrades among other things.

All machine addresses are no compared against the replicaset master
address.

Fixes LP #1403200.
  • Loading branch information
Menno Smits committed Dec 17, 2014
1 parent 1a4e1a0 commit f22f2f0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mongo/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func IsMaster(session *mgo.Session, obj WithAddresses) (bool, error) {
if err == replicaset.ErrMasterNotConfigured {
return true, nil
}

if err != nil {
return false, err
}
Expand All @@ -104,8 +103,12 @@ func IsMaster(session *mgo.Session, obj WithAddresses) (bool, error) {
return false, err
}

machinePeerAddr := SelectPeerAddress(addrs)
return machinePeerAddr == masterAddr, nil
for _, addr := range addrs {
if addr.Value == masterAddr {
return true, nil
}
}
return false, nil
}

// SelectPeerAddress returns the address to use as the
Expand Down

0 comments on commit f22f2f0

Please sign in to comment.