Hello Foreman Developers!
I’ve started a new custom Foreman Plugin for managing CNAMEs to a FQDN: GitHub - XMol/foreman_cnames: Make Foreman maintain a list of CNAME records for an interface. It is based off the Foreman Plugin Template and I stole most of the changes from an old pull request, which was motivated by a feature request to add support of CNAMEs to Foreman UI (#9388).
I’ve made quite some progress since the other two topics with questions on plugin development (Foreman plugin does not store interfaces changes to database, Cannot effectively overlay methods of DnsInterface by prepending a module, diff). However, I’ve reached the next road block: DNS orchestration.
Problem
Every patch to a NIC is considered a change on the CNAMEs, including the update with zero changes.
Foreman and Proxy versions
RedHat Satellite 6.13.7, which includes (among others)…
- satellite-6.13.7-1.el8sat
- katello-4.7.0-1.el8sat
- foreman-3.5.1.24-1.el8sat
- foreman-proxy-3.5.1-1.el8sat
Distribution and version
My development Foreman instance is running on
- Red Hat Enterprise Linux release 8.9 “Ootpa” (4.18.0-513.24.1.el8_9.x86_64)
Other relevant data
The issue arises from the patched function pending_dns_record_changes?
. Here, old
and self
are both a Nic::Managed
object. But the comparison attr_equivalent?(old.cnames, cnames)
always yields false
, because old
has no cnames
. The reason for that in turn is, that old
has no nic_id
and therefor Rails fails to extract the data from the associated tables.
Here is the current example host alias obtained through foreman-rake console
:
irb(main):001:0> ForemanCnames::HostAlias.select("id, nic_id, name, domain_id").first
=> #<ForemanCnames::HostAlias id: 3, name: "satellite-test", nic_id: 7958, domain_id: 1>
irb(main):002:0> Nic::Managed.find(7958).fqdn
=> "satellite-test-01.scc.kit.edu"
irb(main):003:0> Nic::Managed.find(7958).host_aliases.pluck(:id, :nic_id, :name, :domain_id)
=> [[3, 7958, "satellite-test", 1]]
irb(main):004:0> Nic::Managed.find(7958).cnames
=> ["satellite-test.scc.kit.edu"]
By dumping old
and self
inside pending_dns_record_changes?
, I find the following differences:
Attribute | old | self |
---|---|---|
id | nil | 7958 |
host_id | nil | 1937 |
created_at | nil | 2021-05-14 15:29:55.876959000 +0200 |
updated_at | nil | 2024-08-13 09:57:19.855433000 +0200 |
So there is sufficient information stored in old
to run ip
, ip6
and hostname
, but not for host_aliases
.
I found that old
is defined shorthandedly in the Orchestration
model. From that I conclude that this is not a standard Rails feature. Though I failed to find any line of code that initializes old
.
Could somebody kindly give me hints to that?
Thank you very much for your time,
Xavier Mol.