From 13f0b5c874c3cbf636366a2809c21c372475c02d Mon Sep 17 00:00:00 2001 From: DarrylWong Date: Thu, 28 Dec 2023 11:14:03 -0500 Subject: [PATCH] roachprod: revert AdminUIPort back to DefaultAdminUIPort The change #114097 removed default port assumptions for SQLPort and AdminUIPort, and instead finds open ports to assign. However, Prometheus scraping relies on this hardcoded AdminUIPort as it can't discover the port itself. This change temporarily reverts AdminUIPort back to the hardcoded port. Release note: none Epic: none Informs: #117125 --- pkg/cmd/roachprod/main.go | 2 ++ pkg/roachprod/install/cockroach.go | 8 ++++++-- pkg/roachprod/roachprod.go | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/roachprod/main.go b/pkg/cmd/roachprod/main.go index c4b41f33f88f..09ec91d26f38 100644 --- a/pkg/cmd/roachprod/main.go +++ b/pkg/cmd/roachprod/main.go @@ -572,6 +572,8 @@ environment variables to the cockroach process. install.EnvOption(nodeEnv), install.NumRacksOption(numRacks), } + // TODO(DarrylWong): remove once #117125 is addressed. + startOpts.AdminUIPort = 0 startOpts.Target = install.StartSharedProcessForVirtualCluster if externalProcessNodes != "" { diff --git a/pkg/roachprod/install/cockroach.go b/pkg/roachprod/install/cockroach.go index 2689bee7b5e3..4a40134990e3 100644 --- a/pkg/roachprod/install/cockroach.go +++ b/pkg/roachprod/install/cockroach.go @@ -344,13 +344,17 @@ func (c *SyncedCluster) Start(ctx context.Context, l *logger.Logger, startOpts S if startOpts.Target == StartRoutingProxy { return fmt.Errorf("start SQL proxy not implemented") } + // Local clusters do not support specifying ports. An error is returned if we // detect that they were set. - if c.IsLocal() && (startOpts.SQLPort != 0 || startOpts.AdminUIPort != 0) { + if c.IsLocal() { // We don't need to return an error if the ports are the default values // specified in DefaultStartOps, as these have not been specified explicitly // by the user. - if startOpts.SQLPort != config.DefaultSQLPort || startOpts.AdminUIPort != config.DefaultAdminUIPort { + if startOpts.SQLPort != 0 && startOpts.SQLPort != config.DefaultSQLPort { + return fmt.Errorf("local clusters do not support specifying ports") + } + if startOpts.AdminUIPort != 0 && startOpts.AdminUIPort != config.DefaultAdminUIPort { return fmt.Errorf("local clusters do not support specifying ports") } startOpts.SQLPort = 0 diff --git a/pkg/roachprod/roachprod.go b/pkg/roachprod/roachprod.go index fa59a224685f..2f7067871eb7 100644 --- a/pkg/roachprod/roachprod.go +++ b/pkg/roachprod/roachprod.go @@ -689,7 +689,8 @@ func DefaultStartOpts() install.StartOpts { InitTarget: 1, SQLPort: 0, VirtualClusterName: install.SystemInterfaceName, - AdminUIPort: 0, + // TODO(DarrylWong): revert back to 0 once #117125 is addressed. + AdminUIPort: config.DefaultAdminUIPort, } }