mirror of https://github.com/status-im/consul.git
[CE] feat(v2dns): enable v2 dns as default (#20715)
* feat(v2dns): enable v2 dns as default * changelog
This commit is contained in:
parent
d747b51dab
commit
6026ada0c9
|
@ -0,0 +1,6 @@
|
|||
```release-note:feature
|
||||
dns: queries now default to a refactored DNS server that is v1 and v2 Catalog compatible.
|
||||
Use `v1dns` in the `experiments` agent config to disable.
|
||||
The legacy server will be removed in a future release of Consul.
|
||||
See the [Consul 1.19.x Release Notes](https://developer.hashicorp.com/consul/docs/release-notes/consul/v1_19_x) for removed DNS features.
|
||||
```
|
|
@ -878,13 +878,12 @@ 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 {
|
||||
if a.baseDeps.UseV1DNS() {
|
||||
if err := a.listenAndServeV1DNS(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := a.listenAndServeV1DNS(); err != nil {
|
||||
if err := a.listenAndServeV2DNS(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -618,8 +618,8 @@ func TestBuilder_CheckExperimentsInSecondaryDatacenters(t *testing.T) {
|
|||
"primary server v2catalog": {
|
||||
hcl: primary + `experiments = ["resource-apis"]`,
|
||||
},
|
||||
"primary server v2dns": {
|
||||
hcl: primary + `experiments = ["v2dns"]`,
|
||||
"primary server v1dns": {
|
||||
hcl: primary + `experiments = ["v1dns"]`,
|
||||
},
|
||||
"primary server v2tenancy": {
|
||||
hcl: primary + `experiments = ["v2tenancy"]`,
|
||||
|
@ -631,9 +631,8 @@ func TestBuilder_CheckExperimentsInSecondaryDatacenters(t *testing.T) {
|
|||
hcl: secondary + `experiments = ["resource-apis"]`,
|
||||
expectErr: true,
|
||||
},
|
||||
"secondary server v2dns": {
|
||||
hcl: secondary + `experiments = ["v2dns"]`,
|
||||
expectErr: true,
|
||||
"secondary server v1dns": {
|
||||
hcl: secondary + `experiments = ["v1dns"]`,
|
||||
},
|
||||
"secondary server v2tenancy": {
|
||||
hcl: secondary + `experiments = ["v2tenancy"]`,
|
||||
|
|
|
@ -50,10 +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.
|
||||
func (d Deps) UseV2DNS() bool {
|
||||
if stringslice.Contains(d.Experiments, V2DNSExperimentName) || d.UseV2Resources() {
|
||||
// UseV1DNS returns true if "v1dns" is present in the Experiments
|
||||
// array of the agent config. It is ignored if the v2 resource APIs are enabled.
|
||||
func (d Deps) UseV1DNS() bool {
|
||||
if stringslice.Contains(d.Experiments, V1DNSExperimentName) && !d.UseV2Resources() {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
|
@ -132,7 +132,7 @@ const (
|
|||
|
||||
LeaderTransferMinVersion = "1.6.0"
|
||||
CatalogResourceExperimentName = "resource-apis"
|
||||
V2DNSExperimentName = "v2dns"
|
||||
V1DNSExperimentName = "v1dns"
|
||||
V2TenancyExperimentName = "v2tenancy"
|
||||
HCPAllowV2ResourceAPIs = "hcp-v2-resource-apis"
|
||||
)
|
||||
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -121,11 +121,11 @@ func dnsTXT(src string, txt []string) *dns.TXT {
|
|||
|
||||
func getVersionHCL(enableV2 bool) map[string]string {
|
||||
versions := map[string]string{
|
||||
"DNS: v1 / Catalog: v1": "",
|
||||
"DNS: v1 / Catalog: v1": "experiments=[\"v1dns\"]",
|
||||
}
|
||||
|
||||
if enableV2 {
|
||||
versions["DNS: v2 / Catalog: v1"] = `experiments=["v2dns"]`
|
||||
versions["DNS: v2 / Catalog: v1"] = ""
|
||||
}
|
||||
return versions
|
||||
}
|
||||
|
@ -3338,6 +3338,7 @@ func TestDNS_V1ConfigReload(t *testing.T) {
|
|||
min_ttl = 4
|
||||
}
|
||||
}
|
||||
experiments = ["v1dns"]
|
||||
`)
|
||||
defer a.Shutdown()
|
||||
testrpc.WaitForLeader(t, a.RPC, "dc1")
|
||||
|
|
Loading…
Reference in New Issue