Bug 1388044

Summary: Dynamic update of parameters in service catalogs
Product: Red Hat CloudForms Management Engine Reporter: Sachin <sacpatil>
Component: AutomateAssignee: eclarizi
Status: CLOSED NOTABUG QA Contact: Shveta <sshveta>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 5.6.0CC: cpelland, eclarizi, gmccullo, hkataria, jhardy, mkanoor, mpovolny, obarenbo, sacpatil, smallamp, sshveta, tfitzger
Target Milestone: GAKeywords: Reopened
Target Release: cfme-future   
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: 2018-08-10 10:33:42 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:

Description Sachin 2016-10-24 10:00:25 UTC
Created attachment 1213423 [details]
datastore

This BZ is continuation of BZ#1346952
	
- The script error still exist in 5.6.2.1[1]
- Dynamic dropdown show script error.

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

How reproducible:

Always

Steps to Reproduce:

Go to 

- Service -> Catalog -> Sachin -> Sachin
- Order service catalog

Actual results:

- Script error

Expected results:

- Should get dynamic value instead of script error


Additional info:

[1] Reproducer: https://10.74.130.178

Comment 3 Greg McCullough 2016-10-25 00:40:12 UTC
Sachin - Only a few dynamic fields are showing a script error and this is because the scripts actually have logic errors.

In this case the "VPC Type", "Key Name" and "Security Group IDs" fields all call the same method "/RWE-common/Methods/AWS/get_aws_credentials" which is failing with the following error which is visible in the automation.log:

