hashicorp / hashicorp/consul

Ability to watch for events in all data centers

Open
#20,871 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
30.1k
Forks
4.6k
Avg merge
1d 18h
Merged PRs (30d)
39

Description

#### Feature Description
Currently the Watch API and command both default to listening for events or service changes in one data center:

>[datacenter](https://developer.hashicorp.com/consul/docs/dynamic-app-config/watches#datacenter) - Can be provided to override the agent's default datacenter.

https://developer.hashicorp.com/consul/docs/dynamic-app-config/watches#global-parameters

A workaround for this is to define multiple watchers, one for each data center. But that is not a great workaround because:

- When number of data center changes the config needs to be changed to account for that.
- Multiple watchers can trigger the same handler in essentially the same moment for two different DCs causing race conditions.

All of this would be much simpler if `-datacenter=all` was supported.

#### Use Case(s)
In our case this doesn't work since we want to be able to detect events across all data centers. This useful for triggering configuration of WireGuard VPN, which exists on all hosts across all data centers, and needs to be updated every time a new host shows up, or leaves the network. With the current setup it would require extra automation to either continuously update the list of watchers, or use the API and dynamically query all data centers.

Contributor guide

Open the contributing guide

Research direction

Start by locating the Watch API and watch command implementations, then trace how the datacenter parameter selects the event scope. Define how an all-datacenter watch should behave when datacenters change, including handler triggering, and verify the result with the relevant watch tests or command checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, cli, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.