Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CE] feat(v2dns): enable v2 dns as default #20715

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changelog/20715.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```release-note:feature
dns: queries now default to a refactored DNS server that is v1 and v2 Catalog compatible.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do multi-line changelog entries do the right thing? I don't think I've authored one before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should wrap like normal markdown, which I think is OK here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also confirmed looking at 20812.txt - it should up as a single line 👍

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.
```
7 changes: 3 additions & 4 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
9 changes: 4 additions & 5 deletions agent/config/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"]`,
Expand All @@ -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"]`,
Expand Down
8 changes: 4 additions & 4 deletions agent/consul/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions agent/consul/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const (

LeaderTransferMinVersion = "1.6.0"
CatalogResourceExperimentName = "resource-apis"
V2DNSExperimentName = "v2dns"
V1DNSExperimentName = "v1dns"
V2TenancyExperimentName = "v2tenancy"
HCPAllowV2ResourceAPIs = "hcp-v2-resource-apis"
)
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion agent/dns_catalogv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
5 changes: 3 additions & 2 deletions agent/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -3338,6 +3338,7 @@ func TestDNS_V1ConfigReload(t *testing.T) {
min_ttl = 4
}
}
experiments = ["v1dns"]
`)
defer a.Shutdown()
testrpc.WaitForLeader(t, a.RPC, "dc1")
Expand Down
Loading