From a1918e2684be496e07a624e5668cc1f603248e1e Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Fri, 29 Mar 2024 10:10:38 -0500 Subject: [PATCH] Backport of structs: fix test for empty DNS configuration into release/1.7.x (#20255) Co-authored-by: Tim Gross --- nomad/structs/structs.go | 2 +- nomad/structs/structs_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 47c81910c77..13f86188c49 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -2851,7 +2851,7 @@ func (d *DNSConfig) IsZero() bool { if d == nil { return true } - return len(d.Options) == 0 || len(d.Searches) == 0 || len(d.Servers) == 0 + return len(d.Options) == 0 && len(d.Searches) == 0 && len(d.Servers) == 0 } // NetworkResource is used to represent available network diff --git a/nomad/structs/structs_test.go b/nomad/structs/structs_test.go index 05ff3081de4..7060d95eba0 100644 --- a/nomad/structs/structs_test.go +++ b/nomad/structs/structs_test.go @@ -7660,6 +7660,7 @@ func TestDNSConfig_Equal(t *testing.T) { must.Equal[*DNSConfig](t, nil, nil) must.NotEqual[*DNSConfig](t, nil, new(DNSConfig)) + must.NotEqual[*DNSConfig](t, nil, &DNSConfig{Servers: []string{"8.8.8.8"}}) must.StructEqual(t, &DNSConfig{ Servers: []string{"8.8.8.8", "8.8.4.4"},