X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5aa470ef5aa86f7946be8d379e409deacfabba67..fc8e572937f2fd61bdc1e7f34a2e3f9a5cebd7ff:/services/api/app/models/node.rb diff --git a/services/api/app/models/node.rb b/services/api/app/models/node.rb index 502ae26594..c38f6817db 100644 --- a/services/api/app/models/node.rb +++ b/services/api/app/models/node.rb @@ -137,6 +137,17 @@ class Node < ArvadosModel def dns_server_update if self.hostname_changed? or self.ip_address_changed? + if not self.ip_address.nil? + stale_conflicting_nodes = Node.where('id != ? and ip_address = ? and last_ping_at < ?',self.id,self.ip_address,10.minutes.ago) + if not stale_conflicting_nodes.empty? + # One or more stale compute node records have the same IP address as the new node. + # Clear the ip_address field on the stale nodes. + stale_conflicting_nodes.each do |stale_node| + stale_node.ip_address = nil + stale_node.save! + end + end + end if self.hostname and self.ip_address self.class.dns_server_update(self.hostname, self.ip_address) end