Bug 1471297

Summary: Tag with Key 'Name' and a nil Value Breaks Refresh for AWS
Product: Red Hat CloudForms Management Engine Reporter: myoder
Component: ProvidersAssignee: Daniel Berger <dberger>
Status: CLOSED CURRENTRELEASE QA Contact: Matouš Mojžíš <mmojzis>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 5.7.0CC: agrare, gblomqui, jfrey, jhardy, mmojzis, obarenbo, rspagnol, simaishi
Target Milestone: GAKeywords: TestOnly
Target Release: 5.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: ec2:cloud:refresh
Fixed In Version: 5.10.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1471315 1478557 1514156 (view as bug list) Environment:
Last Closed: 2018-06-21 20:55:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: Bug
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: AWS Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1471315, 1478557, 1514156    

Description myoder 2017-07-14 23:03:03 UTC
Description of problem:
Tagging an image/instance with a tag that has a key = 'Name' and value = '' breaks the refresh for AWS provider.

[----] E, [2017-07-14T05:35:06.715936 #2770:8a712c] ERROR -- : MIQ(EmsRefresh.save_vms_inventory) EMS: [AWS TEST], id: [1000000000006] Processing Vm: [] failed with error [Validation failed: Name can't be blank]. Skipping Vm.
[----] E, [2017-07-14T05:35:06.716400 #2770:8a712c] ERROR -- : [ActiveRecord::RecordInvalid]: Validation failed: Name can't be blank  Method:[rescue in block (2 levels) in save_vms_inventory]
[----] E, [2017-07-14T05:35:06.716795 #2770:8a712c] ERROR -- : /opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/validations.rb:78:in `raise_validation_error'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/validations.rb:50:in `save!'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/transactions.rb:324:in `block in save!'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:230:in `transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/transactions.rb:211:in `transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/transactions.rb:392:in `with_transaction_returning_status'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/transactions.rb:324:in `save!'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/suppressor.rb:45:in `save!'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory.rb:187:in `save_hardware_inventory'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory_helper.rb:109:in `block in save_child_inventory'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory_helper.rb:109:in `each'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory_helper.rb:109:in `save_child_inventory'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory.rb:114:in `block (2 levels) in save_vms_inventory'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory.rb:58:in `each'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory.rb:58:in `block in save_vms_inventory'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/transactions.rb:211:in `transaction'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory.rb:57:in `save_vms_inventory'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory_helper.rb:109:in `block in save_child_inventory'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory_helper.rb:109:in `each'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory_helper.rb:109:in `save_child_inventory'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory_cloud.rb:69:in `save_ems_cloud_inventory'
/var/www/miq/vmdb/app/models/ems_refresh/save_inventory.rb:4:in `save_ems_inventory'
/opt/rh/cfme-gemset/bundler/gems/manageiq-providers-amazon-1b78b94636be/app/models/manageiq/providers/amazon/cloud_manager/refresher.rb:11:in `save_inventory'
/var/www/miq/vmdb/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:91:in `block in refresh_targets_for_ems'
/var/www/miq/vmdb/gems/pending/util/extensions/miq-benchmark.rb:11:in `realtime_store'
/var/www/miq/vmdb/gems/pending/util/extensions/miq-benchmark.rb:30:in `realtime_block'
/var/www/miq/vmdb/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:91:in `refresh_targets_for_ems'
/var/www/miq/vmdb/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:24:in `block (2 levels) in refresh'
/var/www/miq/vmdb/gems/pending/util/extensions/miq-benchmark.rb:11:in `realtime_store'
/var/www/miq/vmdb/gems/pending/util/extensions/miq-benchmark.rb:30:in `realtime_block'
/var/www/miq/vmdb/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:24:in `block in refresh'
/var/www/miq/vmdb/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:14:in `each'
/var/www/miq/vmdb/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:14:in `refresh'
/var/www/miq/vmdb/app/models/manageiq/providers/base_manager/refresher.rb:10:in `refresh'
/var/www/miq/vmdb/app/models/ems_refresh.rb:91:in `block in refresh'
/var/www/miq/vmdb/app/models/ems_refresh.rb:90:in `each'
/var/www/miq/vmdb/app/models/ems_refresh.rb:90:in `refresh'
/var/www/miq/vmdb/app/models/miq_queue.rb:347:in `block in deliver'
/opt/rh/rh-ruby23/root/usr/share/ruby/timeout.rb:91:in `block in timeout'
/opt/rh/rh-ruby23/root/usr/share/ruby/timeout.rb:33:in `block in catch'
/opt/rh/rh-ruby23/root/usr/share/ruby/timeout.rb:33:in `catch'
/opt/rh/rh-ruby23/root/usr/share/ruby/timeout.rb:33:in `catch'
/opt/rh/rh-ruby23/root/usr/share/ruby/timeout.rb:106:in `timeout'
/var/www/miq/vmdb/app/models/miq_queue.rb:343:in `deliver'
/var/www/miq/vmdb/app/models/miq_queue_worker_base/runner.rb:107:in `deliver_queue_message'
/var/www/miq/vmdb/app/models/miq_queue_worker_base/runner.rb:135:in `deliver_message'
/var/www/miq/vmdb/app/models/miq_queue_worker_base/runner.rb:153:in `block in do_work'
/var/www/miq/vmdb/app/models/miq_queue_worker_base/runner.rb:147:in `loop'
/var/www/miq/vmdb/app/models/miq_queue_worker_base/runner.rb:147:in `do_work'
/var/www/miq/vmdb/app/models/miq_worker/runner.rb:336:in `block in do_work_loop'
/var/www/miq/vmdb/app/models/miq_worker/runner.rb:333:in `loop'
/var/www/miq/vmdb/app/models/miq_worker/runner.rb:333:in `do_work_loop'
/var/www/miq/vmdb/app/models/miq_worker/runner.rb:155:in `run'
/var/www/miq/vmdb/app/models/miq_worker/runner.rb:130:in `start'
/var/www/miq/vmdb/app/models/miq_worker/runner.rb:21:in `start_worker'
/var/www/miq/vmdb/app/models/miq_worker.rb:343:in `block in start'
/opt/rh/cfme-gemset/gems/nakayoshi_fork-0.0.3/lib/nakayoshi_fork.rb:24:in `fork'
/opt/rh/cfme-gemset/gems/nakayoshi_fork-0.0.3/lib/nakayoshi_fork.rb:24:in `fork'
/var/www/miq/vmdb/app/models/miq_worker.rb:341:in `start'
/var/www/miq/vmdb/app/models/miq_worker.rb:270:in `start_worker'
/var/www/miq/vmdb/app/models/mixins/per_ems_worker_mixin.rb:68:in `start_worker_for_ems'
/var/www/miq/vmdb/app/models/mixins/per_ems_worker_mixin.rb:46:in `block in sync_workers'
/var/www/miq/vmdb/app/models/mixins/per_ems_worker_mixin.rb:45:in `each'
/var/www/miq/vmdb/app/models/mixins/per_ems_worker_mixin.rb:45:in `sync_workers'
/var/www/miq/vmdb/app/models/miq_server/worker_management/monitor.rb:53:in `block in sync_workers'
/var/www/miq/vmdb/app/models/miq_server/worker_management/monitor.rb:50:in `each'
/var/www/miq/vmdb/app/models/miq_server/worker_management/monitor.rb:50:in `sync_workers'
/var/www/miq/vmdb/app/models/miq_server/worker_management/monitor.rb:22:in `monitor_workers'
/var/www/miq/vmdb/app/models/miq_server.rb:346:in `block in monitor'
/var/www/miq/vmdb/gems/pending/util/extensions/miq-benchmark.rb:11:in `realtime_store'
/var/www/miq/vmdb/gems/pending/util/extensions/miq-benchmark.rb:30:in `realtime_block'
/var/www/miq/vmdb/app/models/miq_server.rb:346:in `monitor'
/var/www/miq/vmdb/app/models/miq_server.rb:368:in `block (2 levels) in monitor_loop'
/var/www/miq/vmdb/gems/pending/util/extensions/miq-benchmark.rb:11:in `realtime_store'
/var/www/miq/vmdb/gems/pending/util/extensions/miq-benchmark.rb:30:in `realtime_block'
/var/www/miq/vmdb/app/models/miq_server.rb:368:in `block in monitor_loop'
/var/www/miq/vmdb/app/models/miq_server.rb:367:in `loop'
/var/www/miq/vmdb/app/models/miq_server.rb:367:in `monitor_loop'
/var/www/miq/vmdb/app/models/miq_server.rb:250:in `start'
/var/www/miq/vmdb/lib/workers/evm_server.rb:65:in `start'
/var/www/miq/vmdb/lib/workers/evm_server.rb:92:in `start'
/var/www/miq/vmdb/lib/workers/bin/evm_server.rb:4:in `<main>'

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

How reproducible:
always

Steps to Reproduce:
1. create tag with key = 'Name' and value = ''
2. tag an image or instance from AWS provider
3. perform refresh

Actual results:
Refresh fails

Expected results:
Refresh succeeds

Additional info:

Comment 3 CFME Bot 2017-07-14 23:32:57 UTC
New commit detected on ManageIQ/manageiq-providers-amazon/master:
https://github.com/ManageIQ/manageiq-providers-amazon/commit/8bb113757dda2fd25accd2f3ca2f3e454a43be7c

commit 8bb113757dda2fd25accd2f3ca2f3e454a43be7c
Author:     Adam Grare <agrare>
AuthorDate: Fri Jul 14 18:49:49 2017 -0400
Commit:     Adam Grare <agrare>
CommitDate: Fri Jul 14 19:07:30 2017 -0400

    Handle empty string in image tags
    
    It is possible for the name coming from a tag to be an empty string,
    this was bypassing the ||= check but failing the validation on the
    VmOrTemplate model causing the refresh to fail.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1471297

 .../manageiq/providers/amazon/cloud_manager/refresh_parser.rb       | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comment 9 Matouš Mojžíš 2017-10-10 14:14:11 UTC
*** Bug 1496549 has been marked as a duplicate of this bug. ***

Comment 10 Matouš Mojžíš 2017-10-10 14:15:05 UTC
Still can reproduce on 5.9.0.1 with AMI with tag Name without value is refresh broken.

Comment 11 Adam Grare 2017-10-10 14:18:20 UTC
Matous can you provide the backtrace and evm.log?

Comment 14 Adam Grare 2017-10-10 14:56:57 UTC
Thanks Matous, looks like the same fix needs to be applied to the inventory/parser for when inventory_object_refresh is used.

Bronagh sending this over to your team.