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

Add more fields to /tasks endpoint #526

Merged
merged 6 commits into from
Jan 11, 2021
Merged

Conversation

rochacbruno
Copy link
Member

@rochacbruno rochacbruno commented Oct 22, 2020

Issue: AAH-16

Replaces #488

/tasks/

GET /api/automation-hub/v3/tasks/
HTTP 200 OK
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "meta": {
        "count": 2
    },
    "links": {
        "first": "/api/automation-hub/v3/tasks/?limit=10&offset=0",
        "previous": null,
        "next": null,
        "last": "/api/automation-hub/v3/tasks/?limit=10&offset=0"
    },
    "data": [
        {
            "pulp_id": "4a02f4b2-201c-4c71-8d5b-56a717332d20",
            "name": "pulp_ansible.app.tasks.collections.sync",
            "repository": "rh-certified",
            "state": "failed",
            "started_at": "2020-11-09T16:32:47.436947Z",
            "finished_at": "2020-11-09T16:32:48.340957Z",
            "href": "/api/automation-hub/v3/tasks/4a02f4b2-201c-4c71-8d5b-56a717332d20/"
        },
        {
            "pulp_id": "51d13b1d-328b-4354-b832-b1c706055522",
            "name": "pulp_ansible.app.tasks.collections.sync",
            "repository": "community",
            "state": "failed",
            "started_at": "2020-11-05T21:10:37.050173Z",
            "finished_at": "2020-11-05T21:10:38.158190Z",
            "href": "/api/automation-hub/v3/tasks/51d13b1d-328b-4354-b832-b1c706055522/"
        }
    ]
}

/tasks/pk/

GET /api/automation-hub/v3/tasks/4a02f4b2-201c-4c71-8d5b-56a717332d20/
HTTP 200 OK
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "pulp_id": "4a02f4b2-201c-4c71-8d5b-56a717332d20",
    "name": "pulp_ansible.app.tasks.collections.sync",
    "created_at": "2020-11-09T16:32:47.310079Z",
    "updated_at": "2020-11-09T16:32:48.341382Z",
    "finished_at": "2020-11-09T16:32:48.340957Z",
    "started_at": "2020-11-09T16:32:47.436947Z",
    "state": "failed",
    "error": {
        "traceback": "  File \"/venv/lib64/python3.6/site-packages/rq/worker.py\", line 936, in perform_job\n    rv = job.perform()\n  File \"/venv/lib64/python3.6/site-packages/rq/job.py\", line 684, in perform\n    self._result = self._execute()\n  File \"/venv/lib64/python3.6/site-packages/rq/job.py\", line 690, in _execute\n    return self.func(*self.args, **self.kwargs)\n  File \"/venv/lib64/python3.6/site-packages/pulp_ansible/app/tasks/collections.py\", line 82, in sync\n    d_version.create()\n  File \"/venv/lib64/python3.6/site-packages/pulpcore/plugin/stages/declarative_version.py\", line 148, in create\n    loop.run_until_complete(pipeline)\n  File \"/usr/lib64/python3.6/asyncio/base_events.py\", line 484, in run_until_complete\n    return future.result()\n  File \"/venv/lib64/python3.6/site-packages/pulpcore/plugin/stages/api.py\", line 225, in create_pipeline\n    await asyncio.gather(*futures)\n  File \"/venv/lib64/python3.6/site-packages/pulpcore/plugin/stages/api.py\", line 43, in __call__\n    await self.run()\n  File \"/venv/lib64/python3.6/site-packages/pulp_ansible/app/tasks/collections.py\", line 290, in run\n    async for metadata in self._fetch_collections():\n  File \"/venv/lib64/python3.6/site-packages/pulp_ansible/app/tasks/collections.py\", line 441, in _fetch_collections\n    count = await _loop_through_pages(not_done)\n  File \"/venv/lib64/python3.6/site-packages/pulp_ansible/app/tasks/collections.py\", line 399, in _loop_through_pages\n    url = await _get_url(1, versions_url)\n  File \"/venv/lib64/python3.6/site-packages/pulp_ansible/app/tasks/collections.py\", line 387, in _get_url\n    api_endpoint, api_version = await _get_collection_api(remote.url)\n  File \"/venv/lib64/python3.6/site-packages/pulp_ansible/app/tasks/collections.py\", line 361, in _get_collection_api\n    api_data = parse_metadata(await downloader.run())\n  File \"/venv/lib64/python3.6/site-packages/pulpcore/download/base.py\", line 227, in run\n    return await self._run(extra_data=extra_data)\n  File \"/venv/lib64/python3.6/site-packages/backoff/_async.py\", line 133, in retry\n    ret = await target(*args, **kwargs)\n  File \"/venv/lib64/python3.6/site-packages/pulp_ansible/app/downloaders.py\", line 88, in _run\n    return await super()._run(extra_data=extra_data)\n  File \"/venv/lib64/python3.6/site-packages/backoff/_async.py\", line 133, in retry\n    ret = await target(*args, **kwargs)\n  File \"/venv/lib64/python3.6/site-packages/pulpcore/download/http.py\", line 210, in _run\n    self.raise_for_status(response)\n  File \"/venv/lib64/python3.6/site-packages/pulp_ansible/app/downloaders.py\", line 66, in raise_for_status\n    response.raise_for_status()\n  File \"/venv/lib64/python3.6/site-packages/aiohttp/client_reqrep.py\", line 946, in raise_for_status\n    headers=self.headers)\n",
        "description": "401, message='Unauthorized', url=URL('https://cloud.redhat.com/api/automation-hub/v3/collections/api/')"
    },
    "worker": {
        "name": "1@d038415f3345",
        "missing": false,
        "last_heartbeat": "2020-11-09T20:22:33.770831Z"
    },
    "parent_task": null,
    "child_tasks": [],
    "repository": "rh-certified",
    "progress_reports": [
        {
            "message": "Parsing CollectionVersion Metadata",
            "code": "parsing.metadata",
            "state": "failed",
            "total": null,
            "done": 0,
            "suffix": null
        },
        {
            "message": "Parsing Galaxy Collections API",
            "code": "parsing.collections",
            "state": "failed",
            "total": null,
            "done": 0,
            "suffix": null
        },
        {
            "message": "Downloading Artifacts",
            "code": "downloading.artifacts",
            "state": "canceled",
            "total": null,
            "done": 0,
            "suffix": null
        },
        {
            "message": "Downloading Artifacts",
            "code": "downloading.artifacts",
            "state": "canceled",
            "total": null,
            "done": 0,
            "suffix": null
        },
        {
            "message": "Associating Content",
            "code": "associating.content",
            "state": "canceled",
            "total": null,
            "done": 0,
            "suffix": null
        }
    ]
}

