ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.91k stars 3.41k forks source link

Collection awx.awx.tower_import is slow #13036

Open ArtsiomMusin opened 1 year ago

ArtsiomMusin commented 1 year ago

Please confirm the following

Bug Summary

tower_import takes 6 minutes to import any object. Since there might be a lot of dependencies to import at one run, the entire job execution time may take hours to complete just for one organizations.

Attaching the screenshot below where it's seen one task takes 6 mins to complete: image

AWX version

ansible tower 3.8.6

Select the relevant components

Installation method

openshift

Modifications

no

Ansible version

No response

Operating system

No response

Web browser

Chrome

Steps to reproduce

Just simple tower_import for organization or any other object

Expected results

Some time as tower_export

Actual results

6 mins for one tower_import

Additional information

No response

sarabrajsingh commented 1 year ago

hi @ArtsiomMusin,

how big is your import? how many objects are you trying to import?

seem like you're running tower. there is a LDAP issue in tower if you're using basic authentication which causes an excessive amount of database traffic, which could be slowing down your import.

please let us know,

AWX Team

ArtsiomMusin commented 1 year ago

Hi @sarabrajsingh

I'm trying to import one object per one tower_import task:

- name: import org
  awx.awx.tower_import:
    assets: "{{ lookup('file', file_name) | from_json() }}"
    tower_host: "{{ tower_url }}"
    tower_oauthtoken: "{{ lookup('env', 'TOWER_OAUTH_TOKEN') }}"
    validate_certs: no

The file content is:

{"organizations": [{"name": "xxx", "description": "", "max_hosts": 0, "custom_virtualenv": null, "related": {"notification_templates": [{"organization": {"name": "xxx", "type": "organization"}, "name": "sid", "type": "notification_template"}], "notification_templates_started": [], "notification_templates_success": [], "notification_templates_error": [], "notification_templates_approvals": []}, "natural_key": {"name": "xxx", "type": "organization"}}]}

So this is using tower token to run export/import. Also the playbook is executed directly on tower localhost and I assume the connection should be more or less fast.

awxkit is 18.0.0

ArtsiomMusin commented 1 year ago

debugged that to see the root cause. It's slow in getting all objects for each endpoint https://github.com/ansible/awx/blob/9f8b3948e1aad75620bec818f1965b1bb1acbf6e/awxkit/awxkit/api/pages/api.py#L389

it gets all objects for all types listed here https://github.com/ansible/awx/blob/9f8b3948e1aad75620bec818f1965b1bb1acbf6e/awxkit/awxkit/api/pages/api.py#L15-L29

Since there might be a lot of objects for each type, those get requests can become slow as it's in our case. And if you import many objects separately, then it leads to very long running job