Bug 1594833

Summary: User defined custom attributes are deleted by RHV targeted refresh
Product: Red Hat CloudForms Management Engine Reporter: Satoe Imaishi <simaishi>
Component: ProvidersAssignee: Adam Grare <agrare>
Status: CLOSED ERRATA QA Contact: Ilanit Stein <istein>
Severity: high Docs Contact:
Priority: high    
Version: 5.9.0CC: cpelland, fdupont, gblomqui, istein, jfrey, jhardy, obarenbo
Target Milestone: GAKeywords: ZStream
Target Release: 5.9.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.9.3.4 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1594817 Environment:
Last Closed: 2018-07-12 13:17:05 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: RHEVM Target Upstream Version:
Embargoed:
Bug Depends On: 1594817    
Bug Blocks:    

Comment 3 CFME Bot 2018-06-26 12:00:40 UTC
New commit detected on ManageIQ/manageiq-providers-ovirt/gaprindashvili:

https://github.com/ManageIQ/manageiq-providers-ovirt/commit/c290daf3c427da39b41de0b12478069bb5090963
commit c290daf3c427da39b41de0b12478069bb5090963
Author:     Adam Grare <agrare>
AuthorDate: Mon Jun 25 09:59:25 2018 -0400
Commit:     Adam Grare <agrare>
CommitDate: Mon Jun 25 09:59:25 2018 -0400

    Use the same assoc for targeted and full refresh

    The full refresh persister was using the :vm_and_template_ems_custom_fields
    association but the targeted persister was using the :custom_attributes
    association.  This caused targeted refresh to clear all
    miq_custom_attributes which were added outside of refresh.

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

 app/models/manageiq/providers/redhat/inventory/persister/target_collection.rb | 2 -
 spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_custom_attributes_spec.rb | 17 +
 2 files changed, 17 insertions(+), 2 deletions(-)

Comment 6 Ilanit Stein 2018-07-03 07:05:35 UTC
Verified on CFME-5.9.3.4/RHV-4.2.3:


[root@... vmdb]# rails c                                                                                                                                                                                     
Loading production environment (Rails 5.0.6)                                                                                                                                                                       

                                                                                                                                                                              
irb(main):002:0> vm = Vm.where(name: "test-snpsh-ismm").last                                                                                                                                                       
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0                                                                                                     
=> #<ManageIQ::Providers::Redhat::InfraManager::Vm id: 133, vendor: "redhat", format: nil, version: nil, name: "test-snpsh-ismm", description: nil, location: "99cf57f8-a9b3-4f29-b9a9-9004b810966e.ovf", config_xml: nil, autostart: nil, host_id: 5, last_sync_on: nil, created_on: "2018-06-28 18:33:56", updated_on: "2018-07-01 11:17:51", storage_id: 12, guid: "a524fdbc-2894-40ae-98d2-163fcf93b50f", ems_id: 68, last_scan_on: nil, last_scan_attempt_on: nil, uid_ems: "99cf57f8-a9b3-4f29-b9a9-9004b810966e", retires_on: nil, retired: nil, boot_time: "2018-06-28 17:47:57", tools_status: nil, standby_action: nil, power_state: "on", state_changed_on: "2018-06-28 18:33:56", previous_state: nil, connection_state: "connected", last_perf_capture_on: nil, registered: nil, busy: nil, smart: nil, memory_reserve: 1024, memory_reserve_expand: nil, memory_limit: 8192, memory_shares: nil, memory_shares_level: nil, cpu_reserve: nil, cpu_reserve_expand: nil, cpu_limit: nil, cpu_shares: nil, cpu_shares_level: nil, cpu_affinity: nil, ems_created_on: nil, template: false, evm_owner_id: nil, ems_ref_obj: "--- \"/api/vms/99cf57f8-a9b3-4f29-b9a9-9004b810966e...", miq_group_id: 1, linked_clone: nil, fault_tolerance: nil, type: "ManageIQ::Providers::Redhat::InfraManager::Vm", ems_ref: "/api/vms/99cf57f8-a9b3-4f29-b9a9-9004b810966e", ems_cluster_id: 68, retirement_warn: nil, retirement_last_warn: nil, vnc_port: nil, flavor_id: nil, availability_zone_id: nil, cloud: false, retirement_state: nil, cloud_network_id: nil, cloud_subnet_id: nil, cloud_tenant_id: nil, raw_power_state: "up", publicly_available: nil, orchestration_stack_id: nil, retirement_requester: nil, tenant_id: 1, resource_group_id: nil, deprecated: nil, storage_profile_id: nil, cpu_hot_add_enabled: nil, cpu_hot_remove_enabled: nil, memory_hot_add_enabled: nil, memory_hot_add_limit: nil, memory_hot_add_increment: nil>   

                  
irb(main):003:0> vm.miq_custom_set('mykey', 'myval')                                                                                                                                                               
=> true                                                                                                                                                                                                            


