From 98209411fe6e568d232576025c79236883f0b696 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:06 -0500 Subject: [PATCH] Backport of structs: fix test for empty DNS configuration into release/1.6.x (#20254) 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 1074b6fc0cc..a6adb1dfa59 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -2871,7 +2871,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 5a2c49e3a67..2f21675f62b 100644 --- a/nomad/structs/structs_test.go +++ b/nomad/structs/structs_test.go @@ -7580,6 +7580,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"},