Bug 1465826

Summary: Accessing the 'manager' association of a ManageIQ_Providers_EmbeddedAnsible_AutomationManager_Job service model gives a NoMethodError exception
Product: Red Hat CloudForms Management Engine Reporter: Peter McGowan <pmcgowan>
Component: AutomateAssignee: Lucy Fu <lufu>
Status: CLOSED CURRENTRELEASE QA Contact: Dmitry Misharov <dmisharo>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.8.0CC: jhardy, mkanoor, obarenbo, simaishi, tfitzger
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: ansible_embed:automate
Fixed In Version: 5.9.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1478515 (view as bug list) Environment:
Last Closed: 2018-03-06 15:26:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1478515    

Description Peter McGowan 2017-06-28 09:58:39 UTC
Description of problem:
A ManageIQ_Providers_EmbeddedAnsible_AutomationManager_Job service model appears to have 3 associations named 'manager', however accessing this association results in a NoMethodError exception, as follows:

irb(main):009:0> job = $evm.vmdb('ManageIQ_Providers_EmbeddedAnsible_AutomationManager_Job').first
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0

irb(main):010:0> job.associations
=> ["ext_management_system", "manager", "manager", "manager", "outputs", "parameters", "resources"]

irb(main):011:0> job.manager
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0
NoMethodError: undefined method `manager' for #<ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Job:0x0000000a386bc0>
	from /opt/rh/cfme-gemset/gems/activemodel-5.0.3/lib/active_model/attribute_methods.rb:433:in `method_missing'
	from /var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service_model_base.rb:266:in `public_send'
	from /var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service_model_base.rb:266:in `block in object_send'
	from /var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service_model_base.rb:285:in `ar_method'
	from /var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service_model_base.rb:295:in `ar_method'
	from /var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service_model_base.rb:264:in `object_send'
	from /var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service_model_base.rb:119:in `block (2 levels) in expose'
	from (irb):11
	from /opt/rh/cfme-gemset/gems/railties-5.0.3/lib/rails/commands/console.rb:65:in `start'
	from /opt/rh/cfme-gemset/gems/railties-5.0.3/lib/rails/commands/console_helper.rb:9:in `start'
	from /opt/rh/cfme-gemset/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:78:in `console'
	from /opt/rh/cfme-gemset/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
	from /opt/rh/cfme-gemset/gems/railties-5.0.3/lib/rails/commands.rb:18:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'

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

How reproducible:
Every time

Steps to Reproduce:
1. job = $evm.vmdb('ManageIQ_Providers_EmbeddedAnsible_AutomationManager_Job').first
2. job.associations
3. job.manager

Actual results:
NoMethodError exception

Expected results:
the association should be traversed

Additional info:
It looks like:

class MiqAeServiceManageIQ_Providers_EmbeddedAnsible_AutomationManager_Job < MiqAeServiceManageIQ_Providers_EmbeddedAutomationManager_OrchestrationStack
(exposes manager)

class MiqAeServiceManageIQ_Providers_EmbeddedAutomationManager_OrchestrationStack < MiqAeServiceManageIQ_Providers_AutomationManager_OrchestrationStack
(exposes manager)

class MiqAeServiceManageIQ_Providers_AutomationManager_OrchestrationStack < MiqAeServiceOrchestrationStack
(exposes manager)

class MiqAeServiceOrchestrationStack < MiqAeServiceModelBase
(manager is not exposed here)


This seems to be why we have 3 'manager' associations from the ManageIQ_Providers_EmbeddedAnsible_AutomationManager_Job object, but it needs to be exposed from MiqAeServiceOrchestrationStack

Comment 4 CFME Bot 2017-07-05 21:29:14 UTC
New commit detected on ManageIQ/manageiq-automation_engine/master:
https://github.com/ManageIQ/manageiq-automation_engine/commit/751893848d14403413d54d8c4d81fe84720d33dc

commit 751893848d14403413d54d8c4d81fe84720d33dc
Author:     Lucy Fu <lufu>
AuthorDate: Wed Jul 5 16:47:11 2017 -0400
Commit:     Lucy Fu <lufu>
CommitDate: Wed Jul 5 16:47:11 2017 -0400

    Remove the expose of manager to Embedded Ansible Job in service model.
    
    The :manager association to Embedded Ansible Job does not exist in the model side.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1465826

 ...vice_manageiq-providers-automation_manager-orchestration_stack.rb | 5 -----
 ...ice_manageiq-providers-embedded_ansible-automation_manager-job.rb | 5 -----
 ...geiq-providers-embedded_automation_manager-orchestration_stack.rb | 5 -----
 3 files changed, 15 deletions(-)
 delete mode 100644 lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-automation_manager-orchestration_stack.rb
 delete mode 100644 lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-embedded_ansible-automation_manager-job.rb
 delete mode 100644 lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-embedded_automation_manager-orchestration_stack.rb

Comment 6 Dmitry Misharov 2017-10-18 07:37:13 UTC
Verified in 5.9.0.2.20171010190026_0413a06.
irb(main):001:0> $evm=MiqAeMethodService::MiqAeService.new(MiqAeEngine::MiqAeWorkspaceRuntime.new)
...
irb(main):002:0> job = $evm.vmdb('ManageIQ_Providers_EmbeddedAnsible_AutomationManager_Job').first
...
irb(main):003:0> job.associations
=> ["ext_management_system", "outputs", "parameters", "resources"]
irb(main):004:0> job.ext_management_system

job.ext_management_system can be used to access its manager.