mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 13:30:46 +02:00
mini: wire the shared metrics port, and tolerate an unset one
weed mini builds MasterOptions directly and never set metricsHttpPort, so reading it in toMasterOption dereferenced nil and crashed startup. Point mini's master, volume and filer at its single -metricsPort listener, the same way weed server does, and treat an unset port as disabled so a partially initialised MasterOptions cannot panic again. Reproduced with 'weed mini -dir=... -s3.port=...', which is what the S3 filer-group and delete-regression suites start.
This commit is contained in:
@@ -465,6 +465,12 @@ func peerIndex(self pb.ServerAddress, peers []pb.ServerAddress) int {
|
||||
}
|
||||
|
||||
func (m *MasterOptions) toMasterOption(whiteList []string) *weed_server.MasterOption {
|
||||
// Not every caller wires up every flag, so treat an unset metrics port as
|
||||
// disabled rather than dereferencing nil.
|
||||
metricsPort := 0
|
||||
if m.metricsHttpPort != nil {
|
||||
metricsPort = *m.metricsHttpPort
|
||||
}
|
||||
masterAddress := pb.NewServerAddress(*m.ip, *m.port, *m.portGrpc)
|
||||
return &weed_server.MasterOption{
|
||||
Master: masterAddress,
|
||||
@@ -479,7 +485,7 @@ func (m *MasterOptions) toMasterOption(whiteList []string) *weed_server.MasterOp
|
||||
WhiteList: whiteList,
|
||||
DisableHttp: *m.disableHttp,
|
||||
MetricsAddress: *m.metricsAddress,
|
||||
MetricsPort: *m.metricsHttpPort,
|
||||
MetricsPort: metricsPort,
|
||||
MetricsIntervalSec: *m.metricsIntervalSec,
|
||||
TelemetryUrl: *m.telemetryUrl,
|
||||
TelemetryEnabled: *m.telemetryEnabled,
|
||||
|
||||
@@ -1308,6 +1308,13 @@ func runMini(cmd *Command, args []string) bool {
|
||||
}
|
||||
pb.RegisterLocalGrpcSocket(*miniIp, *miniAdminOptions.grpcPort, fmt.Sprintf("/tmp/seaweedfs-admin-grpc-%d.sock", *miniAdminOptions.grpcPort))
|
||||
|
||||
// One process, one shared Prometheus registry, so this single listener
|
||||
// serves every component's series. Point each component at it so they all
|
||||
// advertise the same port to the master.
|
||||
miniMasterOptions.metricsHttpPort = miniMetricsHttpPort
|
||||
miniOptions.v.metricsHttpPort = miniMetricsHttpPort
|
||||
miniFilerOptions.metricsHttpPort = miniMetricsHttpPort
|
||||
|
||||
go stats_collect.StartMetricsServer(*miniMetricsHttpIp, *miniMetricsHttpPort)
|
||||
|
||||
if *miniMasterOptions.volumeSizeLimitMB > util.MaxVolumeSizeLimitMB {
|
||||
|
||||
Reference in New Issue
Block a user