Consul Returns Incorrect Nodes when a Queried Node Doesn't Exist (Short Node Names)
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
#### Overview of the Issue
Consul DNS can return random nodes when a short node name doesn't exist.
This is directly related to this code:
https://github.com/hashicorp/consul/blob/7d6316305e8612066e0a23c7a1209e7dae5e7441/agent/consul/state/catalog.go#L38-L43
Which originates from this commit:
https://github.com/hashicorp/consul/commit/fe49c0a0abe8d0779abfca0bc13ad557173f664d
> I'm torn on this. It's useful from a UX perspective for an operator to be able to type in something that's short. At the same time, by enforcing an `8` character length, we reduced the probability of a user depending on the behavior and having it suddenly stop working in the future when a duplicate prefix is injected into the environment.
I was very surprised. From what I can tell, there is no way for an operator to op-out of this behavior.
---
#### Reproduction Steps
1. Run a cluster.
2. Use short 3 character host names for nodes, like `ba1` (really node names that also happen to be hex).
3. Get unlucky (a UUID just happens to start with that node name being queried), so in this case, have a node randomly generate a UUID that starts with `BA1...`.
Contributor guide
Research direction
Start with agent/consul/state/catalog.go at lines 38–43, then reproduce the DNS lookup using short hexadecimal node names such as ba1 and a UUID sharing that prefix. Verify the response when the queried short name does not exist. Done should prevent random-node results, but the issue does not specify the intended replacement response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- distributed-systems, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100