Bug 2000534 - Compute Resource cannot list the VMs if any VMs in the datacenter has config.instanceUuid set to '' in Satellite 6.7 and above
Summary: Compute Resource cannot list the VMs if any VMs in the datacenter has config....
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Compute Resources - VMWare
Version: 6.7.0
Hardware: All
OS: Linux
unspecified
high
Target Milestone: 6.10.0
Assignee: Tomer Brisker
QA Contact: Lukáš Hellebrandt
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-09-02 10:59 UTC by Sayan Das
Modified: 2023-10-06 21:36 UTC (History)
6 users (show)

Fixed In Version: foreman-2.5.2.8-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 14:13:42 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 33396 0 None None None 2021-09-02 11:04:26 UTC
Red Hat Product Errata RHSA-2021:4702 0 None None None 2021-11-16 14:13:49 UTC

Description Sayan Das 2021-09-02 10:59:56 UTC
Description of problem:

When trying see the VMs from Virtual Machines tab of a Vmware Compute Resource, It shows "500 Internal Server" error.


Version-Release number of selected component (if applicable):

Satellite 6.7 and above

How reproducible:

Under specific circumstances i.e when the value of instanceUuid of any VM in the concerned datacenter is set to '' 


Steps to Reproduce:
1. Have a VM created in vCenter in a way that it's config.uuid and config.instanceUuid looks like below.

               name = '/vmfs/volumes/60d169e5-cbe0d537-c0b3-94f128c38630/sandbox02/sandbox02.vmx',
               guestFullName = 'Other (32-bit)',
               version = 'vmx-13',
               uuid = '',
               instanceUuid = '',

2. Create a VMware Compute Resource in Satellite for that Datacenter where above VM resides.


3. Go to UI --> Infrastructure --> Compute Resources --> Click open the compute resource and go to the Virtual Machines tab



Actual results:


At Step 3: We can see 500 Internal Server error.

Rails debug shows following traceback in production.log

2021-08-10T16:33:16 [W|app|ea1023d4] Action failed
2021-08-10T16:33:16 [D|app|ea1023d4] Backtrace for 'Action failed' error (ActionView::Template::Error): No route matches {:action=>"show", :compute_resource_id=>#<Foreman::Model::Vmware id: 3, name: "sma7301", description: "", url: "myvcenter.example.com", user: "example\\svc-mis-satellite-ah", password: "encrypted-c0p0Wlc1cGV4MU1EdEJCWFhDdkcrcVpsRnRiTUxX...", uuid: "FR-MAR", type: "Foreman::Model::Vmware", created_at: "2019-01-14 10:56:15", updated_at: "2021-08-10 12:57:45", attrs: {:setpw=>1, :pubkey_hash=>"50addbd601d3dd8dff7e47608f4a84dbf0f2927bbc094bb27119e536fcf2f637", :display=>"vmrc"}, email: nil, caching_enabled: false, domain: nil, http_proxy_id: nil>, :controller=>"compute_resources_vms", :id=>""}, 
possible unmatched constraints: [:id]
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/journey/formatter.rb:57:in `generate'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:744:in `generate'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:775:in `generate'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:822:in `url_for'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/url_for.rb:179:in `full_url_for'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/url_for.rb:169:in `url_for'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/routing_url_for.rb:91:in `url_for'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/turbolinks-2.5.4/lib/turbolinks/xhr_url_for.rb:19:in `url_for'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/helpers/url_helper.rb:202:in `link_to'
/usr/share/foreman/app/helpers/application_helper.rb:101:in `link_to_if_authorized'
/usr/share/foreman/app/views/compute_resources_vms/index/_vmware.html.erb:15:in `block in _65d7c00e9bb905a55a6f934bc60b7e1d'
/usr/share/foreman/app/views/compute_resources_vms/index/_vmware.html.erb:13:in `each'
/usr/share/foreman/app/views/compute_resources_vms/index/_vmware.html.erb:13:in `_65d7c00e9bb905a55a6f934bc60b7e1d'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/template.rb:159:in `block in render'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/notifications.rb:170:in `instrument'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/template.rb:354:in `instrument_render_template'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/template.rb:157:in `render'
/opt/theforeman/tfm/root/usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'


Expected results:

The satellite should be able to bypass the problematic VMs and then provide us with the list of good VMs utilizing the compute resource connectivity.


Additional info:


Following is the code we have.
 
# grep 'vms =' /usr/share/foreman/app/services/fog_extensions/vsphere/mini_servers.rb
        vms = results.select { |result| result.obj.is_a?(RbVmomi::VIM::VirtualMachine) && result['config.template'] == templates && !result['config.instanceUuid'].nil? }
 

Based on discussion with the RH Engineering team, we needed to change it to look like below followed by a restart of satellite services and that fixed the issue.
 
# grep 'vms =' /usr/share/foreman/app/services/fog_extensions/vsphere/mini_servers.rb
        vms = results.select { |result| result.obj.is_a?(RbVmomi::VIM::VirtualMachine) && result['config.template'] == templates && result['config.instanceUuid'].present? }

Comment 2 Tomer Brisker 2021-09-02 11:04:25 UTC
Created redmine issue https://projects.theforeman.org/issues/33396 from this bug

Comment 4 Bryan Kearney 2021-09-02 12:05:45 UTC
Upstream bug assigned to tbrisker

Comment 5 Bryan Kearney 2021-09-02 12:05:47 UTC
Upstream bug assigned to tbrisker

Comment 6 Bryan Kearney 2021-09-03 00:06:07 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/33396 has been resolved.

Comment 8 Lukáš Hellebrandt 2021-10-12 15:03:32 UTC
I was unable to obtain a reproducer. After consulting with people involved, it seems like we don't know how to create a VM without a UUID. Our VMWare instances fill random UUID even after attempts to hack empty uuid directly into the configuration text files. We also don't have any instance with reproducer already prepared.

Therefore, verified sanity-only with sat 6.10.0 snap 21.0.
VMWare CR can be added, seems to work, compute profile for that CR can be created, host can be created on that CR, VMs can be listed (including those we attempted do remove the uuid from, as opposed to hypothetical VMs that actually don't have any uuid - those should not be listed).
Code inspection shows that the fix is indeed present in app/services/fog_extensions/vsphere/mini_servers.rb on line 22.

Comment 11 errata-xmlrpc 2021-11-16 14:13:42 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Satellite 6.10 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:4702


Note You need to log in before you can comment on or make changes to this bug.