Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Martin Hradil
@himdel
From what I can tell, there has been no PR to add any kind of API editing to service templates since the initial commit
(there are changes to service template subcollections, but that probably doesn't help)
Martin Hradil
@himdel

Should an API request be waiting for a task?

When I try to POST to /api/service_templates to create a new template,
the POST request just hangs indefinitely,
until I run simulate_queue_worker

That sounds wrong, I would have thought the API request would end immediately, with the task_id to watch.
@abellotti , @Fryguy is that by design? ^
Keenan Brock
@kbrock
Does seem that it would be done in the foreground or background (queue) or a little of both. But blocking on background always seemed strange
Did it need automate to run?
Martin Hradil
@himdel
it was creating an ansible catalog item .. so... maybe?
reproducer..
API.post('/api/service_templates', {"action":"create","resource":{"name":"ff","description":"fff","long_description":"","display":false,"service_template_catalog_id":"","zone_id":"2","prov_type":"generic_ansible_playbook","type":"ServiceTemplateAnsiblePlaybook","additional_tenant_ids":[],"config_info":{"provision":{"repository_id":"23","playbook_id":"304","credential_id":"10","hosts":"localhost","verbosity":"0","log_output":"on_error","extra_vars":{},"execution_ttl":"","become_enabled":false,"dialog_id":"3"},"retirement":{"remove_resources":"yes_without_playbook","verbosity":"0","log_output":"on_error"}}}})
Jason Frey
@Fryguy
@himdel If that's the case, it's a bug...we should not ever wait in the API
If it's ansible catalog item, it's possible that's because of the new embedded ansible changes... cc @NickLaMuro ^
Martin Hradil
@himdel
Thanks, yeah, waiting that way seems weird
(And UI already has an API.wait_for_task(task_id) => Promise mechanism, so we can deal with the API returning task_id)
Jason Frey
@Fryguy
yeah, we need to double check that
Nick LaMuro
@NickLaMuro
I there is a bug in the service templates that QE had made me aware of, and was working on trying to get it reproduced, but got distracted with other broken things...
Sounds related though if it is service template related
Jason Frey
@Fryguy
I'm curious if this is an old issue or a new issue
Nick LaMuro
@NickLaMuro
well, the issue QE had was that they can't create a catalog item for an ansible playbook, so it sounds new
because that was working for me and Nick C. just fine a few weeks ago at least
Nick LaMuro
@NickLaMuro
@himdel Okay, I think I have figured out the issue. Is this using the embedded_ansible provider?
Martin Hradil
@himdel
@NickLaMuro yup,
> ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScriptSource.find(23)
=> #<ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource id: 23, manager_id: 2, manager_ref: "21", name: "avaleror_test", description: "playbooks for testing", created_at: "2018-02-09 18:56:54", updated_at: "2018-02-09 18:56:54", scm_type: "git", scm_url: "https://github.com/avaleror/ansible", scm_branch: "", scm_clean: false, scm_delete_on_update: false, scm_update_on_launch: true, authentication_id: nil, type: "ManageIQ::Providers::EmbeddedAnsible::AutomationMa...", status: "successful", last_updated_on: nil, last_update_error: nil>
Nick LaMuro
@NickLaMuro
Can you do this then:
> ManageIQ::Providers::EmbeddedAutomationManager.count
> ManageIQ::Providers::EmbeddedAutomationManager.first
(I assume you only have one, but want to make sure)
Martin Hradil
@himdel
1
=> #<ManageIQ::Providers::EmbeddedAnsible::AutomationManager id: 2, name: "Embedded Ansible", created_on: "2017-10-06 16:44:53", updated_on: "2019-06-19 10:06:20", guid: "d5b70db0-244d-4f29-818a-61abb429de9b", zone_id: 1, type: "ManageIQ::Providers::EmbeddedAnsible::AutomationMa...", api_version: "3.2.2", uid_ems: nil, host_default_vnc_port_start: nil, host_default_vnc_port_end: nil, provider_region: nil, last_refresh_error: "uninitialized constant ManageIQ::Providers::Embedd...", last_refresh_date: "2019-06-19 10:06:20", provider_id: 1, realm: nil, tenant_id: 1, project: nil, parent_ems_id: nil, subscription: nil, last_metrics_error: nil, last_metrics_update_date: nil, last_metrics_success_date: nil, tenant_mapping_enabled: nil, enabled: true, options: nil, zone_before_pause_id: nil, 
last_inventory_date: nil>
Nick LaMuro
@NickLaMuro
ManageIQ::Providers::EmbeddedAutomationManager.first.authentications.count
Martin Hradil
@himdel
9
Nick LaMuro
@NickLaMuro
damn... multiple makes this harder
ManageIQ::Providers::EmbeddedAutomationManager.first.authentications.all.map(&:manager_ref)
Martin Hradil
@himdel
is ManageIQ::Providers::EmbeddedAutomationManager.first.last_refresh_error relevant? => "uninitialized constant ManageIQ::Providers::EmbeddedAnsible::AutomationManager::RefreshParser"
Nick LaMuro
@NickLaMuro
oh, no, that is not what I was getting
Martin Hradil
@himdel
> ManageIQ::Providers::EmbeddedAutomationManager.first.authentications.all.map(&:manager_ref)
=> ["2", "5", "8", "7", "9", "10", "3", "4", nil]
Nick LaMuro
@NickLaMuro
ManageIQ::Providers::EmbeddedAutomationManager.first.authentications.all.last
the nil manager_ref I "think™" is the problem
Martin Hradil
@himdel
sounds reasonable :)
=> #<ManageIQ::Providers::EmbeddedAnsible::AutomationManager::MachineCredential id: 170, name: "ManageIQ Default Credential", authtype: nil, userid: nil, password: nil, resource_id: 2, resource_type: "ExtManagementSystem", created_on: "2019-06-12 09:25:43", updated_on: "2019-06-12 09:25:43", last_valid_on: nil, last_invalid_on: nil, credentials_changed_on: nil, status: nil, status_details: nil, type: "ManageIQ::Providers::EmbeddedAnsible::AutomationMa...", auth_key: nil, fingerprint: nil, service_account: nil, challenge: nil, login: nil, public_key: nil, htpassd_users: [], ldap_id: [], ldap_email: [], ldap_name: [], ldap_preferred_user_name: [], ldap_bind_dn: nil, ldap_insecure: nil, ldap_url: nil, request_header_challenge_url: nil, request_header_login_url: nil, request_header_headers: [], request_header_preferred_username_headers: [], request_header_name_headers: [], request_header_email_headers: [], open_id_sub_claim: nil, open_id_user_info: nil, open_id_authorization_endpoint: nil, open_id_token_endpoint: nil, open_id_extra_scopes: [], open_id_extra_authorize_parameters: nil, certificate_authority: nil, google_hosted_domain: nil, github_organizations: [], rhsm_sku: nil, rhsm_pool_id: nil, rhsm_server: nil, manager_ref: nil, options: nil, evm_owner_id: nil, miq_group_id: 1, tenant_id: 1, become_username: nil, become_password: nil, auth_key_password: nil>
Jason Frey
@Fryguy
Conversations in Code™
Martin Hradil
@himdel
:)
Jason Frey
@Fryguy
puts "Hi"
Nick LaMuro
@NickLaMuro
okay, then try doing this:
ManageIQ::Providers::EmbeddedAutomationManager.first.authentications.all.last.update_attribute :manager_ref, ManageIQ::Providers::EmbeddedAutomationManager.first.id
I think that should allow you to create a new service template now
because this was the error I got:
{"error":{"kind":"bad_request","message":"Could not create Service Template - cant convert nil into Integer","klass":"Api::BadRequestError"}}
Martin Hradil
@himdel
oh ... which problem are you solving ?
Nick LaMuro
@NickLaMuro

