mirror of https://github.com/hashicorp/consul
[CE] fix(v2dns): allow secondary datacenters (#20657)
fix(v2dns): allow secondary datacenterspull/20686/head
parent
4532ba682c
commit
e8d5ccdda3
|
@ -878,7 +878,6 @@ func (a *Agent) Start(ctx context.Context) error {
|
|||
|
||||
// start DNS servers
|
||||
if a.baseDeps.UseV2DNS() {
|
||||
a.logger.Warn("DNS v2 is under construction")
|
||||
if err := a.listenAndServeV2DNS(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -632,8 +632,7 @@ func TestBuilder_CheckExperimentsInSecondaryDatacenters(t *testing.T) {
|
|||
expectErr: true,
|
||||
},
|
||||
"secondary server v2dns": {
|
||||
hcl: secondary + `experiments = ["v2dns"]`,
|
||||
expectErr: true,
|
||||
hcl: secondary + `experiments = ["v2dns"]`,
|
||||
},
|
||||
"secondary server v2tenancy": {
|
||||
hcl: secondary + `experiments = ["v2tenancy"]`,
|
||||
|
|
|
@ -50,8 +50,10 @@ type Deps struct {
|
|||
EnterpriseDeps
|
||||
}
|
||||
|
||||
// UseV2DNS returns true if "v2-dns" is present in the Experiments
|
||||
// array of the agent config. It is assumed if the v2 resource APIs are enabled.
|
||||
// UseV2DNS returns true if "v2dns" is present in the Experiments
|
||||
// array of the agent config. V2 DNS refers to the refactored implementation of Consul's DNS server.
|
||||
// It can handle either the v1 or v2 Catalog APIs.
|
||||
// It is enabled automatically if the v2 resource APIs are enabled.
|
||||
func (d Deps) UseV2DNS() bool {
|
||||
if stringslice.Contains(d.Experiments, V2DNSExperimentName) || d.UseV2Resources() {
|
||||
return true
|
||||
|
|
|
@ -143,7 +143,7 @@ const (
|
|||
// Likely these will all be short lived exclusions.
|
||||
func IsExperimentAllowedOnSecondaries(name string) bool {
|
||||
switch name {
|
||||
case CatalogResourceExperimentName, V2DNSExperimentName, V2TenancyExperimentName:
|
||||
case CatalogResourceExperimentName, V2TenancyExperimentName:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
|
|
|
@ -984,7 +984,6 @@ func (r *Router) getAnswerExtraAndNs(result *discovery.Result, port discovery.Po
|
|||
answer = append(answer, makeNSRecord(domain, fqdn, ttl))
|
||||
extra = append(extra, extraRecord)
|
||||
case qType == dns.TypeSOA:
|
||||
// to be returned in the result.
|
||||
fqdn := canonicalNameForResult(result.Type, result.Node.Name, domain, result.Tenancy, port.Name)
|
||||
extraRecord := makeIPBasedRecord(fqdn, nodeAddress, ttl)
|
||||
|
||||
|
|
|
@ -261,7 +261,8 @@ func TestDNS_CatalogV2_Basic(t *testing.T) {
|
|||
require.Equal(t, 9, len(in.Answer), "answer count did not match expected\n\n%s", in.String())
|
||||
require.Equal(t, 9, len(in.Extra), "extra answer count did not match expected\n\n%s", in.String())
|
||||
} else {
|
||||
// Expect 1 result per port, per workload, up to the default limit of 3. In practice the results are truncated at 2.
|
||||
// Expect 1 result per port, per workload, up to the default limit of 3. In practice the results are truncated
|
||||
// at 2 because of the record byte size.
|
||||
require.Equal(t, 2, len(in.Answer), "answer count did not match expected\n\n%s", in.String())
|
||||
require.Equal(t, 2, len(in.Extra), "extra answer count did not match expected\n\n%s", in.String())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue