Project

Profile

Help

Issue #1923

POST /pulp/api/v2/content/actions/delete_orphans/ is broken

Added by Ichimonji10 over 4 years ago. Updated 6 months ago.

Status:
CLOSED - NOTABUG
Priority:
Urgent
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
2.8.3
Platform Release:
2.8.5
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

Description

According to the documentation, it's possible to remove orphaned content units by type and id. [1] It can be done with a call like the following:

POST /pulp/api/v2/content/actions/delete_orphans/ HTTP/1.1
Host: pulp.example.com
Content-Type: application/json

{"content_type_id": "erratum", "unit_id": "abc123"}

According to the Pulp 2.4 release notes, this feature is deprecated. [2] However, semantic versioning implies that this feature won't be released until Pulp version 3. This API call has broken and been fixed in the past. [3] I've tested this API call against Pulp 2.8.3 on Fedora 23.

1. http://pulp.readthedocs.io/en/latest/dev-guide/integration/rest-api/content/orphan.html#remove-orphaned-content-units-by-type-and-id
2. http://pulp.readthedocs.io/en/latest/user-guide/release-notes/2.4.x.html#other-changes
3. https://bugzilla.redhat.com/show_bug.cgi?id=1092467

History

#1 Updated by mhrivnak over 4 years ago

  • Priority changed from Normal to Urgent
  • Platform Release set to 2.8.4
  • Triaged changed from No to Yes

#2 Updated by amacdona@redhat.com over 4 years ago

Whoever fixes this should have a look at webservices/views/content OrphanCollectionView.delete to see how this should be done.

#3 Updated by Ichimonji10 over 4 years ago

Sample of how to trigger the issue:

