Bug 874243 - Requesting package profile on consumer without a package profile results in error
Summary: Requesting package profile on consumer without a package profile results in e...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Pulp
Classification: Retired
Component: consumers
Version: 2.0.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: Sprint 42
Assignee: Jeff Ortel
QA Contact: Preethi Thomas
URL:
Whiteboard:
Depends On: 872724
Blocks: katello-v2-pulp
TreeView+ depends on / blocked
 
Reported: 2012-11-07 19:02 UTC by Preethi Thomas
Modified: 2013-01-09 17:05 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 872724
Environment:
Last Closed: 2013-01-09 17:05:34 UTC
Embargoed:


Attachments (Terms of Use)

Description Preethi Thomas 2012-11-07 19:02:12 UTC
Clone for 2.0 beta
+++ This bug was initially created as a clone of Bug #872724 +++

Description of problem:

Create a consumer
request a package profile  (GET /pulp/api/v2/consumers/ID/profiles/rpm/)

Gets an ISE (Exception below)



Version-Release number of selected component (if applicable):
pulp-server-0.0.335-1.fc16.noarch

How reproducible:
always



2012-11-02 16:07:09,034 2607:140552821511936: pulp.server.webservices.middleware.exception:ERROR: exception:63 Unhandled Exception
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/middleware/exception.py", line 44, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/middleware/postponed.py", line 39, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/web/application.py", line 278, in wsgi
    result = self.handle_with_processors()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 26, in _handle_with_processors
    return process(self.processors)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in process
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/web/application.py", line 557, in processor
    return handler()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in <lambda>
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in process
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/web/application.py", line 572, in processor
    result = handler()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in <lambda>
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 25, in process
    return self.handle()
  File "/usr/lib/python2.7/site-packages/web/application.py", line 232, in handle
    return self._delegate(fn, self.fvars, args)
  File "/usr/lib/python2.7/site-packages/web/application.py", line 413, in _delegate
    return f()
  File "/usr/lib/python2.7/site-packages/web/application.py", line 421, in <lambda>
    f = lambda: self._delegate_sub_application(pat, what)
  File "/usr/lib/python2.7/site-packages/web/application.py", line 446, in _delegate_sub_application
    return app.handle_with_processors()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 26, in _handle_with_processors
    return process(self.processors)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in process
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/web/application.py", line 557, in processor
    return handler()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in <lambda>
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in process
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/web/application.py", line 572, in processor
    result = handler()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in <lambda>
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 25, in process
    return self.handle()
  File "/usr/lib/python2.7/site-packages/web/application.py", line 232, in handle
    return self._delegate(fn, self.fvars, args)
  File "/usr/lib/python2.7/site-packages/web/application.py", line 395, in _delegate
    return handle_class(f)
  File "/usr/lib/python2.7/site-packages/web/application.py", line 386, in handle_class
    return tocall(*args)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/controllers/decorators.py", line 231, in _auth_decorator
    value = method(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/controllers/consumers.py", line 566, in GET
    serialized = serialization.consumer.profile(profile)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/serialization/consumer.py", line 27, in profile
    serialized = dict(profile)
TypeError: 'NoneType' object is not iterable

--- Additional comment from jsherril on 2012-11-02 16:18:42 EDT ---

I think it would make sense to return an empty array or a 404 (if it was not created).  A 500 doesn't seem correct though.

Comment 1 Jeff Ortel 2012-11-19 14:51:00 UTC
Updated to return 404 when the profile does not exist.

Comment 2 Jeff Ortel 2012-11-20 22:19:58 UTC
build: 2.0.6-0.3.beta

Comment 3 Jeff Ortel 2012-12-06 18:38:28 UTC
To test this:

Using the CLI, bind a consumer to a repository.  Then using pic do:

>>> from pprint import pprint
>>> from pulp.common import pic
>>> pic.connect() 
>>> pprint (pic.GET('/v2/tasks/'))
...
  {u'call_request_group_id': u'e3882d65-d687-45d1-8ad0-a3ef59156d81',
   u'call_request_id': u'e3b8ff4f-4cfb-4455-a8fc-dfe15d0ae47e',
   u'call_request_tags': [u'pulp:consumer:jortel',
                          u'pulp:repository:jeff',
                          u'pulp:repository_distributor:yum_distributor',
                          u'pulp:action:agent_bind'],
   u'dependency_failures': {},
   u'exception': None,
   u'finish_time': None,
   u'principal_login': u'SYSTEM',
   u'progress': {},
   u'reasons': [],
   u'response': u'accepted',
   u'result': None,
   u'schedule_id': None,
   u'start_time': u'2012-12-05T20:27:42Z',
   u'state': u'running',
   u'tags': [u'pulp:consumer:jortel',
             u'pulp:repository:jeff',
             u'pulp:repository_distributor:yum_distributor',
             u'pulp:action:agent_bind'],
   u'task_group_id': u'e3882d65-d687-45d1-8ad0-a3ef59156d81',
   u'task_id': u'e3b8ff4f-4cfb-4455-a8fc-dfe15d0ae47e',
   u'traceback': None}])
