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:
Chris Lu
2026-09-14 23:59:32 -07:00
parent 14bc6e5e4f
commit 2f26d5779b
2 changed files with 14 additions and 1 deletions
+7 -1
View File
@@ -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,
+7
View File
@@ -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 {