Project

General

Profile

« Previous | Next » 

Revision db559817

Added by Dominic Cleal about 9 years ago

fixes #10298 - handle destroyed but present interfaces

When deleting a host and DHCP orchestration is removing reservations for NICs,
it generates a dhcp_record that contains next-server data. Determining the
next-server IP causes the primary interface to be fetched for DNS resolution,
to resolve the next-server hostname:

app/models/host/base.rb:390:in `get_interface_by_flag'
app/models/host/base.rb:253:in `primary_interface'
app/models/host/managed.rb:130:in `dns_ptr_record'
app/models/host/managed.rb:838:in `to_ip_address'
app/models/nic/managed.rb:16:in `to_ip_address'
app/models/concerns/orchestration/dhcp.rb:49:in `boot_server'
app/models/concerns/orchestration/dhcp.rb:72:in `dhcp_attrs'
app/models/concerns/orchestration/dhcp.rb:18:in `dhcp_record'
app/models/concerns/orchestration/dhcp.rb:32:in `del_dhcp'

get_interface_by_flag no longer attempts to modify the interface when it is
being deleted.

View differences:

app/models/host/base.rb
# we can't use SQL, we need to get even unsaved objects
interface = self.interfaces.detect(&flag)
interface.host = self if interface # inverse_of does not help (STI), but ignore this on deletion (interface is not found)
interface.host = self if interface && !interface.destroyed? # inverse_of does not help (STI), but ignore this on deletion
instance_variable_set(cache, interface)
end
end

Also available in: Unified diff