Skip to content

Commit 87cf1dc

Browse files
committed
Simplify logic in UpdateDNSNameMappings
Previously, we were always updating the ipToDNSName in place, but a recent change was made to use a local copy instead. With that in place, we no longer need to first remove old and then add new IPs to te map. Instead we can just construct the new one only with the new IPs and reassign it. Signed-off-by: Kevin Klues <kklues@nvidia.com>
1 parent 0726bea commit 87cf1dc

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

cmd/compute-domain-daemon/dnsnames.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ func (m *DNSNameManager) UpdateDNSNameMappings(nodes []*nvapi.ComputeDomainNode)
6262
m.Lock()
6363
defer m.Unlock()
6464

65-
// Make a local copy of the current ipToDNSName mappings
66-
ipToDNSName := maps.Clone(m.ipToDNSName)
65+
// Make a local ipToDNSName mappings
66+
ipToDNSName := make(IPToDNSNameMap)
6767

6868
// Prefilter nodes to only consider those with the matching cliqueID
6969
var cliqueNodes []*nvapi.ComputeDomainNode
@@ -73,24 +73,8 @@ func (m *DNSNameManager) UpdateDNSNameMappings(nodes []*nvapi.ComputeDomainNode)
7373
}
7474
}
7575

76-
// Find and remove stale IPs from map
77-
currentIPs := make(map[string]bool)
76+
// Add IPs to map
7877
for _, node := range cliqueNodes {
79-
currentIPs[node.IPAddress] = true
80-
}
81-
for ip := range ipToDNSName {
82-
if !currentIPs[ip] {
83-
delete(ipToDNSName, ip)
84-
}
85-
}
86-
87-
// Add new IPs to map
88-
for _, node := range cliqueNodes {
89-
// If IP already has a DNS name, skip it
90-
if _, exists := ipToDNSName[node.IPAddress]; exists {
91-
continue
92-
}
93-
9478
// Construct the DNS name from the node index
9579
dnsName, err := m.constructDNSName(node)
9680
if err != nil {

0 commit comments

Comments
 (0)