Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate url open fixes #6040

Merged
merged 2 commits into from
Aug 19, 2019

Conversation

martinpovolny
Copy link
Member

@martinpovolny martinpovolny commented Aug 15, 2019

Fixes for:

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

  • "Provider" is really an "ExtManagementSystem",
  • wait_for_task route missing in Service controller.

Tested automate code for "Provider":

For "Provider" testing also ManageIQ/manageiq#19157 is needed. (merged)

provider = $evm.root['ext_management_system']
provider.external_url = "https://www.redhat.com"

Tested automate code for "Service":

service = $evm.root['service']
service.external_url = "https://www.redhat.com"

Tested automate code for "CloudTenant":

t = $evm.root['cloud_tenant']
$evm.log(:info, "cloud_tenant: #{t.inspect}")
t.external_url = "https://www.redhat.com"

Tested automate code for "Tenant":

Requires automation engine PR: ManageIQ/manageiq-automation_engine#350 (merged)

$evm.log(:info, $evm.root['vmdb_object_type'])
$evm.log(:info, "tenant_id: #{$evm.root['tenant_id']}")

# t = $evm.root['tenant'] # this will give the LOGGGED IN tenant, not the target object tenant
t = $evm.vmdb($evm.root['vmdb_object_type']).find_by(:id => $evm.root['tenant_id'])
$evm.log(:info, "tenant: #{t.inspect}")
t.external_url = "https://www.redhat.com"

Notes:

How to access a number of objects: https://pemcg.gitbooks.io/introduction-to-cloudforms-automation/content/chapter6/evm_and_the_workspace.html

Note that $evm.root['vmdb_object_type'] contains the class for all the objects.
However $evm.root['target_object_ids'] is NOT set for the singular case (and thus is useless for this case). I am not aware of any generic way to get the ID of the target object in the singular case.

Note that a number of variables such as $evm.root['vm'] or $evm.root['user'] exist but they do NOT contain the target object in all cases.

The $evm.root[...] variables user, group and tenant contain the LOGGED IN user insted of the target object one.

For the case where User is the target class, $evm.root['user_id'] is set with the ID of the target object.

@martinpovolny martinpovolny force-pushed the automate_url_open_fixes branch from f605530 to d46bc6b Compare August 15, 2019 14:27
@miq-bot
Copy link
Member

miq-bot commented Aug 15, 2019

Checked commits martinpovolny/manageiq-ui-classic@f6d2260~...d46bc6b with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@martinpovolny martinpovolny changed the title Automate url open fixes [WIP] Automate url open fixes Aug 15, 2019
@martinpovolny
Copy link
Member Author

martinpovolny commented Aug 16, 2019

Everything seems to be working for me except for Generic Object.

What I am experiencing there is that the automate method gets invoked, all is set, but the associated MiqTask never finished.

So the UI ends up in an endless loop of wait_for_task request.

The automate code for GO that I am testing:

$evm.log(:info, "Object type: #{$evm.root['vmdb_object_type']}")
go = $evm.root['generic_object']
$evm.log(:info, "GO: #{go.inspect}")
go.external_url = "https://www.redhat.com"

I am using https://gist.github.com/martinpovolny/4d960e550a7838a9b04cb4d8396514b0 to create a Service with GO for testing.

This will been some help from someone who knows automate.

And I found this issue: #6048

@martinpovolny martinpovolny removed the wip label Aug 16, 2019
@martinpovolny martinpovolny changed the title [WIP] Automate url open fixes Automate url open fixes Aug 16, 2019
@martinpovolny
Copy link
Member Author

@pkomanek : can you help me with the issue in the last comment? (Automate method seems to be finished according to the logs, but the associated MiqTask is not)

