diff --git a/.changelog/11585.txt b/.changelog/11585.txt new file mode 100644 index 00000000000..833e3ba5bb9 --- /dev/null +++ b/.changelog/11585.txt @@ -0,0 +1,3 @@ +```release-note:bug +client: Fixed a bug where clients would ignore the `client_auto_join` setting after losing connection with the servers, causing them to incorrectly fallback to Consul discovery if it was set to `false`. +``` diff --git a/client/client.go b/client/client.go index 5bc142406cf..8b6d0ad75e2 100644 --- a/client/client.go +++ b/client/client.go @@ -2690,11 +2690,13 @@ func taskIsPresent(taskName string, tasks []*structs.Task) bool { // triggerDiscovery causes a Consul discovery to begin (if one hasn't already) func (c *Client) triggerDiscovery() { - select { - case c.triggerDiscoveryCh <- struct{}{}: - // Discovery goroutine was released to execute - default: - // Discovery goroutine was already running + if c.configCopy.ConsulConfig.ClientAutoJoin != nil && *c.configCopy.ConsulConfig.ClientAutoJoin { + select { + case c.triggerDiscoveryCh <- struct{}{}: + // Discovery goroutine was released to execute + default: + // Discovery goroutine was already running + } } }