Bug 1282851 - VMware provider refresh fails with 'divided by 0'
VMware provider refresh fails with 'divided by 0'
Status: CLOSED ERRATA
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Providers (Show other bugs)
5.4.0
Unspecified Unspecified
high Severity high
: GA
: 5.5.0
Assigned To: Adam Grare
Nandini Chandra
: ZStream
Depends On:
Blocks: 1287731
  Show dependency treegraph
 
Reported: 2015-11-17 10:57 EST by ncatling
Modified: 2015-12-08 08:47 EST (History)
6 users (show)

See Also:
Fixed In Version: 5.5.0.13
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1287731 (view as bug list)
Environment:
Last Closed: 2015-12-08 08:47:59 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
evm log snippet (4.24 KB, text/plain)
2015-11-17 10:57 EST, ncatling
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:2551 normal SHIPPED_LIVE Moderate: CFME 5.5.0 bug fixes and enhancement update 2015-12-08 12:58:09 EST

  None (edit)
Description ncatling 2015-11-17 10:57:15 EST
Created attachment 1095545 [details]
evm log snippet

Description of problem:

VMware provider refresh fails with:
ERROR -- : [ZeroDivisionError]: divided by 0  Method:[rescue in block in refresh]


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

CFME 5.4.3
vCenter 5.1


How reproducible:


Steps to Reproduce:
1. Add provider
2. Refresh
3. Error produced

Actual results:

Refresh fails with above error.


Expected results:

Refresh completes successfully


Additional info:

[----] E, [2015-11-17T13:00:24.280242 #11104:76fea8] ERROR -- : [ZeroDivisionError]: divided by 0  Method:[rescue in block in refresh]
[----] E, [2015-11-17T13:00:24.280697 #11104:76fea8] ERROR -- : /var/www/miq/vmdb/app/models/ems_refresh/parsers/vc.rb:830:in `/'
/var/www/miq/vmdb/app/models/ems_refresh/parsers/vc.rb:830:in `calculate_cores_and_sockets'
Comment 2 ncatling 2015-11-20 03:30:15 EST
As the error suggests, the value of 'cores' is zero in this instance. This workaround was successful:

[root@localhost ~]# diff -u /var/www/miq/vmdb/app/models/ems_refresh/parsers/vc.rb*
--- /var/www/miq/vmdb/app/models/ems_refresh/parsers/vc.rb	2015-11-17 07:26:30.264593764 -0500
+++ /var/www/miq/vmdb/app/models/ems_refresh/parsers/vc.rb.back	2015-10-13 12:02:02.000000000 -0400
@@ -827,7 +827,6 @@
 
   def self.calculate_cores_and_sockets(total, cores)
     cores = (cores || 1).to_i
-    cores = 1 if cores == 0
     [cores, (total.to_i / cores)]
   end
   private_class_method :calculate_cores_and_sockets
Comment 4 CFME Bot 2015-12-02 14:44:16 EST
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/74b219d8578f98d9c5fba4c4faef1676d7b1676c

commit 74b219d8578f98d9c5fba4c4faef1676d7b1676c
Author:     Adam Grare <agrare@redhat.com>
AuthorDate: Wed Nov 25 11:11:02 2015 -0500
Commit:     Adam Grare <agrare@redhat.com>
CommitDate: Wed Nov 25 11:51:18 2015 -0500

    Handle VMware VMs reportedly having 0 CPU Sockets
    
    VMware has been seen to return inventory stating that a VM has
    0 CPU sockets causing a ZeroDivisionError exception in the
    vmware refresh_parser.
    
    There is an existing check for numCoresPerSocket being nil,
    so expand on that to check for 0 as well.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1282851

 .../vmware/infra_manager/refresh_parser.rb         |  5 ++++-
 .../vmware/infra_manager/refresher_spec.rb         | 25 ++++++++++++++++++++++
 .../miq_vim_inventory/virtualMachinesByMor.yml     | 16 ++++++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)
Comment 5 CFME Bot 2015-12-02 15:30:27 EST
New commit detected on cfme/5.5.z:
https://code.engineering.redhat.com/gerrit/gitweb?p=cfme.git;a=commitdiff;h=efe07d18ba5e92025cfb2b40e1af5079a34081a6

commit efe07d18ba5e92025cfb2b40e1af5079a34081a6
Author:     Adam Grare <agrare@redhat.com>
AuthorDate: Wed Nov 25 11:11:02 2015 -0500
Commit:     Adam Grare <agrare@redhat.com>
CommitDate: Mon Nov 30 11:50:59 2015 -0500

    Handle VMware VMs reportedly having 0 CPU Sockets
    
    VMware has been seen to return inventory stating that a VM has
    0 CPU sockets causing a ZeroDivisionError exception in the
    vmware refresh_parser.
    
    There is an existing check for numCoresPerSocket being nil,
    so expand on that to check for 0 as well.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1282851

 .../vmware/infra_manager/refresh_parser.rb         |  5 ++++-
 .../vmware/infra_manager/refresher_spec.rb         | 25 ++++++++++++++++++++++
 .../miq_vim_inventory/virtualMachinesByMor.yml     | 16 ++++++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)
Comment 6 Nandini Chandra 2015-12-03 17:42:06 EST
Root cause was having a VC >= 5.0 and VMs on hosts <= 4.1.  The numCoresPerSocket property was added in 5.0 [1] so the VC just set that value to 0 for any hosts older than 5.0.

[1] https://www.vmware.com/support/developer/converter-sdk/conv55_apireference/vim.vm.VirtualHardware.html
Comment 7 Nandini Chandra 2015-12-03 19:11:47 EST
Verified that the code is present in 5.5.0.13.Marking this as VERIFIED.
Comment 9 errata-xmlrpc 2015-12-08 08:47:59 EST
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, 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-2015:2551

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