Project

General

Profile

Bug #17873

foreman_url ignores templates proxy when provisioning discovered host

Added by Timo Goebel about 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Discovery plugin
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

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.


Related issues

Related to Discovery - Bug #19313: Auto-provisioning does not orchestrate TFTPClosed2017-04-19

Associated revisions

Revision e9c626c7 (diff)
Added by Timo Goebel about 4 years ago

fixes #17873 - clear association cache when converting host

History

#1 Updated by Timo Goebel about 4 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".

#2 Updated by Timo Goebel about 4 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.

#3 Updated by The Foreman Bot about 4 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

#4 Updated by Anonymous about 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#5 Updated by Lukas Zapletal over 3 years ago

  • Related to Bug #19313: Auto-provisioning does not orchestrate TFTP added

#6 Updated by Lukas Zapletal over 3 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.

Also available in: Atom PDF