mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-25 00:39:08 +08:00
Fix -raftHashicorp and -raftBootstrap flag propagation. (#4309)
`weed server` was not correctly propagating `-master.raftHashicorp` and `-master.raftBootstrap` flags when starting the master server. Related to #4307
This commit is contained in:
parent
71b33faef0
commit
dd71f54c6b
@ -2,13 +2,14 @@ package command
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
hashicorpRaft "github.com/hashicorp/raft"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
hashicorpRaft "github.com/hashicorp/raft"
|
||||||
|
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
@ -163,11 +164,11 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) {
|
|||||||
RaftResumeState: *masterOption.raftResumeState,
|
RaftResumeState: *masterOption.raftResumeState,
|
||||||
HeartbeatInterval: *masterOption.heartbeatInterval,
|
HeartbeatInterval: *masterOption.heartbeatInterval,
|
||||||
ElectionTimeout: *masterOption.electionTimeout,
|
ElectionTimeout: *masterOption.electionTimeout,
|
||||||
RaftBootstrap: *m.raftBootstrap,
|
RaftBootstrap: *masterOption.raftBootstrap,
|
||||||
}
|
}
|
||||||
var raftServer *weed_server.RaftServer
|
var raftServer *weed_server.RaftServer
|
||||||
var err error
|
var err error
|
||||||
if *m.raftHashicorp {
|
if *masterOption.raftHashicorp {
|
||||||
if raftServer, err = weed_server.NewHashicorpRaftServer(raftServerOption); err != nil {
|
if raftServer, err = weed_server.NewHashicorpRaftServer(raftServerOption); err != nil {
|
||||||
glog.Fatalf("NewHashicorpRaftServer: %s", err)
|
glog.Fatalf("NewHashicorpRaftServer: %s", err)
|
||||||
}
|
}
|
||||||
@ -180,7 +181,7 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) {
|
|||||||
ms.SetRaftServer(raftServer)
|
ms.SetRaftServer(raftServer)
|
||||||
r.HandleFunc("/cluster/status", raftServer.StatusHandler).Methods("GET")
|
r.HandleFunc("/cluster/status", raftServer.StatusHandler).Methods("GET")
|
||||||
r.HandleFunc("/cluster/healthz", raftServer.HealthzHandler).Methods("GET", "HEAD")
|
r.HandleFunc("/cluster/healthz", raftServer.HealthzHandler).Methods("GET", "HEAD")
|
||||||
if *m.raftHashicorp {
|
if *masterOption.raftHashicorp {
|
||||||
r.HandleFunc("/raft/stats", raftServer.StatsRaftHandler).Methods("GET")
|
r.HandleFunc("/raft/stats", raftServer.StatsRaftHandler).Methods("GET")
|
||||||
}
|
}
|
||||||
// starting grpc server
|
// starting grpc server
|
||||||
@ -191,7 +192,7 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) {
|
|||||||
}
|
}
|
||||||
grpcS := pb.NewGrpcServer(security.LoadServerTLS(util.GetViper(), "grpc.master"))
|
grpcS := pb.NewGrpcServer(security.LoadServerTLS(util.GetViper(), "grpc.master"))
|
||||||
master_pb.RegisterSeaweedServer(grpcS, ms)
|
master_pb.RegisterSeaweedServer(grpcS, ms)
|
||||||
if *m.raftHashicorp {
|
if *masterOption.raftHashicorp {
|
||||||
raftServer.TransportManager.Register(grpcS)
|
raftServer.TransportManager.Register(grpcS)
|
||||||
} else {
|
} else {
|
||||||
protobuf.RegisterRaftServer(grpcS, raftServer)
|
protobuf.RegisterRaftServer(grpcS, raftServer)
|
||||||
@ -204,7 +205,7 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) {
|
|||||||
go grpcS.Serve(grpcL)
|
go grpcS.Serve(grpcL)
|
||||||
|
|
||||||
timeSleep := 1500 * time.Millisecond
|
timeSleep := 1500 * time.Millisecond
|
||||||
if !*m.raftHashicorp {
|
if !*masterOption.raftHashicorp {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(timeSleep)
|
time.Sleep(timeSleep)
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ func init() {
|
|||||||
masterOptions.metricsIntervalSec = cmdServer.Flag.Int("master.metrics.intervalSeconds", 15, "Prometheus push interval in seconds")
|
masterOptions.metricsIntervalSec = cmdServer.Flag.Int("master.metrics.intervalSeconds", 15, "Prometheus push interval in seconds")
|
||||||
masterOptions.raftResumeState = cmdServer.Flag.Bool("master.resumeState", false, "resume previous state on start master server")
|
masterOptions.raftResumeState = cmdServer.Flag.Bool("master.resumeState", false, "resume previous state on start master server")
|
||||||
masterOptions.raftHashicorp = cmdServer.Flag.Bool("master.raftHashicorp", false, "use hashicorp raft")
|
masterOptions.raftHashicorp = cmdServer.Flag.Bool("master.raftHashicorp", false, "use hashicorp raft")
|
||||||
|
masterOptions.raftBootstrap = cmdMaster.Flag.Bool("master.raftBootstrap", false, "Whether to bootstrap the Raft cluster")
|
||||||
masterOptions.heartbeatInterval = cmdServer.Flag.Duration("master.heartbeatInterval", 300*time.Millisecond, "heartbeat interval of master servers, and will be randomly multiplied by [1, 1.25)")
|
masterOptions.heartbeatInterval = cmdServer.Flag.Duration("master.heartbeatInterval", 300*time.Millisecond, "heartbeat interval of master servers, and will be randomly multiplied by [1, 1.25)")
|
||||||
masterOptions.electionTimeout = cmdServer.Flag.Duration("master.electionTimeout", 10*time.Second, "election timeout of master servers")
|
masterOptions.electionTimeout = cmdServer.Flag.Duration("master.electionTimeout", 10*time.Second, "election timeout of master servers")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user