rochacbruno added a commit to rochacbruno/pulpcore that referenced this pull request Oct 23, 2020
Currently it is only possible to import ProgressReportSerializer through
`pulpcore.app.serializers` and it is useful to have it on
`pulpcore.plugin.serializers`

Related PR: ansible/galaxy_ng#526

[noissue]
@rochacbruno rochacbruno changed the title [WIP] Add more fields to /tasks endpoint Add more fields to /tasks endpoint Oct 26, 2020
rochacbruno added a commit to rochacbruno/pulpcore that referenced this pull request Oct 28, 2020
Currently it is only possible to import ProgressReportSerializer through
`pulpcore.app.serializers` and it is useful to have it on
`pulpcore.plugin.serializers`

Related PR: ansible/galaxy_ng#526

closes #7759
daviddavis pushed a commit to pulp/pulpcore that referenced this pull request Oct 28, 2020
Currently it is only possible to import ProgressReportSerializer through
`pulpcore.app.serializers` and it is useful to have it on
`pulpcore.plugin.serializers`

Related PR: ansible/galaxy_ng#526

closes #7759
@rochacbruno rochacbruno changed the title Add more fields to /tasks endpoint [WIP] Add more fields to /tasks endpoint Nov 9, 2020
- Added 7 more fields to /tasks endpoint
- Added information about worker and errors
- Added progress_reports from pulp api

Issue: AAH-16
temporary solution until pulp/pulpcore#982 is
merged

No-Issue
No-Issue
@rochacbruno rochacbruno changed the title [WIP] Add more fields to /tasks endpoint Add more fields to /tasks endpoint Nov 13, 2020
@alikins
Copy link
Contributor

alikins commented Dec 1, 2020

First glance, I like the pr. It will resolve some issues I've ran into when troubleshooting tasks (notably, that the /tasks from galaxy_ng are missing lots of info that exists in the corresponding pulp task).

Main concern would be making sure the changes are compatible with ansible-galaxy's use of the galaxy_ng task end points. But I haven't dug into that yet.

Copy link
Contributor

@alikins alikins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alikins alikins merged commit 7901955 into ansible:master Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants