diff --git a/internal/cmd/commands/server/server.go b/internal/cmd/commands/server/server.go index 98c0a8c013..0d1302353e 100644 --- a/internal/cmd/commands/server/server.go +++ b/internal/cmd/commands/server/server.go @@ -335,9 +335,17 @@ func (c *Command) Run(args []string) int { } if c.Config.HcpbClusterId != "" { - _, err := uuid.ParseUUID(c.Config.HcpbClusterId) + if len(c.Config.Worker.InitialUpstreams) > 0 { + c.UI.Error(fmt.Errorf("Initial upstreams and HCPB cluster ID are mutually exclusive fields").Error()) + return base.CommandUserError + } + clusterId := c.Config.HcpbClusterId + if strings.HasPrefix(clusterId, "int-") { + clusterId = strings.TrimPrefix(clusterId, "int-") + } + _, err := uuid.ParseUUID(clusterId) if err != nil { - c.UI.Error(fmt.Errorf("Invalid HCP Boundary cluster id %q: %w", c.Config.HcpbClusterId, err).Error()) + c.UI.Error(fmt.Errorf("Invalid HCP Boundary cluster ID %q: %w", clusterId, err).Error()) return base.CommandUserError } } diff --git a/internal/daemon/worker/controller_connection.go b/internal/daemon/worker/controller_connection.go index d044b36f63..c55d29e60f 100644 --- a/internal/daemon/worker/controller_connection.go +++ b/internal/daemon/worker/controller_connection.go @@ -36,7 +36,7 @@ import ( "google.golang.org/protobuf/types/known/structpb" ) -const hcpbUrlSuffix = ".proxy.boundary.hashicorp.cloud:9202" +var HandleHcpbClusterId func(s string) string // StartControllerConnections starts up the resolver and initiates controller // connection client creation @@ -60,8 +60,8 @@ func (w *Worker) StartControllerConnections() error { } if len(initialAddrs) == 0 { - if w.conf.RawConfig.HcpbClusterId != "" { - clusterAddress := fmt.Sprintf("%s%s", w.conf.RawConfig.HcpbClusterId, hcpbUrlSuffix) + if w.conf.RawConfig.HcpbClusterId != "" && HandleHcpbClusterId != nil { + clusterAddress := HandleHcpbClusterId(w.conf.RawConfig.HcpbClusterId) initialAddrs = append(initialAddrs, clusterAddress) event.WriteSysEvent(w.baseContext, op, fmt.Sprintf("Setting HCP Boundary cluster address %s as upstream address", clusterAddress)) } else { diff --git a/internal/daemon/worker/status.go b/internal/daemon/worker/status.go index 3abc242ac4..a50c0c45a8 100644 --- a/internal/daemon/worker/status.go +++ b/internal/daemon/worker/status.go @@ -218,9 +218,8 @@ func (w *Worker) sendWorkerStatus(cancelCtx context.Context, sessionManager sess if len(w.conf.RawConfig.Worker.InitialUpstreams) > 0 { addrs = append(addrs, w.conf.RawConfig.Worker.InitialUpstreams...) - } - if len(w.conf.RawConfig.HcpbClusterId) > 0 { - clusterAddress := fmt.Sprintf("%s%s", w.conf.RawConfig.HcpbClusterId, hcpbUrlSuffix) + } else if HandleHcpbClusterId != nil && len(w.conf.RawConfig.HcpbClusterId) > 0 { + clusterAddress := HandleHcpbClusterId(w.conf.RawConfig.HcpbClusterId) addrs = append(addrs, clusterAddress) }