Bug #17873
closedforeman_url ignores templates proxy when provisioning discovered host
Description
When provisioning a discovered host and changing the provisioning interface, the foreman_url method ignores a templates (or tftp) proxy set on the subnet.
Unsure yet if this is really limited to discovery or an issue in core.
foreman_url method calls
proxy = @host.try(:subnet).try(:tftp)
to find the proxy.
It seems like subnet is nil, however the (new!) provisioning interface has a subnet attached.
Steps to reproduce:
Provision a discovered host, add a new bond interface as primary, provision and managed (tick all three!).
Save the discovered host.
The deployed PXELinux template will now have the foreman url set and not the one from the proxy.
Debug output when rendering the template (this is interesting!)
host: #{@host} (#{@host.class}), subnet: #{@host.try(:subnet)}, proxy: #{@host.try(:subnet).try(:tftp)}, provision_interface: #{@host.try(:provision_interface).try(:inspect)}, primary_interface: #{@host.try(:primary_interface).try(:inspect)}
yields:
host: abc.example.com (Host::Managed), subnet: , proxy: , provision_interface: #<Nic::Bond id: nil, mac: nil, ip: "1.2.3.4", type: "Nic::Bond", name: "abc.example.com", host_id: 14325, subnet_id: 135, domain_id: 1, attrs: {}, created_at: nil, updated_at: nil, provider: nil, username: nil, password: nil, virtual: true, link: true, identifier: "bond0", tag: "", attached_to: "", managed: true, mode: "active-backup", attached_devices: "p5p1,p5p2", bond_options: "", primary: true, provision: true, compute_attributes: {}, execution: false, ip6: "", subnet6_id: nil>, primary_interface: #<Nic::Managed id: 17646, mac: "...", ip: "", type: "Nic::Managed", name: "abc", host_id: 14325, subnet_id: nil, domain_id: nil, ... subnet6_id: nil>
That means:
When it tries to save/validate the provision_interface and render the template, the primary interface (used for foreman_url) is still the old/wrong interface without the subnet set.
Updated by Timo Goebel about 8 years ago
Timo Goebel wrote:
Unsure yet if this is really limited to discovery or an issue in core.
I can't reproduce this with "just Foreman".
Updated by Timo Goebel about 8 years ago
The only workaround I could come up is to change foreman_url like so:
Before:
proxy = @host.try(:subnet).try(:tftp)
After:
primary_interface = @host.try(:interfaces).try(:find) {|i| i.primary? } proxy = primary_interface.try(:subnet).try(:tftp)
Which should basically be the same.
Updated by The Foreman Bot about 8 years ago
- Status changed from New to Ready For Testing
- Assignee set to Timo Goebel
- Pull request https://github.com/theforeman/foreman_discovery/pull/320 added
Updated by Anonymous about 8 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset foreman_discovery|e9c626c7258ce405dbe3d95051a5692ac1d87763.
Updated by Lukas Zapletal over 7 years ago
- Related to Bug #19313: Auto-provisioning does not orchestrate TFTP added
Updated by Lukas Zapletal over 7 years ago
For the record, this change caused issues with TFTP not being orchestrated due to missing association to provision interface, tracked in bug #19313.