mirror of
https://github.com/minio/minio.git
synced 2025-04-22 03:24:38 -04:00
fix: allow dynamic ports for API only in non-distributed setups (#18019)
fixes #17998
This commit is contained in:
parent
65939913b4
commit
b1c2dacab3
@ -391,7 +391,7 @@ func handleCommonCmdArgs(ctx *cli.Context) {
|
|||||||
if consoleAddr == "" {
|
if consoleAddr == "" {
|
||||||
p, err := xnet.GetFreePort()
|
p, err := xnet.GetFreePort()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.FatalIf(err, "Unable to get free port for console on the host")
|
logger.FatalIf(err, "Unable to get free port for Console UI on the host")
|
||||||
}
|
}
|
||||||
consoleAddr = net.JoinHostPort("", p.String())
|
consoleAddr = net.JoinHostPort("", p.String())
|
||||||
}
|
}
|
||||||
@ -405,6 +405,15 @@ func handleCommonCmdArgs(ctx *cli.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
globalMinioHost, globalMinioPort = mustSplitHostPort(addr)
|
globalMinioHost, globalMinioPort = mustSplitHostPort(addr)
|
||||||
|
if globalMinioPort == "0" {
|
||||||
|
p, err := xnet.GetFreePort()
|
||||||
|
if err != nil {
|
||||||
|
logger.FatalIf(err, "Unable to get free port for S3 API on the host")
|
||||||
|
}
|
||||||
|
globalMinioPort = p.String()
|
||||||
|
globalDynamicAPIPort = true
|
||||||
|
}
|
||||||
|
|
||||||
globalMinioConsoleHost, globalMinioConsolePort = mustSplitHostPort(consoleAddr)
|
globalMinioConsoleHost, globalMinioConsolePort = mustSplitHostPort(consoleAddr)
|
||||||
|
|
||||||
if globalMinioPort == globalMinioConsolePort {
|
if globalMinioPort == globalMinioConsolePort {
|
||||||
|
@ -402,6 +402,9 @@ var (
|
|||||||
|
|
||||||
// Captures all batch jobs metrics globally
|
// Captures all batch jobs metrics globally
|
||||||
globalBatchJobsMetrics batchJobMetrics
|
globalBatchJobsMetrics batchJobMetrics
|
||||||
|
|
||||||
|
// Indicates if server was started as `--address ":0"`
|
||||||
|
globalDynamicAPIPort bool
|
||||||
// Add new variable global values here.
|
// Add new variable global values here.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -255,6 +255,16 @@ func serverHandleCmdArgs(ctx *cli.Context) {
|
|||||||
logger.FatalIf(err, "Invalid command line arguments")
|
logger.FatalIf(err, "Invalid command line arguments")
|
||||||
globalNodes = globalEndpoints.GetNodes()
|
globalNodes = globalEndpoints.GetNodes()
|
||||||
|
|
||||||
|
globalIsErasure = (setupType == ErasureSetupType)
|
||||||
|
globalIsDistErasure = (setupType == DistErasureSetupType)
|
||||||
|
if globalIsDistErasure {
|
||||||
|
globalIsErasure = true
|
||||||
|
}
|
||||||
|
globalIsErasureSD = (setupType == ErasureSDSetupType)
|
||||||
|
if globalDynamicAPIPort && globalIsDistErasure {
|
||||||
|
logger.FatalIf(errInvalidArgument, "Invalid --address=\"%s\", port '0' is not allowed in a distributed erasure coded setup", ctx.String("address"))
|
||||||
|
}
|
||||||
|
|
||||||
globalLocalNodeName = GetLocalPeer(globalEndpoints, globalMinioHost, globalMinioPort)
|
globalLocalNodeName = GetLocalPeer(globalEndpoints, globalMinioHost, globalMinioPort)
|
||||||
nodeNameSum := sha256.Sum256([]byte(globalLocalNodeName))
|
nodeNameSum := sha256.Sum256([]byte(globalLocalNodeName))
|
||||||
globalLocalNodeNameHex = hex.EncodeToString(nodeNameSum[:])
|
globalLocalNodeNameHex = hex.EncodeToString(nodeNameSum[:])
|
||||||
@ -289,13 +299,6 @@ func serverHandleCmdArgs(ctx *cli.Context) {
|
|||||||
// To avoid this error situation we check for port availability.
|
// To avoid this error situation we check for port availability.
|
||||||
logger.FatalIf(xhttp.CheckPortAvailability(globalMinioHost, globalMinioPort, globalTCPOptions), "Unable to start the server")
|
logger.FatalIf(xhttp.CheckPortAvailability(globalMinioHost, globalMinioPort, globalTCPOptions), "Unable to start the server")
|
||||||
|
|
||||||
globalIsErasure = (setupType == ErasureSetupType)
|
|
||||||
globalIsDistErasure = (setupType == DistErasureSetupType)
|
|
||||||
if globalIsDistErasure {
|
|
||||||
globalIsErasure = true
|
|
||||||
}
|
|
||||||
globalIsErasureSD = (setupType == ErasureSDSetupType)
|
|
||||||
|
|
||||||
globalConnReadDeadline = ctx.Duration("conn-read-deadline")
|
globalConnReadDeadline = ctx.Duration("conn-read-deadline")
|
||||||
globalConnWriteDeadline = ctx.Duration("conn-write-deadline")
|
globalConnWriteDeadline = ctx.Duration("conn-write-deadline")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user