Bug 1809580

Summary: VM / Cloud Tenant relationship is broken
Product: Red Hat CloudForms Management Engine Reporter: Fabien Dupont <fdupont>
Component: ProvidersAssignee: Adam Grare <agrare>
Status: CLOSED ERRATA QA Contact: Nandini Chandra <nachandr>
Severity: urgent Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: urgent    
Version: 5.11.0CC: dmetzger, jfrey, jhardy, nachandr, obarenbo, simaishi
Target Milestone: GAKeywords: ZStream
Target Release: 5.11.5Flags: pm-rhel: cfme-5.11.z+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.11.5.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-05 13:43:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1809027    

Description Fabien Dupont 2020-03-03 12:47:16 UTC
Description of problem:

When trying to follow the VM to CloudTenant relationship, CloudForms throws a PostgreSQL exception.

irb> my_tenant = CloudTenant.find_by(name: 'my_tenant')
irb> my_vms = Vm.where(:name => 'my_vm', :cloud_tenant => my_tenant)
Traceback (most recent call last):
       16: from activerecord (5.1.7) lib/active_record/connection_adapters/abstract/database_statements.rb:42:in `select_all'
       15: from activerecord (5.1.7) lib/active_record/connection_adapters/abstract/database_statements.rb:371:in `select'
       14: from activerecord (5.1.7) lib/active_record/connection_adapters/postgresql/database_statements.rb:79:in `exec_query'
       13: from activerecord (5.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `execute_and_clear'
       12: from activerecord (5.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:622:in `exec_no_cache'
       11: from activerecord (5.1.7) lib/active_record/connection_adapters/abstract_adapter.rb:604:in `log'
       10: from activesupport (5.1.7) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
        9: from activerecord (5.1.7) lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block in log'
        8: from /usr/share/ruby/monitor.rb:226:in `mon_synchronize'
        7: from activerecord (5.1.7) lib/active_record/connection_adapters/abstract_adapter.rb:613:in `block (2 levels) in log'
        6: from activerecord (5.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:623:in `block in exec_no_cache'
        5: from activesupport (5.1.7) lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads'
        4: from activesupport (5.1.7) lib/active_support/concurrency/share_lock.rb:185:in `yield_shares'
        3: from activesupport (5.1.7) lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_loads'
        2: from activerecord (5.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:624:in `block (2 levels) in exec_no_cache'
        1: from activerecord (5.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:624:in `exec_params'
ActiveRecord::StatementInvalid (PG::UndefinedColumn: ERROR:  column vms.cloud_tenant does not exist)
LINE 1: ...D "vms"."template" = $1 AND "vms"."name" = $2 AND "vms"."clo...
                                                             ^
HINT:  Perhaps you meant to reference the column "vms.cloud_tenant_id".
: SELECT  "vms".* FROM "vms" WHERE "vms"."type" IN ('Vm', 'ManageIQ::Providers::InfraManager::Vm', 'ManageIQ::Providers::CloudManager::Vm', 'VmServer', 'ManageIQ::Providers::Vmware::InfraManager::Vm', 'ManageIQ::Providers::Kubevirt::InfraManager::Vm', 'ManageIQ::Providers::Redhat::InfraManager::Vm', 'ManageIQ::Providers::Microsoft::InfraManager::Vm', 'VmXen', 'ManageIQ::Providers::Amazon::CloudManager::Vm', 'ManageIQ::Providers::Azure::CloudManager::Vm', 'ManageIQ::Providers::AzureStack::CloudManager::Vm', 'ManageIQ::Providers::Google::CloudManager::Vm', 'ManageIQ::Providers::Openstack::CloudManager::Vm', 'ManageIQ::Providers::Vmware::CloudManager::Vm') AND "vms"."template" = $1 AND "vms"."name" = $2 AND "vms"."cloud_tenant" = 9 LIMIT $3

Comment 2 Fabien Dupont 2020-03-03 12:52:42 UTC
https://github.com/ManageIQ/manageiq/pull/19914

Comment 3 CFME Bot 2020-03-20 17:30:23 UTC
New commit detected on ManageIQ/manageiq/ivanchuk:

https://github.com/ManageIQ/manageiq/commit/3a643ea218fa7c80ae8037b046f2eccb1a30a0a0
commit 3a643ea218fa7c80ae8037b046f2eccb1a30a0a0
Author:     Adam Grare <agrare>
AuthorDate: Tue Mar  3 14:20:51 2020 +0000
Commit:     Adam Grare <agrare>
CommitDate: Tue Mar  3 14:20:51 2020 +0000

    Merge pull request #19914 from fdupont-redhat/v2v_bz_1809580

    Add CloudTenant relationship in VM class

    (cherry picked from commit dc8d26883fa1f61130ed583c4bc51fccd4c0c47b)

    https://bugzilla.redhat.com/show_bug.cgi?id=1809580

 app/models/manageiq/providers/cloud_manager/vm.rb | 1 -
 app/models/vm_or_template.rb | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

Comment 4 CFME Bot 2020-03-20 19:30:25 UTC
New commit detected on ManageIQ/manageiq/jansa:

https://github.com/ManageIQ/manageiq/commit/4cf5ecd0f013b303a1f41ef4dc92db7a2736dd07
commit 4cf5ecd0f013b303a1f41ef4dc92db7a2736dd07
Author:     Adam Grare <agrare>
AuthorDate: Tue Mar  3 14:20:51 2020 +0000
Commit:     Adam Grare <agrare>
CommitDate: Tue Mar  3 14:20:51 2020 +0000

    Merge pull request #19914 from fdupont-redhat/v2v_bz_1809580

    Add CloudTenant relationship in VM class

    (cherry picked from commit dc8d26883fa1f61130ed583c4bc51fccd4c0c47b)

    https://bugzilla.redhat.com/show_bug.cgi?id=1809580

 app/models/manageiq/providers/cloud_manager/vm.rb | 1 -
 app/models/vm_or_template.rb | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

Comment 5 Nandini Chandra 2020-04-06 19:24:02 UTC
Verified in  master.20200403002716_63b3608c8d

Comment 6 Nandini Chandra 2020-04-17 13:28:28 UTC
Verified in 5.11.5

Comment 9 errata-xmlrpc 2020-05-05 13:43:32 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, 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/RHBA-2020:2020