...

Note: the 'tags' attribute.

Repeat for unbind.

Comment 4 Jeff Ortel 2012-12-06 18:43:27 UTC
Updated wrong bug :(  Disregard #c3

Comment 5 Jeff Ortel 2012-12-06 18:51:13 UTC
To test this one, register a consumer but make sure the agent is not running.  This will ensure that no profile exits for the consumer.

Then using pic:

>>> pprint(pic.GET('/v2/consumers/jortel/profiles/rpm/'))
Response Body
{
  "exception": null, 
  "traceback": null, 
  "_href": "/pulp/api/v2/consumers/jortel/profiles/rpm/", 
  "error_message": "Missing resource(s): profile_id={'content_type': u'rpm', 'consumer_id': u'jortel'}", 
  "http_request_method": "GET", 
  "http_status": 404, 
  "resources": {
    "profile_id": {
      "content_type": "rpm", 
      "consumer_id": "jortel"
    }
  }
}

Note a 404.

Comment 6 Preethi Thomas 2012-12-06 19:30:27 UTC
verified

[root@preethi ~]# rpm -q pulp-server
pulp-server-2.0.6-0.11.beta.noarch
[root@preethi ~]#  python
Python 2.7.3 (default, Apr 30 2012, 21:18:11) 
[GCC 4.7.0 20120416 (Red Hat 4.7.0-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pprint import pprint
>>> from pulp.common import pic
>>> pic.connect() 
>>> pprint(pic.GET('/v2/consumers/jortel/profiles/rpm/'))
Response Body
{
  "exception": null, 
  "traceback": null, 
  "_href": "/pulp/api/v2/consumers/jortel/profiles/rpm/", 
  "error_message": "Missing resource(s): profile_id={'content_type': u'rpm', 'consumer_id': u'jortel'}", 
  "http_request_method": "GET", 
  "http_status": 404, 
  "resources": {
    "profile_id": {
      "content_type": "rpm", 
      "consumer_id": "jortel"
    }
  }
}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/pulp/common/pic.py", line 121, in GET
    return _request('GET', path)
  File "/usr/lib/python2.7/site-packages/pulp/common/pic.py", line 114, in _request
    (response.status, response_body))
pulp.common.pic.RequestError: Server response: 404
{u'exception': None, u'traceback': None, u'_href': u'/pulp/api/v2/consumers/jortel/profiles/rpm/', u'error_message': u"Missing resource(s): profile_id={'content_type': u'rpm', 'consumer_id': u'jortel'}", u'http_request_method': u'GET', u'http_status': 404, u'resources': {u'profile_id': {u'content_type': u'rpm', u'consumer_id': u'jortel'}}}
>>>

Comment 7 Preethi Thomas 2013-01-09 17:05:34 UTC
Pulp v2.0 released


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