Bug 1461785

Summary: Openshift refresh crashes due to template.objects being nil
Product: Red Hat CloudForms Management Engine Reporter: Beni Paskin-Cherniavsky <cben>
Component: ProvidersAssignee: Bronagh Sorota <bsorota>
Status: CLOSED CURRENTRELEASE QA Contact: juwatts
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 5.8.0CC: cpelland, epacific, fsimonce, gblomqui, jfrey, jhardy, obarenbo, simaishi
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.9.0Flags: epacific: automate_bug+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: containers
Fixed In Version: 5.9.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1462801 (view as bug list) Environment:
Last Closed: 2018-03-06 14:49:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: Container Management Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1462801    

Description Beni Paskin-Cherniavsky 2017-06-15 10:38:01 UTC
Description of problem:
[from http://talk.manageiq.org/t/openshift-provider-refresh-failed-with-cloudforms-4-5/2452/3]
> We are currently encountering an issue concerning refresh on our Cloudforms installation (CFME 5.8.0.17) with Openshift provider. We always have the following error for Openshift refresh (from evm.log):

[----] E, [2017-06-14T13:27:06.898512 #2877:10f9140] ERROR -- : MIQ(MiqQueue#deliver) Message id: [1000047668562], Error: [undefined method `collect' for nil:NilClass]
[----] E, [2017-06-14T13:27:06.898878 #2877:10f9140] ERROR -- : [EmsRefresh::Refreshers::EmsRefresherMixin::PartialRefreshError]: undefined method `collect' for nil:NilClass  Method:[rescue in deliver]
[----] E, [2017-06-14T13:27:06.899031 #2877:10f9140] ERROR -- : /var/www/miq/vmdb/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:50:in `refresh'
[----] E, [2017-06-14T13:28:29.565786 #2877:10f9140] ERROR -- : MIQ(ManageIQ::Providers::Openshift::ContainerManager::Refresher#refresh) EMS: [Kermit], id: [1000000000001] Refresh failed
[----] E, [2017-06-14T13:28:29.566924 #2877:10f9140] ERROR -- : [NoMethodError]: undefined method `collect' for nil:NilClass  Method:[rescue in block in refresh]
[----] E, [2017-06-14T13:28:29.567100 #2877:10f9140] ERROR -- : /var/www/miq/vmdb/app/models/manageiq/providers/openshift/container_manager/refresh_parser.rb:150:in `parse_template'
[----] E, [2017-06-14T13:28:29.567165 #2877:10f9140] ERROR -- : MIQ(ManageIQ::Providers::Openshift::ContainerManager::Refresher#refresh) EMS: [Kermit], id: [1000000000001] Unable to perform refresh for the following targets:
[----] E, [2017-06-14T13:28:29.567297 #2877:10f9140] ERROR -- : MIQ(ManageIQ::Providers::Openshift::ContainerManager::Refresher#refresh)  --- ManageIQ::Providers::Openshift::ContainerManager [Kermit] id [1000000000001]

It's a blocking point for us because we are using Cloudforms with our Openshift provider in order to generate bills, and if refresh doesn't work, we don't see new Openshift projects created and their metrics consumptions are not collected.

> actually we had one of our customer who created a template without object (we can actually set "null" for object value), that was the one which prevent us refreshing Openshift provider. I had an object on it and it works again ! So thanks for the workaround.


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

Steps to Reproduce:
1. oc create template / oc edit template, setting `objects: null` instead of a list.
2. refresh openshift from cloudforms

Actual results:
Refresh fails, errors in evm.log

Expected results:
Refresh succeeds

Additional info:

Crash seems here:
https://github.com/ManageIQ/manageiq/blob/fine/app/models/manageiq/providers/openshift/container_manager/refresh_parser.rb#L150  (5.8)
https://github.com/ManageIQ/manageiq-providers-openshift/blob/master/app/models/manageiq/providers/openshift/container_manager/refresh_parser.rb#L154  (master)

The objects array in openshift doesn't have `omitempty`
https://github.com/openshift/origin/blob/master/pkg/template/api/v1/types.go#L31
so I suppose given zero objects we'll still see an empty array,
but an explicit `objects: null` in the template (and maybe omitting `objects:` altogether?) crashes us.

Comment 4 juwatts 2017-11-28 19:25:54 UTC
Verified Version:
5.9.0.11.20171127204214_e316988

Verification steps:
1)Added provider to CFME appliance
2)On the OCP provider: oc create -f test-template.yaml 
2)oc edit cloudforms
3)Removed objects list and changed to 'objects: null', saved the changes
4)On cfme appliance, ran a manual refresh
5) Verified in the evm.log, that the above error was not observed and the refresh ran to completion