[----] I, [2019-08-16T21:12:05.029268 #28794:1116600]  INFO -- : User [admin] with current group ID [2] name [EvmGroup-super_administrator]
[----] I, [2019-08-16T21:12:05.221305 #28794:1116600]  INFO -- : Instantiating [/SYSTEM/PROCESS/Request?GenericObject%3A%3Ageneric_object=12&MiqServer%3A%3Amiq_server=17&User%3A%3Auser=1&object_name=Request&request=url_open_go&vmdb_object_type=generic_object#create]
[----] I, [2019-08-16T21:12:05.414080 #28794:1116600]  INFO -- : Updated namespace [/SYSTEM/PROCESS/Request?GenericObject%3A%3Ageneric_object=12&MiqServer%3A%3Amiq_server=17&User%3A%3Auser=1&object_name=Request&request=url_open_go&vmdb_object_type=generic_object#create  ManageIQ/SYSTEM]
[----] I, [2019-08-16T21:12:05.573986 #28794:1116600]  INFO -- : Updated namespace [SYSTEM/PROCESS/parse_provider_category  ManageIQ/SYSTEM]
[----] I, [2019-08-16T21:12:05.582141 #28794:1116600]  INFO -- : Invoking [builtin] method [/ManageIQ/System/Process/parse_provider_category] with inputs [{}]
[----] I, [2019-08-16T21:12:05.582332 #28794:1116600]  INFO -- : Setting provider_category to: 
[----] I, [2019-08-16T21:12:05.582532 #28794:1116600]  INFO -- : Following Relationship [miqaedb:/System/Request/url_open_go#create]
[----] I, [2019-08-16T21:12:05.594730 #28794:1116600]  INFO -- : Updated namespace [miqaedb:/System/Request/url_open_go#create  open_url_test/System]
[----] I, [2019-08-16T21:12:05.629835 #28794:1116600]  INFO -- : Updated namespace [System/Request/url_open_go  open_url_test/System]
[----] I, [2019-08-16T21:12:05.635280 #28794:1116600]  INFO -- : Invoking [inline] method [/open_url_test/System/Request/url_open_go] with inputs [{}]
[----] I, [2019-08-16T21:12:05.641752 #28794:1116600]  INFO -- : <AEMethod [/open_url_test/System/Request/url_open_go]> Starting 
[----] I, [2019-08-16T21:12:06.395545 #28794:4534338]  INFO -- : <AEMethod url_open_go> Object type: generic_object
[----] I, [2019-08-16T21:12:06.403737 #28794:4534338]  INFO -- : <AEMethod url_open_go> GO: #<MiqAeServiceGenericObject:0x4294614 @object=#<GenericObject:0x00000000085293f8 id: 12, name: "GO With a Service 038557", uid: nil, generic_object_definition_id: 7, created_at: "2019-08-16 17:50:57", updated_at: "2019-08-16 17:50:58", attributes: {}, associations: ["vms", "abc"], methods: ["add_vm", "remove_vm"]>, @virtual_columns=["generic_object_definition_name", "href_slug", "region_description", "region_number"], @associations=["custom_action_buttons", "custom_actions", "custom_button_events", "external_urls", "generic_object_definition", "picture", "taggings"]>
[----] I, [2019-08-16T21:12:06.445402 #28794:1116600]  INFO -- : <AEMethod [/open_url_test/System/Request/url_open_go]> Ending
[----] I, [2019-08-16T21:12:06.445457 #28794:1116600]  INFO -- : Method exited with rc=MIQ_OK
[----] I, [2019-08-16T21:12:06.445901 #28794:1116600]  INFO -- : Followed  Relationship [miqaedb:/System/Request/url_open_go#create]

@martinpovolny
Copy link
Member Author

martinpovolny commented Aug 16, 2019

Seems the worker crashes fulfilling the MiqTask in question:

[----] I, [2019-08-16T21:12:04.156669 #28915:4db659c]  INFO -- : MIQ(MiqQueue.put) Message id: [55022599],  id: [], Zone: [], Role: [automate], Server: [], MiqTask id: [60661], Ident: [gener
ic], Target id: [], Instance id: [], Task id: [], Command: [MiqAeEngine.deliver], Timeout: [600], Priority: [20], State: [ready], Deliver On: [], Data: [], Args: [{:namespace=>"SYSTEM", :cla
ss_name=>"PROCESS", :instance_name=>"Request", :automate_message=>"create", :open_url_task_id=>nil, :attrs=>{"request"=>"url_open_go"}, :object_type=>"GenericObject", :object_id=>12, :user_i
d=>1, :miq_group_id=>2, :tenant_id=>1, :username=>"admin", :task_id=>60661}]
[----] I, [2019-08-16T21:12:04.156763 #28915:4db659c]  INFO -- : MIQ(MiqTask.generic_action_with_callback) Task: [60661] Queued the action: [Calling automate for user admin] being run for us
er: [#<User:0x00007f4384b3ca58>]
[----] I, [2019-08-16T21:12:04.602980 #28794:1116600]  INFO -- : MIQ(MiqQueue#deliver) Message id: [55022599], Delivering...
[----] I, [2019-08-16T21:12:04.951869 #28794:1116600]  INFO -- : MIQ(MiqTask#update_status) Task: [60661] [Active] [Ok] [Task starting]
[----] I, [2019-08-16T21:12:05.029315 #28794:1116600]  INFO -- : MIQ(MiqAeEngine.deliver) Delivering {"request"=>"url_open_go"} for object [GenericObject.12] with state [] to Automate
[----] I, [2019-08-16T21:12:06.447456 #28794:1116600]  INFO -- : MIQ(MiqQueue#delivered) Message id: [55022599], State: [ok], Delivered in [1.84449775] seconds
[----] I, [2019-08-16T21:12:06.499520 #28794:1116600]  INFO -- : MIQ(MiqQueue#m_callback) Message id: [55022599], Invoking Callback with args: ["Finished", "ok", "Message delivered successfu
lly", "#<MiqAeEngine::MiqAeWorkspaceRuntime:0x000000000ab47350 @readonly=false, @nodes=[#<MiqAeEngine::MiqAeObject:0x000000000985ec20 @workspace=#<MiqAeEngine::MiqAeWorkspaceRuntime:0x000000
000ab47350 ...>, @namespace=\"ManageIQ/SYSTEM\", @klass=\"PROCESS\", @instance=\"Request\", @attributes={\"object_name\"=>\"Request\", \"request\"=>\"url_open_go\", \"vmdb_object_type\"=>\"g
eneric_object\", \"generic_object_id\"=>\"12\", \"generic_object\"=>#<MiqAeServiceGenericObject:0x4294614 @object=#<GenericObject:0x00000000085293f8 id..."]
[----] E, [2019-08-16T21:12:06.527764 #28794:1116600] ERROR -- : MIQ(MiqQueue#m_callback) Message id: [55022599]: Workspace not found when running generic object
[----] E, [2019-08-16T21:12:06.527855 #28794:1116600] ERROR -- : [RuntimeError]: Workspace not found when running generic object  Method:[block (2 levels) in <class:LogProxy>]
[----] E, [2019-08-16T21:12:06.527952 #28794:1116600] ERROR -- : /home/martin/Projects/manageiq-automation_engine/lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb:25:in `ae_user_identity'
/home/martin/Projects/manageiq-automation_engine/lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb:31:in `method_missing'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:517:in `dump_coder'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:134:in `accept'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:360:in `block in visit_Hash'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:358:in `each'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:358:in `visit_Hash'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:136:in `accept'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:546:in `block in dump_ivars'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:544:in `each'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:544:in `dump_ivars'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:163:in `visit_Object'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:136:in `accept'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:389:in `block in visit_Enumerator'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:389:in `each'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:389:in `visit_Enumerator'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:381:in `visit_Array'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:136:in `accept'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:546:in `block in dump_ivars'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:544:in `each'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:544:in `dump_ivars'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:163:in `visit_Object'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:136:in `accept'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych/visitors/yaml_tree.rb:118:in `push'
/home/martin/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/psych.rb:441:in `dump'
/home/martin/Projects/manageiq/app/models/miq_task.rb:271:in `task_results='
/home/martin/Projects/manageiq/app/models/miq_task.rb:242:in `queue_callback'
/home/martin/Projects/manageiq/app/models/miq_queue.rb:522:in `m_callback'
/home/martin/Projects/manageiq/app/models/miq_queue.rb:491:in `delivered'
/home/martin/Projects/manageiq/lib/vmdb/console_methods.rb:37:in `block in simulate_queue_worker'

@martinpovolny
Copy link
Member Author

@mzazrivec : from the above stacktrace I conclude that the last issue is a bug somewhere between Core and Automate. I think that this PR can be merged and the last issue needs to be worked on separately.

@mzazrivec mzazrivec self-assigned this Aug 19, 2019
@mzazrivec mzazrivec added this to the Sprint 118 Ending Aug 19, 2019 milestone Aug 19, 2019
@mzazrivec mzazrivec merged commit 8a3ad53 into ManageIQ:master Aug 19, 2019
@tinaafitz
Copy link
Member

@lfu Can you look into the stacktrace above?

lfu added a commit to lfu/manageiq-automation_engine that referenced this pull request Aug 20, 2019
This method is called by YAML.dump when miq_queue sets the callback result into miq_task.task_results.

Reported by ManageIQ/manageiq-ui-classic#6040 (comment).
lfu added a commit to lfu/manageiq-automation_engine that referenced this pull request Aug 23, 2019
Returning back workspace breaks the custom button for generic objects.
Reported by ManageIQ/manageiq-ui-classic#6040 (comment).

https://bugzilla.redhat.com/show_bug.cgi?id=1550002
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants