Redefine failover properties and logic for prepared queries
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 39
Description
#### Feature Description
To the failover{} section add specific fields like service and tags additionaly to have more flexibility to which service failover.
#### Use Case(s)
I want to have smart failover logic. Assume you have two DCs dc1 and dc2, in each dc deployed minio cluster. Cluster in DC1 is a primary and must be used by all components in DCs. DC1 service name: minio, DC2 service name minio-replica.
In my understanding we first return IPs from dc1 for both DCs requests and if no healthy switch to second dc.
```terraform
resource "consul_prepared_query" "minio_dns_with_failover" {
for_each = toset(data.consul_datacenters.all.datacenters)
name = "minio-faiolver"
datacenter = each.key
stored_token = data.consul_acl_token_secret_id.minio.secret_id
only_passing = true
near = "_agent"
service = "minio"
tags = ["primary"]
failover {
datacenters = ["dc2"]
service = "minio-replica" # Or I can set also tag additionally
tag = ["replica"]
}
dns {
ttl = "5s"
}
}
otherwise it is not possible to have automatic fail-over with consul DNS feature. And it is not allowed use replica cluster if primary alive this is a requirement
Contributor guide
Research direction
Start with the consul_prepared_query resource and its failover block shown in the issue, then trace how prepared-query failover currently selects datacenters, services, and tags. Done means the failover configuration can select the requested replica service and tags while preserving primary-service preference and switching only when the primary is unhealthy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- terraform
- Domain
- distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100