[----] I, [2016-10-24T20:26:48.480389 #12901:1186b58]  INFO -- : <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Starting 
[----] W, [2016-10-24T20:26:48.839168 #12901:5bc60ec]  WARN -- : DEPRECATION WARNING: ems_amazon is deprecated and will be removed from ManageIQ E-release (ManageIQ_Providers_Amazon_CloudManager) (called from block in service_model_lookup at /var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_service/miq_ae_service_model_legacy.rb:92)
[----] E, [2016-10-24T20:26:48.842926 #12901:5bc60ec] ERROR -- : <AEMethod get_aws_credentials> The following error occurred during method evaluation:
[----] E, [2016-10-24T20:26:48.843422 #12901:5bc60ec] ERROR -- : <AEMethod get_aws_credentials>   NoMethodError: undefined method `provider_region' for nil:NilClass
[----] E, [2016-10-24T20:26:48.844199 #12901:5bc60ec] ERROR -- : <AEMethod get_aws_credentials>   
[----] E, [2016-10-24T20:26:48.845574 #12901:5bc7280] ERROR -- : Method STDERR: <code: $evm.object['aws_region']     = management.provider_region>:7:in `<main>': undefined method `provider_region' for nil:NilClass (NoMethodError)
[----] I, [2016-10-24T20:26:48.871779 #12901:1186b58]  INFO -- : <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Ending


The method is always expecting to be passed an "aws_region" or access the first Amazon provider.  Since there is no Amazon provider defined in the system the "management" variable will always be nil leading to the above error.

This is not a product error but a custom script error.

Comment 4 Sachin 2016-10-25 10:18:54 UTC
Greg,

Thanx for your quick reply. Even if I added AWS provider and correct region I get those script errors in the dialog. I don't see ERROR w.r.t get_aws_credentials after adding the appropriate provider.

automation.log
~~~
[----] I, [2016-10-25T06:04:34.418781 #12901:1186b58]  INFO -- : Updated namespace [Methods/AWS/get_aws_credentials  RWE-common/Methods]
[----] I, [2016-10-25T06:04:34.423615 #12901:1186b58]  INFO -- : Invoking [inline] method [/RWE-common/Methods/AWS/get_aws_credentials] with inputs [{}]
[----] I, [2016-10-25T06:04:34.424291 #12901:1186b58]  INFO -- : <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Starting 
[----] I, [2016-10-25T06:04:34.829561 #12901:1186b58]  INFO -- : <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Ending
[----] I, [2016-10-25T06:04:35.308000 #12901:1186b58]  INFO -- : Updated namespace [Methods/AWS/get_aws_credentials  RWE-common/Methods]
[----] I, [2016-10-25T06:04:35.314156 #12901:1186b58]  INFO -- : Invoking [inline] method [/RWE-common/Methods/AWS/get_aws_credentials] with inputs [{}]
[----] I, [2016-10-25T06:04:35.315230 #12901:1186b58]  INFO -- : <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Starting 
[----] I, [2016-10-25T06:04:35.732714 #12901:1186b58]  INFO -- : <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Ending
[----] I, [2016-10-25T06:04:36.310912 #12901:1186b58]  INFO -- : Updated namespace [Methods/AWS/get_aws_credentials  RWE-common/Methods]
[----] I, [2016-10-25T06:04:36.315723 #12901:1186b58]  INFO -- : Invoking [inline] method [/RWE-common/Methods/AWS/get_aws_credentials] with inputs [{}]
[----] I, [2016-10-25T06:04:36.316449 #12901:1186b58]  INFO -- : <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Starting 
[----] I, [2016-10-25T06:04:36.736119 #12901:1186b58]  INFO -- : <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Ending
~~~

evm.log
~~~
[----] I, [2016-10-25T05:58:39.046305 #12901:1186b58]  INFO -- : <AutomationEngine> <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Ending
[----] I, [2016-10-25T05:58:39.518606 #12901:1186b58]  INFO -- : <AutomationEngine> Updated namespace [Methods/AWS/get_aws_credentials  RWE-common/Methods]
[----] I, [2016-10-25T05:58:39.523798 #12901:1186b58]  INFO -- : <AutomationEngine> Invoking [inline] method [/RWE-common/Methods/AWS/get_aws_credentials] with inputs [{}]
[----] I, [2016-10-25T05:58:39.524647 #12901:1186b58]  INFO -- : <AutomationEngine> <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Starting 
[----] I, [2016-10-25T05:58:40.022171 #12901:1186b58]  INFO -- : <AutomationEngine> <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Ending
[----] I, [2016-10-25T06:04:34.418692 #12901:1186b58]  INFO -- : <AutomationEngine> Updated namespace [Methods/AWS/get_aws_credentials  RWE-common/Methods]
[----] I, [2016-10-25T06:04:34.423548 #12901:1186b58]  INFO -- : <AutomationEngine> Invoking [inline] method [/RWE-common/Methods/AWS/get_aws_credentials] with inputs [{}]
[----] I, [2016-10-25T06:04:34.424235 #12901:1186b58]  INFO -- : <AutomationEngine> <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Starting 
[----] I, [2016-10-25T06:04:34.829443 #12901:1186b58]  INFO -- : <AutomationEngine> <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Ending
[----] I, [2016-10-25T06:04:35.307879 #12901:1186b58]  INFO -- : <AutomationEngine> Updated namespace [Methods/AWS/get_aws_credentials  RWE-common/Methods]
[----] I, [2016-10-25T06:04:35.314062 #12901:1186b58]  INFO -- : <AutomationEngine> Invoking [inline] method [/RWE-common/Methods/AWS/get_aws_credentials] with inputs [{}]
[----] I, [2016-10-25T06:04:35.315131 #12901:1186b58]  INFO -- : <AutomationEngine> <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Starting 
[----] I, [2016-10-25T06:04:35.732615 #12901:1186b58]  INFO -- : <AutomationEngine> <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Ending
[----] I, [2016-10-25T06:04:36.310824 #12901:1186b58]  INFO -- : <AutomationEngine> Updated namespace [Methods/AWS/get_aws_credentials  RWE-common/Methods]
[----] I, [2016-10-25T06:04:36.315652 #12901:1186b58]  INFO -- : <AutomationEngine> Invoking [inline] method [/RWE-common/Methods/AWS/get_aws_credentials] with inputs [{}]
[----] I, [2016-10-25T06:04:36.316396 #12901:1186b58]  INFO -- : <AutomationEngine> <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Starting 
[----] I, [2016-10-25T06:04:36.736038 #12901:1186b58]  INFO -- : <AutomationEngine> <AEMethod [/RWE-common/Methods/AWS/get_aws_credentials]> Ending
~~~

I see few dialog_load_security_group error in evm. I'm not sure if they are related.
~~~
=>"DO_NOTHING", "dialog_stack_timeout"=>nil, "dialog_param_AWSRegionType"=>"eu-west-1", "dialog_param_VpcType"=>nil, "dialog_param_KeyName"=>nil, "dialog_param_SecurityGroupIds"=>nil, "dialog_param_InstanceType"=>nil, "dialog_param_SubnetType"=>nil, "dialog_param_AWSAZType1"=>nil, "dialog_param_AWSAZType2"=>nil, "dialog_param_MyHostAPSName1"=>nil, "dialog_param_MyHostAPSName2"=>nil, "dialog_param_HAType"=>nil, "dialog_param_OSType"=>nil, "dialog_param_Aoper"=>nil, "dialog_param_Bservice"=>nil, "dialog_param_Ccentre"=>nil, "dialog_param_Ioper"=>nil, "dialog_param_Itservice"=>nil, "dialog_param_Os"=>nil, "dialog_param_Env"=>nil, "ServiceTemplate::service_template"=>123000000000003, "User::user"=>123000000000001} for object [ServiceTemplate.123000000000003] with state [] to Automate: Method exited with rc=Unknown RC: [1]
[----] E, [2016-10-25T06:04:37.126442 #12901:617865c] ERROR -- : <AutomationEngine> <AEMethod dialog_load_security_groups> The following error occurred during method evaluation:
[----] E, [2016-10-25T06:04:37.126924 #12901:617865c] ERROR -- : <AutomationEngine> <AEMethod dialog_load_security_groups>   LoadError: cannot load such file -- /usr/local/lib/api_lib
[----] E, [2016-10-25T06:04:37.127696 #12901:617865c] ERROR -- : <AutomationEngine> <AEMethod dialog_load_security_groups>   /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
~~~

Am I doing still doing anything wrong?

Comment 5 Greg McCullough 2016-10-25 12:35:06 UTC
That method is doing a explicit require of "/usr/local/lib/api_lib".

Code snippet:
  require '/usr/local/lib/api_lib'
  aws = APILib::AWS.new(
    region,
    $evm.object['aws_access_key'],
    $evm.object['aws_secret_key']
  )


I am unaware of the library this is referencing, you will want to contact the original author and determine what external dependencies this script requires.

Comment 7 Greg McCullough 2016-11-07 14:45:03 UTC
Assigning to Erik to investigate.

Comment 8 Sachin 2016-11-08 07:23:49 UTC
Hello Erik,

Let me know if you need any help to understand the problem.

Comment 10 Sachin 2016-11-11 13:03:56 UTC
Please use newly created servivce dialog: CFME_RHEL_STD_bug as a reproducer.

Comment 11 eclarizi 2016-11-11 15:43:42 UTC
I can't seem to reproduce? When I change the VPC type, the AWS AvailZone type 1 in the UI has the correct A/B/C values. What exactly is the issue you're seeing with regards to VPC/AvailZone interaction?

Comment 14 Sachin 2016-11-14 05:50:37 UTC
Greg,

We have two scenarios here: HA Type=not & HA Type=yes

Expected values for HA Type = not
--------------------------------

'vpc-1a91497f' then 'A'
'vpc-ce0dabab' then 'A'
'vpc-869630e3' then 'A'
'vpc-b99630dc' then 'B'
'vpc-4508ae20' then 'B'
'vpc-295efc4d' then 'A'

from evm.log, I see this values are correct. "Sometimes" the values are correctly refreshed in dialog

evm.log(you can safely discard AZ2 values for HA=not)
~~~
[----] I, [2016-11-07T17:09:39.358245 #10232:cfc5e34]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-869630e3, HA: not, AZ1: A, AZ2: C
[----] I, [2016-11-07T17:09:48.868706 #10232:7102988]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-4508ae20, HA: not, AZ1: B, AZ2: C
[----] I, [2016-11-07T17:09:54.387690 #10232:5da2424]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-ce0dabab, HA: not, AZ1: A, AZ2: B
[----] I, [2016-11-07T17:09:59.863909 #10232:76bcc84]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-295efc4d, HA: not, AZ1: A, AZ2: C
[----] I, [2016-11-07T17:10:15.452443 #10232:8815148]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-1a91497f, HA: not, AZ1: A, AZ2: B
[----] I, [2016-11-07T17:10:22.773973 #10232:5cd2f94]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-b99630dc, HA: not, AZ1: B, AZ2: C
~~~ 



for HA Type = yes
------------------

'vpc-1a91497f' then 'A' & 'B';
'vpc-ce0dabab' then 'A' & 'B';
'vpc-869630e3' then 'A' & 'C';
'vpc-b99630dc' then 'B' & 'C';
'vpc-4508ae20' then 'B' & 'C';
'vpc-295efc4d' then 'A' & 'C';

evm.log shows values as expected, but the values are not correctly display in the dialog UI upon selecting VPC type
~~~
[----] I, [2016-11-07T17:10:39.653770 #10232:5cdf3ac]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-b99630dc, HA: yes, AZ1: B, AZ2: C
[----] I, [2016-11-07T17:10:52.392787 #10232:62d2bc4]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-1a91497f, HA: yes, AZ1: A, AZ2: B
[----] I, [2016-11-07T17:10:58.599538 #10232:1ccaed8]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-295efc4d, HA: yes, AZ1: A, AZ2: C
[----] I, [2016-11-07T17:11:07.552965 #10232:638cdbc]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-ce0dabab, HA: yes, AZ1: A, AZ2: B
[----] I, [2016-11-07T17:11:18.969327 #10232:60831fc]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-4508ae20, HA: yes, AZ1: B, AZ2: C
[----] I, [2016-11-07T17:11:33.082213 #10232:114e564]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-869630e3, HA: yes, AZ1: A, AZ2: C
~~~

You can try mix-n-math by setting 'HA Type' from 'not' to 'yes' and vice-a-versa..and you will see incorrect values. Please see attached file: vpc-1a91497f_shows_incorrect_AZ1_value.png. From snapshot, you can see that AZ1 value is displayed as B whereas from evm.log it shows correct value 'A'.
~~~
[----] I, [2016-11-14T11:09:39.319374 #14271:1b0cd44]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-1a91497f, HA: yes, AZ1: A, AZ2: B
[----] I, [2016-11-14T11:09:39.339264 #14271:1aef0dc]  INFO -- : <AutomationEngine> <AEMethod dialog_load_az> psachin VPC: vpc-1a91497f, HA: yes, AZ1: A, AZ2: B
~~~
 
I understand this can be a tricky issue. I had hard time to understand and reproduce the bug. Let me know if you need any further info

Comment 15 eclarizi 2016-11-14 16:24:34 UTC
I used your reproducer and this sounds similar to the behavior in https://bugzilla.redhat.com/show_bug.cgi?id=1346952.

Here's what I'm seeing:
The catalog starts with 869630e3 selected, the AZ1 default value is A, and contains A and C. If you were to select 1a91497f right now, AZ1 would then refresh and default to A, and contain A and B.

However, if you were to select b99630dc, AZ1 would then default to B, and contain B and C. Now, if you select 1a91497f, AZ1 would refresh and default to B, because that's what was already selected by the previous AZ1, regardless of any default value that was set in the automate method. The preference for default value is given to a value that was selected if it exists in the newly refreshed values.

If you do the same scenario, select b99630dc, but then change AZ1 to C instead of B, when you select 1a91497f, AZ1 will refresh and since C doesn't exist in the newly refreshed values, it will go back and default to A.

Comment 16 Sachin 2016-11-15 05:43:16 UTC
> The preference for default value is given to a value that was selected if it exists in the newly refreshed values.

I agree, but according to automation(and evm.log) method AZ1 should get 'A' and not the previous value. Are you saying https://bugzilla.redhat.com/show_bug.cgi?id=1346952 has fixed this issue? Customer has CFME version 5.6.2.2

Another question I want to ask is the behaviour you referred only applies to drop-down list? what if I change the type to text-box. In that case, it will not have multiple values to select from.

Comment 17 eclarizi 2016-11-21 16:15:29 UTC
The log statement is coming from the automate method; it's simply showing you the two values.

The behavior applies to drop-down lists and radio buttons, because those are the only ones where the previous versions could have a "selected value". If the type was a text-box, it would always change to whatever gets returned from the automate method.

Comment 27 Tina Fitzgerald 2018-05-24 21:46:02 UTC
We think issue has been fixed with latest PRs. Waiting for QE to validate.

Comment 28 Shveta 2018-05-25 00:01:36 UTC
Hi Tina , 

This BZ needs to be validated against 5.9.3 ?

Comment 29 Tina Fitzgerald 2018-05-25 12:37:24 UTC
Hi Shveta,

Unfortunately, the fixes aren't backported to 5.9 yet.
Can you test on master for now?

Thanks,
Tina

Comment 30 Shveta 2018-05-30 01:10:53 UTC
Hi Sachin , 

I am trying to verify this BZ on https://10.8.199.120/.
Service -aws
Can you check why VPC field is showing script error.
The method requires require "'/usr/local/lib/api_lib'" to work .
Is there any other way to make it work with minimal set up.

Thanks, 
Shveta

Comment 31 Sachin 2018-06-01 06:39:09 UTC
Hi Shveta,

It has been a while I have worked on this reproducer but to answer you query, you can either,

1. Have to hard-code values for all `param_` in "/ RWE-common / Methods / AWS / dialog_load_security_groups". That will be too much of work

or

2. I see that AWS API usage has changed[1] since this BZ was raised. The new usage is something like,

~~~
require 'aws-sdk'

aws = Aws.config.update({
  region: region,
  credentials: Aws::Credentials.new('aws_access_key', 'aws_secret_key')
})
~~~



[1] https://github.com/aws/aws-sdk-ruby

Comment 32 Tina Fitzgerald 2018-07-09 20:18:13 UTC
Hi Shveta,

Can you test this on the latest 5.9.2.4?

Thanks,
Tina

Comment 33 Shveta 2018-07-09 21:44:57 UTC
Hi Tina , 
We don't have 5.9.2.4 appliance anymore . 
Can I validate this on 5.9.3.4 instead ?

Comment 34 Tina Fitzgerald 2018-07-09 21:49:13 UTC
Hi Shveta,

Yes, please.

Thanks,
Tina

Comment 37 Shveta 2018-08-09 18:06:16 UTC
@tina ,
Hi Tina , I have tried with the suggestions in comment 31 and could not get a working dialog .

Tested this BZ with my own dynamic dialog and values were displayed correctly .
Not sure what else can be done here .

can you please check and close this BZ if you are satisfied with testing this with a different dynamic dialog.

Comment 38 Tina Fitzgerald 2018-08-10 10:33:42 UTC
Hi Shveta,

I'm satisfied with testing performed using a different dynamic dialog and am confident the issue has been resolved.   

Thanks,
Tina