As stated in the parent task (T149617) we're going to automatically generate the DNS configuration for the configured services so that they can be discovered querying the DNS directly. The proposed solution follows.
When querying services that are present in multiple datacenters, the response will be generated according to the following schema:
|Service capability||Query||Default Response||Response if default is DOWN|
|active/active||RO endpoint||Local DC endpoint IP||Remote DC endpoint IP|
|active/active||RW endpoint||Local DC endpoint IP||Remote DC endpoint IP|
|active/passive||RO endpoint||Local DC endpoint IP||Remote DC endpoint IP|
|active/passive||RW endpoint||Active (from etcd) DC endpoint IP||Local failover IP|
The configuration of the DNS will be generated with all the endpoints, and in the case of an active/passive service, when querying the RW endpoint, only the active one will be in an UP state and the other(s) will be in a DOWN state.
The mechanism to update the state file monitored by gdnsd must ensure that at any given time only one endpoint is UP if the service capability is active/passive.
As a failover mechanism in case no endpoint will be available, a valid IP will be returned in any case, to avoid issues with clients not behaving correctly if no DNS answer is returned and the DNS negative cache.
The failover IP will just respond 503s to any request and there will be one for each DC, in order to always respond with the local one.