Bug 1371007

Summary: folder_path will return Japanese if "Folder Name" left empty when provisioning VMs
Product: Red Hat CloudForms Management Engine Reporter: Chen <cchen>
Component: ProvisioningAssignee: Drew Bomhof <dbomhof>
Status: CLOSED NOTABUG QA Contact: Dave Johnson <dajohnso>
Severity: high Docs Contact:
Priority: unspecified    
Version: 5.6.0CC: cchen, dbomhof, jhardy, obarenbo
Target Milestone: GAKeywords: Reopened
Target Release: 5.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-19 16:16:34 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:
Attachments:
Description Flags
dest_folder method, find_folder method
none
evm.log none

Description Chen 2016-08-29 07:12:28 UTC
Description of problem:

folder_path will return Japanese if "Folder Name" left empty when provisioning VMs. This will cause the provisioning failed.

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

CFME 5.6.1
VMware vsphere with Japanese language setting

How reproducible:

100%

Steps to Reproduce:
1. Set the VMware vsphere's language to Japanese
2. Leave "Folder Name" empty when provisioning a VM


Actual results:

The provisioning will fail.

Expected results:

The provisioning should succeed

Additional info:

This issue didn't happen in CloudForms 3.1 according to the customer.

Currently the customer is using the following workaround.

vmdb/app/models/manageiq/providers/vmware/infra_manager/provision/cloning.rb

  def find_folder(folder_path, datacenter)
    EmsFolder.where(:name => File.basename(folder_path)).detect do |f|
      f.folder_path.sub(/^データセンター\//, 'Datacenters/') == folder_path && f.parent_datacenter == datacenter
    end
  end

Comment 2 Greg McCullough 2016-08-29 13:45:07 UTC

*** This bug has been marked as a duplicate of bug 1368137 ***

Comment 3 Drew Bomhof 2016-08-29 21:28:22 UTC
Hi Chen,

Not sure if this appliance is still available - If it is - is there anyway I can get the folder_path before the .sub method modifies it?

e.g. f.folder_path.sub(/^データセンター\//, 'Datacenters/') == folder_path

Or - I can take a look if the appliance itself is available to me and/or it is running in English.

Thanks!

~Drew

Comment 4 Chen 2016-08-30 01:56:23 UTC
Hi Drew,

That's my customer's environment and I'm not sure the customer could cooperate with us.

But I'll try to ask the value of folder_path. So you want the value of f.folder_path am I right ?

Best Regards,
Chen

Comment 5 Drew Bomhof 2016-08-30 02:02:50 UTC
Hi Chen,

Yes - f.folder_path would be perfect.

Thanks!

~Drew

Comment 6 Chen 2016-08-31 03:45:35 UTC
Hi Drew,

Here is the reply from the customer:

データセンター/DataCenter01/vm

Best Regards,
Chen

Comment 10 Chen 2016-09-12 01:52:26 UTC
Hi Drew,

Sorry for reopening the bug. 

The project will be online shortly so they can not wait for 5.6.2's release. Could you please help me to create a hotfix ?

Best Regards,
Chen

Comment 12 Chen 2016-09-18 09:12:37 UTC
Hi Drew,

The customer reported that after applying the cloning.rb, they can not do the following any more.

Provision VM
Clone this VM
Publish this VM to a Template

The error message is the same for the above operations:

[----] E, [2016-09-14T14:53:03.448821 #2896:955998] ERROR -- : Q-task_id([miq_provision_136]) MIQ(ManageIQ::Providers::Vmware::InfraManager::Provision#provision_error) [[NoMethodError]: undefined method `ems_ref' for #<HostStorage:0x0000000d0fcd70>] encountered during phase [start_clone_task]
[----] E, [2016-09-14T14:53:03.448958 #2896:955998] ERROR -- : Q-task_id([miq_provision_136]) /opt/rh/cfme-gemset/gems/activemodel-5.0.0/lib/active_model/attribute_methods.rb:433:in `method_missing'

I uploaded the logs to the collaboration-shell.

collab-shell.usersys.redhat.com:/cases/01690311/01690311-20160915.zip/01690311-20160915

I can see in https://bugzilla.redhat.com/show_bug.cgi?id=1368137 we are modifying another file ?

In addition, as the customer's project has to be online next week, do you think the workaround which the customer provides is good enough ? 

Best Regards,
Chen

Comment 13 Drew Bomhof 2016-09-19 18:51:07 UTC
Created attachment 1202614 [details]
dest_folder method, find_folder method

Take the 2 (dest_folder, find_folder) methods in this attachment and replace each of the corresponding methods in

app/models/manageiq/providers/vmware/infra_manager/provision/cloning.rb

Replacing only those methods in the existing cloning.rb will solve the problem currently handled by the regex for the Japanese characters.

Comment 15 Chen 2016-09-20 02:00:05 UTC
Hi Drew,

I can see the those two methods are the same as version 5.6.1.2. Does it mean if update to 5.6.1.2 the problem will be gone ?

What I am using: 5.6.1.2-20160810181333_8ba817b

And looking back to the first cloning.rb (attachment #1200269 [details]), it seems that only two places were modified compared to 5.6.1.2. Maybe the customer was not using the newest 5.6.1.2. I'm afraid the following changes are the ones you wanted the customer to make ?

# diff cloning.rb cloning.rb.bak 
68c68
<     vm_folder = "#{host_dc.folder_path}/vm"
---
>     vm_folder = "Datacenters/#{host_dc.name}/vm"
73c73
<     EmsFolder.where(:name => File.basename(folder_path), :ems_id => source.ems_id).detect do |f|
---
>     EmsFolder.where(:name => File.basename(folder_path)).detect do |f|

Best Regards,
Chen

Comment 16 Chen 2016-09-24 08:59:01 UTC
Hi Drew,

I found that I misunderstood the patch. 

I've already provided new patch to the customer and waiting for their feedback.

Best Regards,
Chen

Comment 17 Chen 2016-09-27 01:33:20 UTC
Hi Drew,

The customer said the new hotfix is not working in their environment and the provisioning is failing.

>[----] E, [2016-09-26T12:27:48.875503 #2870:1021998] ERROR -- : Q-task_id([miq_provision_151]) MIQ(ManageIQ::Providers::Vmware::InfraManager::Provision#provision_error) [[NoMethodError]: undefined method `name' for nil:NilClass] encountered during phase [start_clone_task]
>[----] E, [2016-09-26T12:27:48.875637 #2870:1021998] ERROR -- : Q-task_id([miq_provision_151]) /var/www/miq/vmdb/app/models/manageiq/providers/vmware/infra_manager/provision/cloning.rb:84:in `log_clone_options'

But in my test environment there is no such a problem.

Best Regards,
Chen

Comment 18 Chen 2016-09-27 01:34:33 UTC
Created attachment 1205011 [details]
evm.log

Comment 22 Drew Bomhof 2016-10-04 13:38:30 UTC
Clearing NEEDINFO comment for me.

~Drew