(pulp-smash3) [ichimonji10@beech:pulp-smash]$ git diff
diff --git a/pulp_smash/tests/rpm/api_v2/test_orphan_remove.py b/pulp_smash/tests/rpm/api_v2/test_orphan_remove.py
index af75b80..65d3b52 100644
--- a/pulp_smash/tests/rpm/api_v2/test_orphan_remove.py
+++ b/pulp_smash/tests/rpm/api_v2/test_orphan_remove.py
@@ -136,8 +136,8 @@ class OrphansTestCase(utils.BaseAPITestCase):

         This test exercises `Pulp #1923 <https://pulp.plan.io/issues/1923>`_.
         """
-        if selectors.bug_is_untestable(1923, self.cfg.version):
-            self.skipTest('https://pulp.plan.io/issues/1923')
+        # if selectors.bug_is_untestable(1923, self.cfg.version):
+        #     self.skipTest('https://pulp.plan.io/issues/1923')
         client = api.Client(self.cfg, api.json_handler)
         orphans_pre = client.get(ORPHANS_PATH)
         orphan = random.choice(client.get(urljoin(ORPHANS_PATH, 'erratum/')))
(pulp-smash3) [ichimonji10@beech:pulp-smash]$ python -m unittest2 pulp_smash.tests.rpm.api_v2.test_orphan_remove
...E..
======================================================================
ERROR: test_02_delete_by_type_and_id (pulp_smash.tests.rpm.api_v2.test_orphan_remove.OrphansTestCase)
Delete an orphan by its ID and type.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ichimonji10/code/pulp-smash/pulp_smash/tests/rpm/api_v2/test_orphan_remove.py", line 146, in test_02_delete_by_type_and_id
    'unit_id': orphan['_id'],
  File "/home/ichimonji10/code/pulp-smash/pulp_smash/api.py", line 281, in post
    return self.request('POST', url, json=json, **kwargs)
  File "/home/ichimonji10/code/pulp-smash/pulp_smash/api.py", line 319, in request
    requests.request(method, **request_kwargs),
  File "/home/ichimonji10/code/pulp-smash/pulp_smash/api.py", line 120, in json_handler
    _handle_202(server_config, response)
  File "/home/ichimonji10/code/pulp-smash/pulp_smash/api.py", line 86, in _handle_202
    _check_tasks(tasks)
  File "/home/ichimonji10/code/pulp-smash/pulp_smash/api.py", line 76, in _check_tasks
    raise exceptions.TaskReportError(msg)
pulp_smash.exceptions.TaskReportError: Task report /pulp/api/v2/tasks/20e6758b-b869-47c8-a10a-7fc284f40f4e/ contains a error: {'data': {'property_names': ['content_type_id', 'unit_id'], 'properties': "['content_type_id', 'unit_id']"}, 'code': 'PLP0015', 'sub_errors': [], 'description': "Invalid properties: ['content_type_id', 'unit_id']"}
Full task report: {'progress_report': {}, '_id': {'$oid': '573f2e04e64aa79aacd7647a'}, 'tags': ['pulp:action:delete_orphans', 'pulp:content_unit:orphans'], 'id': '573f2e04e64aa79aacd7647a', 'worker_name': 'celery', 'queue': 'celery.dq', 'task_type': 'pulp.server.managers.content.orphan.delete_orphans_by_id', 'traceback': 'Traceback (most recent call last):\n  File "/usr/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task\n    R = retval = fun(*args, **kwargs)\n  File "/usr/lib/python2.7/site-packages/pulp/server/async/tasks.py", line 473, in __call__\n    return super(Task, self).__call__(*args, **kwargs)\n  File "/usr/lib/python2.7/site-packages/pulp/server/async/tasks.py", line 103, in __call__\n    return super(PulpTask, self).__call__(*args, **kwargs)\n  File "/usr/lib/python2.7/site-packages/celery/app/trace.py", line 437, in __protected_call__\n    return self.run(*args, **kwargs)\n  File "/usr/lib/python2.7/site-packages/pulp/server/managers/content/orphan.py", line 191, in delete_orphans_by_id\n    raise pulp_exceptions.InvalidValue([\'content_type_id\', \'unit_id\'])\nInvalidValue: Invalid properties: [\'content_type_id\', \'unit_id\']\n', '_ns': 'task_status', 'spawned_tasks': [], 'finish_time': '2016-05-20T15:32:20Z', 'exception': None, '_href': '/pulp/api/v2/tasks/20e6758b-b869-47c8-a10a-7fc284f40f4e/', 'task_id': '20e6758b-b869-47c8-a10a-7fc284f40f4e', 'state': 'error', 'error': {'data': {'property_names': ['content_type_id', 'unit_id'], 'properties': "['content_type_id', 'unit_id']"}, 'code': 'PLP0015', 'sub_errors': [], 'description': "Invalid properties: ['content_type_id', 'unit_id']"}, 'result': None, 'start_time': '2016-05-20T15:32:20Z'}

----------------------------------------------------------------------
Ran 6 tests in 34.984s

FAILED (errors=1)

#4 Updated by Ichimonji10 over 4 years ago

Here's the properly formatted traceback:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pulp/server/async/tasks.py", line 473, in __call__
    return super(Task, self).__call__(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pulp/server/async/tasks.py", line 103, in __call__
    return super(PulpTask, self).__call__(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/celery/app/trace.py", line 437, in __protected_call__
    return self.run(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pulp/server/managers/content/orphan.py", line 191, in delete_orphans_by_id
    raise pulp_exceptions.InvalidValue(['content_type_id', 'unit_id'])
InvalidValue: Invalid properties: ['content_type_id', 'unit_id']

#5 Updated by jortel@redhat.com over 4 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to jortel@redhat.com

#6 Updated by jortel@redhat.com over 4 years ago

According to the API documentation [1] the posted document needs to be an Array.
Reproduced by calling with the document being a dictionary instead of a list. When called correctly, it seems to work.

[jortel@f23d ~]$ curl -X POST -k -H "Content-Type: application/json"  https://admin:admin@localhost/pulp/api/v2/content/actions/delete_orphans/  -d "[{\"content_type_id\": \"erratum\", \"unit_id\": \"abc123\"}]"
{"spawned_tasks": [{"_href": "/pulp/api/v2/tasks/32592408-1bf1-4ad0-8d33-5f7fd4e38f05/", "task_id": "32592408-1bf1-4ad0-8d33-5f7fd4e38f05"}], "result": null, "error": nullpulp-admin tasks details --task-id=32592408-1bf1-4ad0-8d33-5f7fd4e38f05
+----------------------------------------------------------------------+
                              Task Details
+----------------------------------------------------------------------+

Operations:       delete_orphans
Resources:        orphans (content_unit)
State:            Successful
Start Time:       2016-05-20T20:55:25Z
Finish Time:      2016-05-20T20:55:25Z
Result:           N/A
Task Id:          32592408-1bf1-4ad0-8d33-5f7fd4e38f05
Progress Report:
  1. http://pulp.readthedocs.io/en/latest/dev-guide/integration/rest-api/content/orphan.html#remove-orphaned-content-units-by-type-and-id

#7 Updated by Ichimonji10 over 4 years ago

/me facepalms

#9 Updated by Ichimonji10 over 4 years ago

This issue can be marked as NOTABUG.

#10 Updated by semyers over 4 years ago

  • Platform Release changed from 2.8.4 to 2.8.5

#11 Updated by semyers over 4 years ago

  • Status changed from ASSIGNED to CLOSED - NOTABUG

#12 Updated by bmbouter over 1 year ago

  • Tags Pulp 2 added

#13 Updated by bmbouter 6 months ago

  • Category deleted (14)

We are removing the 'API' category per open floor discussion June 16, 2020.

Please register to edit this issue

Also available in: Atom PDF