Bug 1729341

Summary: Fatal error Couldn't find Service with id for DRO button
Product: Red Hat CloudForms Management Engine Reporter: Bryan Kinney <bkinney>
Component: AutomateAssignee: Patrik Kománek <pkomanek>
Status: CLOSED CURRENTRELEASE QA Contact: John Dupuy <jdupuy>
Severity: high Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: medium    
Version: 5.9.9CC: dmetzger, gmccullo, hkataria, jdupuy, jocarter, mkanoor, nansari, nchugh, obarenbo, pkomanek, simaishi, tfitzger
Target Milestone: GAKeywords: Reopened, TestOnly, ZStream
Target Release: 5.11.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.11.0.21 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1743266 (view as bug list) Environment:
Last Closed: 2019-12-13 14:55:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: Bug
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1743266    
Attachments:
Description Flags
Dialog POST and service page GET
none
Video to show after button execution it routes to the service show with id which generic object belongs to. none

Description Bryan Kinney 2019-07-12 02:14:24 UTC
Description of problem:
A generic object with a button to a dialogue is causing a Fatal error after clicking the Submit button.
Happens even after migration upgrade to 5.10.6.
In CFME 5.10.6: After hitting Submit in Generic Object with a Dialog(via generic object Button) it redirects into a URL where it uses the 'Generic Object ID' as the Service ID
 https://cfme.example.com/api/services/301000000000163   #301000000000163 is a Generic Object ID and not the Service Id.