irb(main):004:0> vm.miq_custom_get('mykey')                                                                                                                                                                        
=> "myval"                                                                                                                                                                                                         


irb(main):005:0> EmsRefresh.refresh(vm)                                                                                                                                                                            
Scoped order and limit are ignored, it's forced to be batch order and batch size.                                                                                                                                  
=> {ManageIQ::Providers::Redhat::InfraManager::Refresh::Strategies::Api4=>[#<ManageIQ::Providers::Redhat::InfraManager::Vm id: 133, vendor: "redhat", format: nil, version: nil, name: "test-snpsh-ismm", description: nil, location: "99cf57f8-a9b3-4f29-b9a9-9004b810966e.ovf", config_xml: nil, autostart: nil, host_id: 5, last_sync_on: nil, created_on: "2018-06-28 18:33:56", updated_on: "2018-07-01 11:17:51", storage_id: 12, guid: "a524fdbc-2894-40ae-98d2-163fcf93b50f", ems_id: 68, last_scan_on: nil, last_scan_attempt_on: nil, uid_ems: "99cf57f8-a9b3-4f29-b9a9-9004b810966e", retires_on: nil, retired: nil, boot_time: "2018-06-28 17:47:57", tools_status: nil, standby_action: nil, power_state: "on", state_changed_on: "2018-06-28 18:33:56", previous_state: nil, connection_state: "connected", last_perf_capture_on: nil, registered: nil, busy: nil, smart: nil, memory_reserve: 1024, memory_reserve_expand: nil, memory_limit: 8192, memory_shares: nil, memory_shares_level: nil, cpu_reserve: nil, cpu_reserve_expand: nil, cpu_limit: nil, cpu_shares: nil, cpu_shares_level: nil, cpu_affinity: nil, ems_created_on: nil, template: false, evm_owner_id: nil, ems_ref_obj: "--- \"/api/vms/99cf57f8-a9b3-4f29-b9a9-9004b810966e...", miq_group_id: 1, linked_clone: nil, fault_tolerance: nil, type: "ManageIQ::Providers::Redhat::InfraManager::Vm", ems_ref: "/api/vms/99cf57f8-a9b3-4f29-b9a9-9004b810966e", ems_cluster_id: 68, retirement_warn: nil, retirement_last_warn: nil, vnc_port: nil, flavor_id: nil, availability_zone_id: nil, cloud: false, retirement_state: nil, cloud_network_id: nil, cloud_subnet_id: nil, cloud_tenant_id: nil, raw_power_state: "up", publicly_available: nil, orchestration_stack_id: nil, retirement_requester: nil, tenant_id: 1, resource_group_id: nil, deprecated: nil, storage_profile_id: nil, cpu_hot_add_enabled: nil, cpu_hot_remove_enabled: nil, memory_hot_add_enabled: nil, memory_hot_add_limit: nil, memory_hot_add_increment: nil>]}


irb(main):006:0> vm.miq_custom_get('mykey')
=> "myval"

Comment 8 errata-xmlrpc 2018-07-12 13:17:05 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/RHSA-2018:2184