Skip to content

Commit 04f82ca

Browse files
Apply DNS host config on change only
1 parent 709e24e commit 04f82ca

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

client/internal/dns/server.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ type DefaultServer struct {
7979
updateSerial uint64
8080
previousConfigHash uint64
8181
currentConfig HostDNSConfig
82+
currentConfigHash uint64
8283
handlerChain *HandlerChain
8384
extraDomains map[domain.Domain]int
8485

@@ -583,10 +584,27 @@ func (s *DefaultServer) applyHostConfig() {
583584

584585
log.Debugf("extra match domains: %v", maps.Keys(s.extraDomains))
585586

587+
hash, err := hashstructure.Hash(config, hashstructure.FormatV2, &hashstructure.HashOptions{
588+
ZeroNil: true,
589+
IgnoreZeroValue: true,
590+
SlicesAsSets: true,
591+
UseStringer: true,
592+
})
593+
if err != nil {
594+
log.Errorf("unable to hash the host dns configuration, got error: %s", err)
595+
}
596+
597+
if s.currentConfigHash == hash {
598+
log.Infof("not applying host config as there are no changes")
599+
return
600+
}
601+
586602
if err := s.hostManager.applyDNSConfig(config, s.stateManager); err != nil {
587603
log.Errorf("failed to apply DNS host manager update: %v", err)
588604
}
589605

606+
s.currentConfigHash = hash
607+
590608
s.registerFallback(config)
591609
}
592610

0 commit comments

Comments
 (0)