* FATAL in 5.10.6 log/production.log
[----] F, [2019-07-11T10:36:38.424553 #12777:1888f50] FATAL -- : Error caught: [ActiveRecord::RecordNotFound] Couldn't find Service with 'id'=301000000000163
(cfme-gemset dump)

* FATAL in 5.9.9 log/production.log
[----] F, [2019-07-08T16:19:53.169019 #475:bdb12c] FATAL -- : Error caught: [ActiveRecord::RecordNotFound] Couldn't find Service with 'id'=301000000000146
(cfme-gemset dump)

* log/apache/ssl_error.log
(Multiple [proxy_http:error] and [proxy:error] errors. Unsure if related)

Full sosreport available in the linked case for both versions. 

There are similar buzilla cases:

* https://bugzilla.redhat.com/show_bug.cgi?id=1595213
This was seen in the 5.9.9 version with the extra "generic_object_id" param and value.
After upgrade that extra field and value are gone.

5.9:
/service/show/301000000000401?display=generic_objects&generic_object_id=301000000000146
5.10:
/service/show/301000000000163?display=generic_objects

* https://bugzilla.redhat.com/show_bug.cgi?id=1582873
This created the service via API instead of rails. See the reproduce steps below.
The "worksforme" in comment 15 doesn't work anymore for CFME 5.10.5 and 5.10.6
Assuming that multiple changes to DRO added complexity not satisfied by the way this was setup? 


Version-Release number of selected component (if applicable):
Original: 5.9.9.3-20190503150855_af8378f
Updated:  5.10.6.1-20190621202107_58f5bbc


How reproducible:
Create a Generic Object, service, dialogue, and instance in custom domain.
No method for that instance. CustomDomain/RH/RH/LogMe


Steps to Reproduce:
1. In Automation > Automate > Generic Object create a new generic object called "Network"
2. Create a Service and associate it with the Generic Object above via rails
---
$ vmdb
$ rails c
irb(main):001:0> $evm = MiqAeMethodService::MiqAeService.new(MiqAeEngine::MiqAeWorkspaceRuntime.new)
irb(main):001:0>gobj_cls = $evm.vmdb(:generic_object_definition).find_by_name('Network')
irb(main):001:0>data = {"name" => "frontend"}       
irb(main):001:0>new_gobj = gobj_cls.create_object(data)
irb(main):001:0>new_service = $evm.vmdb(:service).create(:name => "Network frontend")
irb(main):001:0>new_service.display = true
irb(main):001:0>new_gobj.add_to_service(new_service)
---

3. Create a simple automation method in custom Domain:

Namespace: RH
Class: RH
Instance: LogMe

4. Create a simple Service Dialog. Only has a one simple text field.
5. Create a Generic Object button for the "Network" Generic Object with the following details:

Dialog: Use the Service Dialog created in step 4


Object Details
Text: Network objButton
System/Process/: Request
Message: create
Request: call_instance

Attribute/Value Pairs
1 class RH
2 instance LogMe
3 namespace RH

6. Go to Services > My Services and select the Service created in step 2 "Network frontend".
7. In the service "Network frontend" details, click Instances under the Generic Objects table.
8. Click the Generic Object link "frontend"
9. Click on the Button created in step5, "Network objButton"

Should be able to see the error after hitting 'Submit'

Actual results:
Errors out in the UI and logs. The wrong URL is generated.

Expected results:
Continue with the workflow without error.


Additional info:
Using the steps given by the customer this works for us in versions 5.10.6 with a fresh install of the CFME appliance.

Comment 2 Bryan Kinney 2019-07-12 02:28:01 UTC
Correction to Description:

* After hitting Submit in Generic Object with a Dialog(via generic object Button) it redirects into a URL where it uses the 'Generic Object ID' as the Service ID
5.10:
https://cfme.example.com/service/show/301000000000163?display=generic_objects    #301000000000163 is a Generic Object ID and not the Service Id.

Not the api URL given.

Comment 3 Bryan Kinney 2019-07-12 06:29:46 UTC
Created attachment 1589776 [details]
Dialog POST and service page GET

Show in the production.log where the Dialog POST is received properly.
Then the next GET for the service page is using the wrong ID.

Comment 4 Bryan Kinney 2019-07-16 00:26:43 UTC
Would a Hotfix for engine version 5.10.6 be possible?  The fixed version mentioned, 5.10.9, is a minor update from this.
That version 5.10.9 probably won't be available until September?

Comment 5 John Dupuy 2019-07-31 13:37:31 UTC
I was unable to reproduce this in CFME 5.10.8.0

Comment 6 dmetzger 2019-07-31 18:28:20 UTC
Can you test 5.10.7 which is currently available. The known working version based on comment #5 (5.10.8) is scheduled for GA August 13th.

Comment 8 Neha Chugh 2019-08-14 09:03:56 UTC
Hello Team,

I have tested for 5.10.8 version and issue still persist. Below steps I have followed to reproduce this issue:

1. I have associated one generic object instance with id 1 with service object with id 2.
2. I have created custom button for generic objects and added dialog in it.
3. Now, I navigated to Service so to execute the button, once I click the button and after submitting the dialog, the url got changed and it navigates to the service with id 1 which was the generic object ID.

Though it executes the method associated with the button but after button submission, it shows the service page of Id which generic object belongs to.

I will also share a video which will show the issue, meanwhile I am sharing this test appliance for your reference purpose:

10.8.198.152, please login with default credentials.

Thanks and Regards,
Neha Chugh

Comment 9 Neha Chugh 2019-08-14 11:38:02 UTC
Created attachment 1603692 [details]
Video to show after button execution it routes to the service show with id which generic object belongs to.

Comment 13 CFME Bot 2019-08-19 13:27:20 UTC
New commit detected on ManageIQ/manageiq-ui-classic/master:

https://github.com/ManageIQ/manageiq-ui-classic/commit/8b0e5ac432d32a32999b3b3de4ce52d2c1353bd4
commit 8b0e5ac432d32a32999b3b3de4ce52d2c1353bd4
Author:     Harpreet Kataria <hkataria@redhat.com>
AuthorDate: Fri Aug 16 16:57:54 2019 -0400
Commit:     Harpreet Kataria <hkataria@redhat.com>
CommitDate: Fri Aug 16 16:57:54 2019 -0400

    Fixed API endpoint for GO object custom button dialogs.

    Need to pass in correct parent record id and generic_object id to build endpoint url correctly when pressing a GO custom button from list view or details view.

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

 app/controllers/service_controller.rb | 3 +-
 app/services/dialog_local_service.rb | 5 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

Comment 15 CFME Bot 2019-08-19 13:57:16 UTC
New commit detected on ManageIQ/manageiq-ui-classic/ivanchuk:

https://github.com/ManageIQ/manageiq-ui-classic/commit/8a9d219923eb17d214c0062af83052f83200219e
commit 8a9d219923eb17d214c0062af83052f83200219e
Author:     Martin Hradil <mhradil@redhat.com>
AuthorDate: Mon Aug 19 09:25:27 2019 -0400
Commit:     Martin Hradil <mhradil@redhat.com>
CommitDate: Mon Aug 19 09:25:27 2019 -0400

    Merge pull request #6052 from h-kataria/fix_api_endpoint_for_go_custom_buttons

    Fixed API endpoint for GO object custom button dialogs.

    (cherry picked from commit f817e80391785e5fb3f050576e9b4246909d6398)

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

 app/controllers/service_controller.rb | 3 +-
 app/services/dialog_local_service.rb | 5 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

Comment 16 John Dupuy 2019-08-26 14:02:50 UTC
Verified in CFME 5.11.0.21