diff --git a/api/services.go b/api/services.go index 365bf848463..c9b74dd1586 100644 --- a/api/services.go +++ b/api/services.go @@ -310,13 +310,9 @@ type ConsulMeshGateway struct { } func (c *ConsulMeshGateway) Canonicalize() { - if c == nil { - return - } - - if c.Mode == "" { - c.Mode = "none" - } + // Mode may be empty string, indicating behavior will defer to Consul + // service-defaults config entry. + return } func (c *ConsulMeshGateway) Copy() *ConsulMeshGateway { diff --git a/api/services_test.go b/api/services_test.go index 14cd3827f8e..2ba4452d1e8 100644 --- a/api/services_test.go +++ b/api/services_test.go @@ -613,13 +613,15 @@ func TestService_ConsulMeshGateway_Canonicalize(t *testing.T) { }) t.Run("unset mode", func(t *testing.T) { - c := &ConsulMeshGateway{ - Mode: "", - } + c := &ConsulMeshGateway{Mode: ""} c.Canonicalize() - require.Equal(t, &ConsulMeshGateway{ - Mode: "none", - }, c) + require.Equal(t, "", c.Mode) + }) + + t.Run("set mode", func(t *testing.T) { + c := &ConsulMeshGateway{Mode: "remote"} + c.Canonicalize() + require.Equal(t, "remote", c.Mode) }) } diff --git a/vendor/github.com/hashicorp/nomad/api/services.go b/vendor/github.com/hashicorp/nomad/api/services.go index 365bf848463..c9b74dd1586 100644 --- a/vendor/github.com/hashicorp/nomad/api/services.go +++ b/vendor/github.com/hashicorp/nomad/api/services.go @@ -310,13 +310,9 @@ type ConsulMeshGateway struct { } func (c *ConsulMeshGateway) Canonicalize() { - if c == nil { - return - } - - if c.Mode == "" { - c.Mode = "none" - } + // Mode may be empty string, indicating behavior will defer to Consul + // service-defaults config entry. + return } func (c *ConsulMeshGateway) Copy() *ConsulMeshGateway { diff --git a/website/content/docs/job-specification/upstreams.mdx b/website/content/docs/job-specification/upstreams.mdx index 1b540d219d1..91bb9bd6cdc 100644 --- a/website/content/docs/job-specification/upstreams.mdx +++ b/website/content/docs/job-specification/upstreams.mdx @@ -94,8 +94,8 @@ job "countdash" { ### `mesh_gateway` Parameters -- `mode` `(string: "default")` - The mode of operation in which to use [Connect Mesh Gateways][mesh_gateways] -Defaults to the mode as determined by the Consul [service-defaults][service_defaults_mode] +- `mode` `(string: "")` - The mode of operation in which to use [Connect Mesh Gateways][mesh_gateways]. + If left unset, the mode will default to the mode as determined by the Consul [service-defaults][service_defaults_mode] configuration for the service. Can be configured with the following modes: - `local` - In this mode the Connect proxy makes its outbound connection to a gateway running in the same datacenter. That gateway is then responsible for