Bug 1078833 - Update importer of unexistant repo should return 404
Summary: Update importer of unexistant repo should return 404
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Pulp
Classification: Retired
Component: API/integration
Version: unspecified
Hardware: Unspecified
OS: Unspecified
medium
unspecified
Target Milestone: ---
: 2.6.1
Assignee: Jeremy Cline
QA Contact: pulp-qe-list
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-03-20 11:31 UTC by Ina Panova
Modified: 2015-02-28 22:03 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-02-28 22:03:40 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Pulp Redmine 406 0 None None None Never

Description Ina Panova 2014-03-20 11:31:44 UTC
Description of problem:
https://pulp-dev-guide.readthedocs.org/en/latest/integration/rest-api/repo/cud.html#update-an-importer-associated-with-a-repository

Docs say that an importer associated to a repo can be updated, but in case if there is no repository or importer with the specified IDs it will return 404.
Current api in this case returns a call report with 202 response code and the error is visible only in the task information. 

# curl -i -H "Accept: application/json" -X PUT  -k -u admin:admin -d '{"importer_config":{"num_units":5}}' 'https://ec2-54-217-78-7.eu-west-1.compute.amazonaws.com/pulp/api/v2/repositories/unexistant_repo/importers/yum_importer/'
HTTP/1.1 202 Accepted
Date: Thu, 20 Mar 2014 11:16:47 GMT
Server: Apache/2.4.6 (Fedora) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5
Content-Encoding: utf-8
Content-Length: 172
Content-Type: application/json

{"spawned_tasks": [{"_href": "/pulp/api/v2/tasks/93ea7f3d-347a-4fed-ba7d-dd71db83396b/", "task_id": "93ea7f3d-347a-4fed-ba7d-dd71db83396b"}], "result": null, "error": null}

]# curl -H "Accept: application/json" -X GET -k -u admin:admin  'https://ec2-54-217-78-7.eu-west-1.compute.amazonaws.com/pulp/api/v2/tasks/93ea7f3d-347a-4fed-ba7d-dd71db83396b/'|python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1324  100  1324    0     0   5281      0 --:--:-- --:--:-- --:--:--  5296
{
    "_href": "/pulp/api/v2/tasks/93ea7f3d-347a-4fed-ba7d-dd71db83396b/",
    "_id": {
        "$oid": "532ace1f6380d1e4b56c74b0"
    },
    "_ns": "task_status",
    "error": {
        "code": "PLP0009",
        "data": {
            "resources": {
                "resource_id": "unexistant_repo"
            }
        },
        "description": "Missing resource(s): resource_id=unexistant_repo",
        "sub_errors": []
    },
    "finish_time": 1395314207,
    "queue": "reserved_resource_worker-0.compute.internal",
    "start_time": 1395314207,
    "state": "error",
    "tags": [
        "pulp:repository:unexistant_repo",
        "pulp:repository_importer:yum_importer",
        "pulp:action:update_importer"
    ],
    "task_id": "93ea7f3d-347a-4fed-ba7d-dd71db83396b",
    "traceback": "Traceback (most recent call last):\n  File \"/usr/lib/python2.7/site-packages/celery/app/trace.py\", line 238, in trace_task\n    R = retval = fun(*args, **kwargs)\n  File \"/usr/lib/python2.7/site-packages/pulp/server/async/tasks.py\", line 369, in __call__\n    return super(Task, self).__call__(*args, **kwargs)\n  File \"/usr/lib/python2.7/site-packages/celery/app/trace.py\", line 416, in __protected_call__\n    return self.run(*args, **kwargs)\n  File \"/usr/lib/python2.7/site-packages/pulp/server/managers/repo/importer.py\", line 237, in update_importer_config\n    raise MissingResource(repo_id)\nMissingResource: Missing resource(s): resource_id=unexistant_repo\n"
}


This behaviour is a bit confusing and maybe it would be better if the update call will directly return 404 like in case with distributor update call:

# curl -i -H "Accept: application/json" -X PUT  -k -u admin:admin -d '{ "distributor_config":{"relative_url":"yyy"}}' 'https://example.com/pulp/api/v2/repositories/unexistant_repo/distributors/yum_distributor/'
HTTP/1.1 404 Not Found
Date: Thu, 20 Mar 2014 11:21:30 GMT
Server: Apache/2.4.6 (Fedora) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5
Content-Encoding: utf-8
Content-Length: 464
Content-Type: application/json
{
    "_href": "/pulp/api/v2/repositories/unexistant_repo/distributors/yum_distributor/",
    "error": {
        "code": "PLP0009",
        "data": {
            "resources": {
                "distributor": "yum_distributor"
            }
        },
        "description": "Missing resource(s): distributor=yum_distributor",
        "sub_errors": []
    },
    "error_message": "Missing resource(s): distributor=yum_distributor",
    "exception": null,
    "http_request_method": "PUT",
    "http_status": 404,
    "resources": {
        "distributor": "yum_distributor"
    },
    "traceback": null
}



Version-Release number of selected component (if applicable):

pulp-server-2.4.0-0.3.alpha.git.13.3215df6.fc20.noarch
How reproducible:
always

Steps to Reproduce:
1. update unexistant importer(or update importer of unexistant repo)
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Ina Panova 2014-03-20 11:39:51 UTC
Same behaviour with :
1)'association of importer to unexistant repo':
# curl -i -H "Accept: application/json" -X POST  -k -u admin:admin -d '{"importer_type_id":"yum_importer", "importer_config":{}}' 'https://example.com/pulp/api/v2/repositories/unexistant_repo/importers/'
HTTP/1.1 202 Accepted
Date: Thu, 20 Mar 2014 11:34:01 GMT
Server: Apache/2.4.6 (Fedora) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5
Content-Encoding: utf-8
Content-Length: 172
Content-Type: application/json

{"spawned_tasks": [{"_href": "/pulp/api/v2/tasks/329aacf1-b8d3-4ec5-92d5-10df8714b1ec/", "task_id": "329aacf1-b8d3-4ec5-92d5-10df8714b1ec"}], "result": null, "error": null}


2) 'disaasociate importer from unexistant repo':
# curl -i -H "Accept: application/json" -X DELETE  -k -u admin:admin 'https://example.com/pulp/api/v2/repositories/unexistant_repo/importers/yum_importer/'
HTTP/1.1 202 Accepted
Date: Thu, 20 Mar 2014 11:36:12 GMT
Server: Apache/2.4.6 (Fedora) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5
Content-Encoding: utf-8
Content-Length: 172
Content-Type: application/json

{"spawned_tasks": [{"_href": "/pulp/api/v2/tasks/69604e28-4485-4978-bade-a89d08092b1a/", "task_id": "69604e28-4485-4978-bade-a89d08092b1a"}], "result": null, "error": null}

Comment 2 Ina Panova 2014-04-03 14:26:14 UTC
see also https://bugzilla.redhat.com/show_bug.cgi?id=1084064

Comment 3 Jeremy Cline 2015-01-13 17:03:04 UTC
https://github.com/pulp/pulp/pull/1518

Comment 4 mkovacik 2015-02-03 21:01:51 UTC
Hi,

I've checked with pulp-server-2.6.0-0.5.beta.git.93.014a6ca.fc21.noarch and this seems fixed now --- is it expected in the beta build? If that's the case, I'll mark verified...

Comment 5 mkovacik 2015-02-05 18:05:53 UTC
pulled wrong pulp repo; all is OK

Comment 6 Brian Bouterse 2015-02-28 22:03:40 UTC
Moved to https://pulp.plan.io/issues/406


Note You need to log in before you can comment on or make changes to this bug.