basically, it was two pronged:

In app/models/manageiq/providers/embedded_ansible/seeding.rb when you first enable the role, it will create a default credential, but only assign it the name attribute. This was mostly okay since we were using the relation to fill in the rest.

But with the native_ref call, this would bomb when trying to type cast a nil to an integer. manager_ref was something we got from a refresh when using ansible_tower

Martin Hradil
@himdel
aah, but it still waits for a task
Nick LaMuro
@NickLaMuro
there is a "task" we create for this, but it is mostly ceremony for the UI now, since there is zero refresh is needed
but it was bombing prior to that (at least for me) because of the above
Martin Hradil
@himdel
ok, I'll run simulate_queue_worker and look at the new last one?
Nick LaMuro
@NickLaMuro
the fix (I think) is just to make sure we put in a stub manager_ref for the sake of things that still use it when seeding
that should be right, though I am suprised you don't have to re-run that API call
Martin Hradil
@himdel
Heheh, [----] I, [2019-06-19T18:09:32.654219 #19301:2b2882198e64] INFO -- : Completed 400 Bad Request in 178176ms (Views: 0.1ms | ActiveRecord: 159.6ms)
{"error":{"kind":"bad_request","message":"Could not create Service Template - undefined method '[]' for nil:NilClass","klass":"Api::BadRequestError"}}
Nick LaMuro
@NickLaMuro
this is where I am wondering if you had carried over credentials from a previous database