Bug #25246
closedIPv6 record info destroyed on fact importing
Description
Short story:
So, it appears I can't rebuild or edit hosts when the IPv6 record is broken. I get an "Failed to enable <fqdn> for installation: ["Remove IPv6 DNS record for <fqdn> task failed with the following error: undefined method `destroy' for nil:NilClass"]".
Long story:
I created a virtual host, for which I've configured an IPv6 subnet (set to use EUI-64). Usually this remains empty (as the compute resource didn't assign a MAC address yet), untill I save it, after which (if I'm lucky) the EUI-64 is calculated and assigned. All is (quite) well up untill here.
However, at some point (still figuring out what that point in time is, will update this issue as soon as I figured it out), the IPv6 information is simply lost, no mention of it's existing anywhere. If I look at my domain db, then there's still an AAAA record assigned for that host. However, when rebuilding, it complains:
"Remove IPv6 DNS record for <fqdn> task failed with the following error: undefined method `destroy' for nil:NilClass"]"
If I try to edit my host, and simply remove the IPv6 (as a work-around), it always tries to delete the IPv6 record (which makes sense) but this fails with the same error:
"Remove IPv6 DNS record for <fqdn> task failed with the following error: undefined method `destroy' for nil:NilClass"]"
Looking at the YAML, the information regarding my IPv6 address, however, is still there, but it doesn't show up in the UI.
The foreman production logs show this:
2018-10-19T11:16:38 [W|app|e3f29] Remove IPv6 DNS record for <fqdn> task failed with the following error: undefined method `destroy' for nil:NilClass NoMethodError: undefined method `destroy' for nil:NilClass /usr/share/foreman/app/models/concerns/dns_interface.rb:51:in `del_dns_record' /usr/share/foreman/app/models/concerns/orchestration.rb:221:in `execute' /usr/share/foreman/app/models/concerns/orchestration.rb:145:in `block in process' /usr/share/foreman/app/models/concerns/orchestration.rb:137:in `each' /usr/share/foreman/app/models/concerns/orchestration.rb:137:in `process' /usr/share/foreman/app/models/concerns/orchestration.rb:44:in `around_save_orchestration'
Work around: last time I had to destroy and recreate my host altogether
Although it would be one thing to be more forgiving if the record is non-existing, I'd actually like to try and figure out what the root-cause is before trying to ignore erroneous situations.