https://codereview.appspot.com/86490043/diff/1/state/addmachine.go#newcode555
state/addmachine.go:555: if err != nil {
If err==txn.ErrAborted, I think it's only going to be because someone
else has run EnsureAvailability concurrently. Perhaps we should check if
the voting server count has changed - if it has, return an error,
otherwise return nil because our work will already have been done.
LGTM modulo the following.
Very nice.
https:/ /codereview. appspot. com/86490043/ diff/1/ state/addmachin e.go
File state/addmachine.go (right):
https:/ /codereview. appspot. com/86490043/ diff/1/ state/addmachin e.go#newcode531 e.go:531: mdocs := make([]*machineDoc, -len(info. VotingMachineId s))
state/addmachin
numStateServers
nice clear logic here.
https:/ /codereview. appspot. com/86490043/ diff/1/ state/addmachin e.go#newcode555 e.go:555: if err != nil { ErrAborted, I think it's only going to be because someone
state/addmachin
If err==txn.
else has run EnsureAvailability concurrently. Perhaps we should check if
the voting server count has changed - if it has, return an error,
otherwise return nil because our work will already have been done.
https:/ /codereview. appspot. com/86490043/ diff/1/ state/addmachin e.go#newcode578 e.go:578: var newVotingMachin eIds, newMachineIds []string
state/addmachin
rather than two variables, it might be clearer if we did:
var newInfo StateServerInfo
and then, e.g. newInfo. MachineIds, ...)
newInfo.MachineIds = append(
then it's more obvious when we're just building
up ids in the new info.
https:/ /codereview. appspot. com/86490043/ diff/1/ state/addmachin e.go#newcode589 e.go:589: if !m.WantsVote() {
state/addmachin
switch the sense of the condition to avoid the negative?
https:/ /codereview. appspot. com/86490043/ diff/1/ state/addmachin e.go#newcode598 e.go:598: // If the machine does want to vote, we simply
state/addmachin
set novote and
Since the comments are inside the if statement, we can phrase them
unconditionally, which might read slightly more clearly.
// The machine wants to vote, so we simply set novote etc
https:/ /codereview. appspot. com/86490043/ diff/1/ state/addmachin e.go#newcode605 e.go:605: } else if !m.HasVote() {
state/addmachin
perhaps invert the condition here to save negatives?
https:/ /codereview. appspot. com/86490043/ diff/1/ state/addmachin e.go#newcode606 e.go:606: // If the machine does not want to vote and
state/addmachin
doesn't have a vote,
again, we can phrase it unconditionally.
https:/ /codereview. appspot. com/86490043/ diff/1/ state/addmachin e.go#newcode625 e.go:625: Assert: bson.D{{"novote", bson.D{{"$ne",
state/addmachin
false}}}},
I *think* this should be {{"$eq", true}}, because nil!=false
and legacy machines may have a nil novote field.
similarly below.
https:/ /codereview. appspot. com/86490043/ diff/1/ state/addmachin e.go#newcode655 e.go:655: Update: bson.D{{"$pull", bson.D{{"jobs", n}}}},
state/addmachin
JobManageEnviro
perhaps set novote=false here too?
https:/ /codereview. appspot. com/86490043/