Check if join allowed before determining addresses
@@ -193,11 +193,21 @@ func main() {
log.Fatalf("failed to parse Raft open timeout %s: %s", raftOpenTimeout, err.Error())
}
- // Determine join addresses.
- joins, err := determineJoinAddresses()
+ // Determine join addresses, if necessary.
+ ja, err := store.JoinAllowed(dataPath)
+ if err != nil {
+ log.Fatalf("unable to determine if join permitted: %s", err.Error())
+ }
+
+ var joins []string
+ if ja {
+ joins, err = determineJoinAddresses()
if err != nil {
log.Fatalf("unable to determine join addresses: %s", err.Error())
}
+ } else {
+ log.Println("node is already member of cluster, skipping determining join addresses")
+ }
// Now, open it.
if err := str.Open(len(joins) == 0); err != nil {
@@ -214,7 +224,6 @@ func main() {
// Execute any requested join operation.
if len(joins) > 0 {
log.Println("join addresses are:", joins)
- if str.JoinRequired() {
advAddr := raftAddr
if raftAdv != "" {
advAddr = raftAdv
@@ -224,9 +233,7 @@ func main() {
} else {
log.Println("successfully joined cluster at", j)
}
- } else {
- log.Println("node is already member of cluster, ignoring any join requests")
- }
+
} else {
log.Println("no join addresses available")
}
