Bug 1368239 - Azure provider fails EMS refresh
Summary: Azure provider fails EMS refresh
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Providers
Version: 5.6.0
Hardware: x86_64
OS: Linux
high
high
Target Milestone: GA
: 5.7.0
Assignee: Bill Wei
QA Contact: Jeff Teehan
URL:
Whiteboard: provider:azure:refresh
Depends On:
Blocks: 1370216
TreeView+ depends on / blocked
 
Reported: 2016-08-18 19:02 UTC by Colin Arnott
Modified: 2019-12-16 06:24 UTC (History)
10 users (show)

Fixed In Version: 5.7.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1370216 (view as bug list)
Environment:
Last Closed: 2017-01-11 20:03:49 UTC
Category: ---
Cloudforms Team: Azure
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Colin Arnott 2016-08-18 19:02:03 UTC
Description of problem:
I can successfully create an Azure provider is successfully created, however during an EMS Refresh the refresh process encounters an error. Below is the error and beginning of the stack trace.


[----] E, [2016-08-17T15:19:26.230101 #60252:c7d990] ERROR -- : MIQ(ManageIQ::Providers::Azure::CloudManager::Refresher#refresh) EMS: [Azure], id: [1000000000011] Refresh failed
[----] E, [2016-08-17T15:19:26.267193 #60252:c7d990] ERROR -- : [NameError]: undefined local variable or method `resource' for #<ManageIQ::Providers::Azure::CloudManager::RefreshParser:0x00000005125a20>  Method:[rescue in block in refresh]
[----] E, [2016-08-17T15:19:26.267261 #60252:c7d990] ERROR -- : /var/www/miq/vmdb/app/models/manageiq/providers/azure/cloud_manager/refresh_parser.rb:131:in `transfer_selected_resource_properties'
/var/www/miq/vmdb/app/models/manageiq/providers/azure/cloud_manager/refresh_parser.rb:121:in `block in resource_already_collected?'
/var/www/miq/vmdb/app/models/manageiq/providers/azure/cloud_manager/refresh_parser.rb:116:in `each'
/var/www/miq/vmdb/app/models/manageiq/providers/azure/cloud_manager/refresh_parser.rb:116:in `each_with_index'
/var/www/miq/vmdb/app/models/manageiq/providers/azure/cloud_manager/refresh_parser.rb:116:in `resource_already_collected?'
<< CLIPPED >>


The code block being executed is:

      def transfer_selected_resource_properties(old_resource, new_resource)
        if new_resource.properties.provisioning_state != 'Succeeded'
          old_resource.properties.provisioning_state = resource.properties.provisioning_state
        end
        if new_resource.properties.try(:status_message)
          if old_resource.properties.try(:status_message)
            old_resource.properties.status_message += "\n#{new_resource.properties.status_message}"
          else
            old_resource.properties['status_message'] = new_resource.properties.status_message
          end
        end
      end


There is a resource that has a provisioning state that is not Successful and therefore CloudForms attempts to set properties of the old_resource variable from the variable named resource, but there is no variable named "resource" in the current scope.

Based on how the function is being called from the resource_already_collected? function (line 123) I believe the variable named resource should really be named new_resource.

Modified code block:

      def transfer_selected_resource_properties(old_resource, new_resource)
        if new_resource.properties.provisioning_state != 'Succeeded'
          old_resource.properties.provisioning_state = new_resource.properties.provisioning_state
        end
        if new_resource.properties.try(:status_message)
          if old_resource.properties.try(:status_message)
            old_resource.properties.status_message += "\n#{new_resource.properties.status_message}"
          else
            old_resource.properties['status_message'] = new_resource.properties.status_message
          end
        end
      end

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

How reproducible:
requires this Azure account

Comment 8 CFME Bot 2016-08-24 22:36:26 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/6b9d0716c90129a66757b4d9de4768d7a5ea50c1

commit 6b9d0716c90129a66757b4d9de4768d7a5ea50c1
Author:     Bill Wei <bilwei>
AuthorDate: Thu Aug 18 15:47:29 2016 -0400
Commit:     Bill Wei <bilwei>
CommitDate: Fri Aug 19 14:30:30 2016 -0400

    Fix a typo: resource -> new_resource
    Fix how to acculate resource status messages.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1368239

 .../azure/cloud_manager/refresh_parser.rb          | 31 +++++++++++++++-------
 1 file changed, 22 insertions(+), 9 deletions(-)

Comment 9 Jeff Teehan 2016-10-04 16:16:36 UTC
Test case is assumed for refresh errors.

Comment 10 Jeff Teehan 2016-10-11 19:30:03 UTC
Verified via code review.  It really isn't possible to create a bad resource on purpose in Azure.  So far I haven't seen any new refresh errors.


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