pulp / pulp_ostree

OSTree support for the Pulp Platform
https://docs.pulpproject.org/pulp_ostree/
GNU General Public License v2.0
59 stars 43 forks source link

Incorrect payload returned when import all fails #376

Closed lzap closed 3 months ago

lzap commented 3 months ago

Version Pulp Stage ConsoleDot

Describe the bug Ostree import API does not conform to the OpenAPI spec when there was an error (artifact is not a valid type of tar with commit). It does return 202, however, the payload is completely different leading to json parsing error.

To Reproduce

  1. Create an artifact that is NOT a valid TAR ostree commit
  2. Upload it as ostree commit

Expected behavior The endpoint returns what is documented in the OpenAPI.

Additional context Generated client is unable to unmarshal to the specified JSON type because it is completely different payload. Expected type:

{
"task": "http://example.com/"
}

What is actually returned:

{
   "pulp_href": "/api/pulp/edge-integration-test-2/api/v3/tasks/019039d0-fb12-7345-8b30-bdbf5f0f691b/",
   "pulp_created": "2024-06-21T08:01:55.476733Z",
   "pulp_last_updated": "2024-06-21T08:01:55.476755Z",
   "state": "failed",
   "name": "pulp_ostree.app.tasks.importing.import_all_refs_and_commits",
   "logging_cid": "c60256a46f574e0cb9510fd2cea1eaa4",
   "created_by": "/api/pulp/edge-integration-test-2/api/v3/users/9/",
   "unblocked_at": "2024-06-21T08:01:55.516060Z",
   "started_at": "2024-06-21T08:01:55.674029Z",
   "finished_at": "2024-06-21T08:01:56.157322Z",
   "error": {
      "traceback": "  File \"/usr/local/lib/python3.9/site-packages/pulpcore/tasking/tasks.py\", line 70, in _execute_task\n    result = func(*args, **kwargs)\n  File \"/usr/local/lib/python3.9/site-packages/pulp_ostree/app/tasks/importing.py\", line 55, in import_all_refs_and_commits\n    return dv.create()\n  File \"/usr/local/lib/python3.9/site-packages/pulpcore/plugin/stages/declarative_version.py\", line 161, in create\n    loop.run_until_complete(pipeline)\n  File \"/usr/lib64/python3.9/asyncio/base_events.py\", line 647, in run_until_complete\n    return future.result()\n  File \"/usr/local/lib/python3.9/site-packages/pulpcore/plugin/stages/api.py\", line 220, in create_pipeline\n    await asyncio.gather(*futures)\n  File \"/usr/local/lib/python3.9/site-packages/pulpcore/plugin/stages/api.py\", line 41, in __call__\n    await self.run()\n  File \"/usr/local/lib/python3.9/site-packages/pulp_ostree/app/tasks/importing.py\", line 324, in run\n    self.init_repository()\n  File \"/usr/local/lib/python3.9/site-packages/pulp_ostree/app/tasks/importing.py\", line 211, in init_repository\n    raise ValueError(\n",
      "description": "An invalid path to the repository provided: api/pulp/edge-integration-test-2/api/v3/repositories/ostree/ostree/019039d0-eb4e-7448-b40d-8fee3a158fb4/"
   },
   "worker": "/api/pulp/default/api/v3/workers/019031ea-8389-7456-afb1-4cf83f3e87b0/",
   "parent_task": null,
   "child_tasks": [],
   "task_group": null,
   "progress_reports": [
      {
         "message": "Committing the tarball",
         "code": "committing.tarball",
         "state": "failed",
         "total": 1,
         "done": 0,
         "suffix": null
      },
      {
         "message": "Associating Content",
         "code": "associating.content",
         "state": "canceled",
         "total": null,
         "done": 0,
         "suffix": null
      }
   ],
   "created_resources": [],
   "reserved_resources_record": [
      "/api/pulp/edge-integration-test-2/api/v3/artifacts/0190360e-ea91-7c8a-989e-d6783056f7a4/",
      "/api/pulp/edge-integration-test-2/api/v3/repositories/ostree/ostree/019039d0-eb4e-7448-b40d-8fee3a158fb4/",
      "prn:core.artifact:0190360e-ea91-7c8a-989e-d6783056f7a4",
      "prn:ostree.ostreerepository:019039d0-eb4e-7448-b40d-8fee3a158fb4",
      "shared:prn:core.domain:0190360e-c33e-73d3-a666-591cd2730da9",
      "shared:/api/pulp/default/api/v3/domains/0190360e-c33e-73d3-a666-591cd2730da9/"
   ]
}
lubosmj commented 3 months ago

Can you also provide a reproducer for this? Are you seeing this error when running the import after you uploaded an invalid artifact to Pulp?

lzap commented 3 months ago

Sorry I got this wrong, invalid bug report.