diff --git a/.release/linux/package/etc/boundary.d/worker.hcl b/.release/linux/package/etc/boundary.d/worker.hcl index 5ac07e935a..28a0ce3259 100644 --- a/.release/linux/package/etc/boundary.d/worker.hcl +++ b/.release/linux/package/etc/boundary.d/worker.hcl @@ -13,7 +13,7 @@ # description = "A default worker created demonstration" # # Workers must be able to reach controllers on :9201 -# controllers = [ +# initial_upstreams = [ # "10.0.0.1", # "10.0.0.2", # "10.0.0.3", diff --git a/CHANGELOG.md b/CHANGELOG.md index 35ec6d6b64..e578bd7d0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Canonical reference for changes, improvements, and bugfixes for Boundary. ## Next +* Remove deprecated `controllers` field from the worker config, which was deprecated for +`initial_upstreams`([PR](https://github.com/hashicorp/boundary/pull/5125)) + ## 0.17.2 (Unreleased) ### Changes diff --git a/enos/modules/aws_boundary/templates/worker.hcl b/enos/modules/aws_boundary/templates/worker.hcl index 90e2bc2d88..afcd95ce4c 100644 --- a/enos/modules/aws_boundary/templates/worker.hcl +++ b/enos/modules/aws_boundary/templates/worker.hcl @@ -13,7 +13,7 @@ worker { description = "Enos Boundary worker ${id}" # Workers must be able to reach controllers on :9201 - controllers = ${controller_ips} + initial_upstreams = ${controller_ips} public_addr = "${public_addr}" diff --git a/enos/modules/aws_boundary/templates/worker_bsr.hcl b/enos/modules/aws_boundary/templates/worker_bsr.hcl index b1446cafb0..764735fef8 100644 --- a/enos/modules/aws_boundary/templates/worker_bsr.hcl +++ b/enos/modules/aws_boundary/templates/worker_bsr.hcl @@ -13,7 +13,7 @@ worker { description = "Enos Boundary worker ${id}" # Workers must be able to reach controllers on :9201 - controllers = ${controller_ips} + initial_upstreams = ${controller_ips} public_addr = "${public_addr}" diff --git a/internal/cmd/commands/server/server.go b/internal/cmd/commands/server/server.go index 2d6cc2cd38..b62dac74c6 100644 --- a/internal/cmd/commands/server/server.go +++ b/internal/cmd/commands/server/server.go @@ -340,9 +340,6 @@ func (c *Command) Run(args []string) int { c.UI.Error(`Config activates worker but no listener with "proxy" purpose found`) return base.CommandUserError } - if c.Config.Worker.ControllersRaw != nil { - c.UI.Warn("The \"controllers\" field for worker config is deprecated. Please use \"initial_upstreams\" instead.") - } if err := c.SetupWorkerPublicAddress(c.Config, ""); err != nil { c.UI.Error(err.Error()) diff --git a/internal/cmd/config/config.go b/internal/cmd/config/config.go index ab1c2d3a94..6b2dbbc1a4 100644 --- a/internal/cmd/config/config.go +++ b/internal/cmd/config/config.go @@ -271,10 +271,6 @@ type Worker struct { InitialUpstreams []string `hcl:"-"` InitialUpstreamsRaw any `hcl:"initial_upstreams"` - // The ControllersRaw field is deprecated and users should use InitialUpstreamsRaw instead. - // TODO: remove this field when support is discontinued. - ControllersRaw any `hcl:"controllers"` - // We use a raw interface for parsing so that people can use JSON-like // syntax that maps directly to the filter input or possibly more familiar // key=value syntax, as well as accepting a string denoting an env or file @@ -1056,17 +1052,6 @@ func Parse(d string) (*Config, error) { return result, nil } -// supportControllersRawConfig returns either initialUpstreamsRaw or controllersRaw depending on which is populated. Errors when both fields are populated. -func supportControllersRawConfig(initialUpstreamsRaw, controllersRaw any) (any, error) { - switch { - case initialUpstreamsRaw == nil && controllersRaw != nil: - return controllersRaw, nil - case initialUpstreamsRaw != nil && controllersRaw != nil: - return nil, fmt.Errorf("both initial_upstreams and controllers fields are populated") - } - return initialUpstreamsRaw, nil -} - func parseApiRateLimits(node ast.Node) (ratelimit.Configs, error) { list, ok := node.(*ast.ObjectList) if !ok { @@ -1103,19 +1088,15 @@ func parseWorkerUpstreams(c *Config) ([]string, error) { if c == nil || c.Worker == nil { return nil, fmt.Errorf("config or worker field is nil") } - if c.Worker.InitialUpstreamsRaw == nil && c.Worker.ControllersRaw == nil { + if c.Worker.InitialUpstreamsRaw == nil { // return nil here so that other address sources can be provided outside of config return nil, nil } - rawUpstreams, err := supportControllersRawConfig(c.Worker.InitialUpstreamsRaw, c.Worker.ControllersRaw) - if err != nil { - return nil, err - } - switch t := rawUpstreams.(type) { + switch t := c.Worker.InitialUpstreamsRaw.(type) { case []any: var upstreams []string - err := mapstructure.WeakDecode(rawUpstreams, &upstreams) + err := mapstructure.WeakDecode(c.Worker.InitialUpstreamsRaw, &upstreams) if err != nil { return nil, fmt.Errorf("failed to decode worker initial_upstreams block into config field: %w", err) } diff --git a/internal/cmd/config/config_load_test.go b/internal/cmd/config/config_load_test.go index 526fc5e289..3a42398171 100644 --- a/internal/cmd/config/config_load_test.go +++ b/internal/cmd/config/config_load_test.go @@ -383,7 +383,6 @@ func TestLoad(t *testing.T) { PublicAddr: "", InitialUpstreams: []string{"boundary:9201"}, InitialUpstreamsRaw: []any{"boundary:9201"}, - ControllersRaw: nil, Tags: nil, TagsRaw: nil, SuccessfulStatusGracePeriodDuration: 0, @@ -810,7 +809,6 @@ func TestLoad(t *testing.T) { PublicAddr: "", InitialUpstreams: []string{"boundary:9201"}, InitialUpstreamsRaw: []any{"boundary:9201"}, - ControllersRaw: nil, Tags: nil, TagsRaw: nil, SuccessfulStatusGracePeriodDuration: 0, @@ -1232,7 +1230,6 @@ func TestLoad(t *testing.T) { PublicAddr: "", InitialUpstreams: []string{"boundary:9201"}, InitialUpstreamsRaw: []any{"boundary:9201"}, - ControllersRaw: nil, Tags: nil, TagsRaw: nil, SuccessfulStatusGracePeriodDuration: 0, @@ -1673,7 +1670,6 @@ func TestLoad(t *testing.T) { PublicAddr: "", InitialUpstreams: []string{"boundary:9201"}, InitialUpstreamsRaw: []any{"boundary:9201"}, - ControllersRaw: nil, Tags: nil, TagsRaw: nil, SuccessfulStatusGracePeriodDuration: 0, diff --git a/internal/cmd/config/config_test.go b/internal/cmd/config/config_test.go index 65cdf88eca..30449cc7ba 100644 --- a/internal/cmd/config/config_test.go +++ b/internal/cmd/config/config_test.go @@ -1609,40 +1609,6 @@ func TestWorkerUpstreams(t *testing.T) { expErr: true, expErrIs: parseutil.ErrNotAUrl, }, - { - name: "Worker using deprecated controllers field", - in: ` - worker { - name = "test" - controllers = ["127.0.0.1", "127.0.0.2", "127.0.0.3"] - }`, - expWorkerUpstreams: []string{"127.0.0.1", "127.0.0.2", "127.0.0.3"}, - expErr: false, - }, - { - name: "Different values in controllers and initial_upstreams field", - in: ` - worker { - name = "test" - controllers = ["127.0.0.1", "127.0.0.2", "127.0.0.3"] - initial_upstreams = ["127.0.0.1"] - }`, - expWorkerUpstreams: nil, - expErr: true, - expErrStr: "Failed to parse worker upstreams: both initial_upstreams and controllers fields are populated", - }, - { - name: "Identical values in controllers and initial_upstreams field", - in: ` - worker { - name = "test" - controllers = ["127.0.0.1"] - initial_upstreams = ["127.0.0.1"] - }`, - expWorkerUpstreams: nil, - expErr: true, - expErrStr: "Failed to parse worker upstreams: both initial_upstreams and controllers fields are populated", - }, } for _, tt := range tests {