From 61ec5b47e4ae885bed2750fd7497eee324ba0c01 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 3 Feb 2021 08:58:42 -0500 Subject: [PATCH] When running single-server mode, use public_cluster_addr if given (#904) When running single-server mode, use public_cluster_addr if given Right now you don't need to specify a controller address and we use the cluster listener address; this allows overriding it to the public_cluster_addr if one is given. If `controllers` is specified we allow it to be either the cluster listener or the public cluster address if one is specified before trying to parse and use it. --- CHANGELOG.md | 6 ++++++ internal/cmd/commands/server/server.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aaf4aa9bf..52d6a05645 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ Canonical reference for changes, improvements, and bugfixes for Boundary. ## Next +### New and Improved + +* server: When running single-server mode and `controllers` is not specified in + the `worker` block, use `public_cluster_addr` if given + ([PR](https://github.com/hashicorp/boundary/pull/904)) + ### Bug Fixes * api: Fix nil pointer panic that could occur when using TLS diff --git a/internal/cmd/commands/server/server.go b/internal/cmd/commands/server/server.go index 64fbbc5ae0..0784d1ba14 100644 --- a/internal/cmd/commands/server/server.go +++ b/internal/cmd/commands/server/server.go @@ -229,11 +229,18 @@ func (c *Command) Run(args []string) int { if c.Config.Controller != nil { switch len(c.Config.Worker.Controllers) { case 0: + if c.Config.Controller.PublicClusterAddr != "" { + clusterAddr = c.Config.Controller.PublicClusterAddr + } c.Config.Worker.Controllers = []string{clusterAddr} case 1: if c.Config.Worker.Controllers[0] == clusterAddr { break } + if c.Config.Controller.PublicClusterAddr != "" && + c.Config.Worker.Controllers[0] == c.Config.Controller.PublicClusterAddr { + break + } // Best effort see if it's a domain name and if not assume it must match host, _, err := net.SplitHostPort(c.Config.Worker.Controllers[0]) if err != nil && strings.Contains(err.Error(), "missing port in address") {