Bug #23909

VMware “Could not match network interface” on VM creation

Added by Zachary Bedell about 1 month ago. Updated 9 days ago.

Category:Compute resources - VMware
Target version:1.19.0
Difficulty: Team Backlog:
Triaged: Fixed in Releases:
Bugzilla link: Found in Releases:1.17.1
Pull request:https://github.com/theforeman/foreman/pull/5685


I’ve found an edge case where the fix for bug #19623 isn’t working. This may also relate to bug #11106. The error message is a closer fit to #11106, but the root cause looks like a variation on #19623.

As far as I can tell, the issue is caused by collisions between the id/key and ref attributes of two vCenter network objects. Our environment matches the conditions in the original bug where we’re post-vCenter migration with legacy id ref’s on the distributed virtual switches. It looks like we have an object where the ref matches the id of another object’s key.

The select_nic function in FogExtensions::Vsphere::Server (app/models/concerns/fog_extensions/vsphere/server.rb) calls all_networks.detect first with the nic_attrs structure which looks like it matches against network._ref. IE:

vm_network = all_networks.detect { |network| network._ref == nic_attrs['network'] }

Only if that doesn’t match anything would the check below it which checks for network.key execute:

vm_network ||= all_networks.detect { |network| nic_attrs['network'] && [network.name, network.try(:key)].include?(nic_attrs['network']) }

In our environment, this makes a false positive match due to one object having a ref attribute that matches the desired object’s key. I’m pretty sure the check a few lines later that compares the vm_network.name and vm_network.key nil’s out selected_nic, ultimately returning nil to match_macs_to_nics in Orchestration::Compute which then fails with “Orchestration::Compute: Could not match network interface.”

In my environment, I was able to fix the issue by reversing the search by name & key and the search for nic_attrs as in the attached patch.

I think this should be a safe change in the other cases where #19623 applies, but I’m nowhere near familiar enough with the Foreman codebase to be certain of that.

foreman-vcenter67-network.patch Magnifier (959 Bytes) Zachary Bedell, 06/12/2018 03:33 PM

Associated revisions

Revision f5ea70ad
Added by Zachary Bedell about 1 month ago

fixes #23909 - vsphere: prefer network search by key

Creating a new VMware image fails during provisioning with
"Could not match network interface". Searching for distributed
virtual switch via key BEFORE searching with the nic_attrs structure
resolves a false positive match when vCenter contains VDS migrated
from prior install with ref attribute that matches a different
object's key.


#1 Updated by The Foreman Bot about 1 month ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5685 added

#2 Updated by Timo Goebel about 1 month ago

  • Legacy Backlogs Release (now unused) set to 353

#3 Updated by Zachary Bedell about 1 month ago

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

Also available in: Atom PDF