From 2f26d5779b939be4acda0f9d7579163912f4dba3 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 14 Sep 2026 23:59:32 -0700 Subject: [PATCH] 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. --- weed/command/master.go | 8 +++++++- weed/command/mini.go | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/weed/command/master.go b/weed/command/master.go index 178827550..3ed2b5a8b 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -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, diff --git a/weed/command/mini.go b/weed/command/mini.go index 8ce45436a..500cee52d 100644 --- a/weed/command/mini.go +++ b/weed/command/mini.go @@ -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 {