Bug 683220

Summary: Need an error message Adding a consumer with a key-value pair to a group with the same key defined is allowed
Product: [Retired] Pulp Reporter: Preethi Thomas <pthomas>
Component: z_otherAssignee: Pradeep Kilambi <pkilambi>
Status: CLOSED CURRENTRELEASE QA Contact: Preethi Thomas <pthomas>
Severity: medium Docs Contact:
Priority: low    
Version: unspecifiedCC: jason.dobies, jconnor, jortel, skarmark
Target Milestone: ---Keywords: Triaged
Target Release: Sprint 22   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 669213 Environment:
Last Closed: 2011-08-16 12:11:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 647488    

Description Preethi Thomas 2011-03-08 21:07:05 UTC
+++ This bug was initially created as a clone of Bug #669213 +++

By the end of the following, it shows that `consumer list` and `consumer get_keyvalues` are returning two different values for the key "jdob".


$ pulp-admin consumergroup list
+------------------------------------------+
      List of Available Consumer Groups
+------------------------------------------+

Id                 	test-group               
Description        	Test Consumer Group      
Consumer ids       	[]                       
Additional info    	{'jdob': 'group-value'}  



 -> sudo pulp-admin consumer list
+------------------------------------------+
            Consumer Information
+------------------------------------------+

Id                 	foo                      
Description        	None                     
Subscribed Repos   	/pulp/api/consumers/foo/repoids/
Additional info    	                         


 -> sudo pulp-admin consumer add_keyvalue --id foo --key jdob --value consumer-value
Successfully added key-value pair jdob:consumer-value


 -> sudo pulp-admin consumer list
+------------------------------------------+
            Consumer Information
+------------------------------------------+

Id                 	foo                      
Description        	None                     
Subscribed Repos   	/pulp/api/consumers/foo/repoids/
Additional info    	jdob  :  consumer-value, 


 -> sudo pulp-admin consumergroup add_consumer --id test-group --consumerid foo
Successfully added consumer [foo] to group [test-group]


 -> sudo pulp-admin consumer get_keyvalues --id foo
+------------------------------------------+
             Consumer Key-values
+------------------------------------------+

	KEY            :	VALUE          

--------------------------------------------

	jdob           :	group-value    


$ pulp-admin consumer list
+------------------------------------------+
            Consumer Information
+------------------------------------------+

Id                 	foo                      
Description        	None                     
Subscribed Repos   	/pulp/api/consumers/foo/repoids/
Additional info    	jdob  :  consumer-value,

--- Additional comment from skarmark on 2011-02-22 14:29:59 EST ---

Fixed:

Raising PulpException when trying to add a consumer with conflicting keyvalues.
 
$ sudo pulp-admin consumergroup add_consumer --id=mygroup --consumerid=consumer2
error: operation failed: Traceback (most recent call last):
  File "/home/skarmark/git/pulp/src/pulp/server/webservices/controllers/base.py", line 52, in report_error
    return method(self, *args, **kwargs)
  File "/home/skarmark/git/pulp/src/pulp/server/compat.py", line 40, in _decorator
    return decorator(*args,**kwargs)
  File "/home/skarmark/git/pulp/src/pulp/server/webservices/controllers/base.py", line 131, in _auth_decorator
    value = method(self, *args, **kwargs)
  File "/home/skarmark/git/pulp/src/pulp/server/webservices/controllers/consumergroups.py", line 248, in POST
    return action(id)
  File "/home/skarmark/git/pulp/src/pulp/server/webservices/controllers/consumergroups.py", line 185, in add_consumer
    api.add_consumer(id, data)
  File "/home/skarmark/git/pulp/src/pulp/server/compat.py", line 40, in _decorator
    return decorator(*args,**kwargs)
  File "/home/skarmark/git/pulp/src/pulp/server/auditing.py", line 207, in _audit
    result = method(*args, **kwargs)
  File "/home/skarmark/git/pulp/src/pulp/server/api/consumer_group.py", line 107, in add_consumer
    'in order to add it to this consumergroup: %s', consumerid, groupid, conflicting_keyvalues)
PulpException: u"Consumer [consumer2] cannot be added to consumergroup [mygroup] because of the following conflicting key-value pairs. You need to delete these key-values from the consumer in order to add it to this consumergroup: {u'key2': u'bla'}"

--- Additional comment from jortel on 2011-02-23 12:57:11 EST ---

Build: 0.141

--- Additional comment from pthomas on 2011-03-08 15:17:49 EST ---

Failing this

[root@nec-em8 upload]# rpm -q pulp
pulp-0.0.145-1
. 
Looks like the error needs to be raised all the way back up to the CLI.

From the log

2011-03-08 15:15:07,612 [ERROR][Dummy-2] @ base.py:56 - Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/pulp/server/webservices/controllers/base.py", line 52, in report_error
    return method(self, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/pulp/server/compat.py", line 40, in _decorator
    return decorator(*args,**kwargs)
  File "/usr/lib/python2.4/site-packages/pulp/server/webservices/controllers/base.py", line 131, in _auth_decorator
    value = method(self, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/pulp/server/webservices/controllers/consumergroups.py", line 248, in POST
    return action(id)
  File "/usr/lib/python2.4/site-packages/pulp/server/webservices/controllers/consumergroups.py", line 185, in add_consumer
    api.add_consumer(id, data)
  File "/usr/lib/python2.4/site-packages/pulp/server/compat.py", line 40, in _decorator
    return decorator(*args,**kwargs)
  File "/usr/lib/python2.4/site-packages/pulp/server/auditing.py", line 207, in _audit
    result = method(*args, **kwargs)
  File "/usr/lib/python2.4/site-packages/pulp/server/api/consumer_group.py", line 107, in add_consumer
    'in order to add it to this consumergroup: %s', consumerid, groupid, conflicting_keyvalues)
PulpException: u"Consumer [foo] cannot be added to consumergroup [test-group] because of the following conflicting key-value pairs. You need to delete these key-values from the consumer in order to add it to this consumergroup: {u'preethi': u'consumer-value'}"

--- Additional comment from skarmark on 2011-03-08 15:47:39 EST ---

Original bug is fixed and it is raising correct exception. This is more of an exception handling bug. 

Preethi, can you verify this bug and open up a new one for a better error message so I can align it to exception handling tracker?

Comment 1 Sayli Karmarkar 2011-03-25 07:07:07 UTC
This is fixed.

Comment 2 Preethi Thomas 2011-03-25 19:01:15 UTC
verified
[root@preethi ~]# rpm -q pulp
pulp-0.0.157-1.git.1.1ea502c.fc14.noarch


[root@preethi ~]# pulp-admin consumergroup add_consumer --id test-group --consumerid preethi.usersys.redhat.com
error: operation failed: PulpException: u"Consumer [preethi.usersys.redhat.com] cannot be added to consumergroup [test-group] because of the following conflicting key-value pairs. You need to delete these key-values from the consumer in order to add it to this consumergroup: {u'preethi': u'consumer-value'}"

Comment 3 Preethi Thomas 2011-08-16 12:11:03 UTC
Closing with Community Release 15

pulp-0.0.223-4.

Comment 4 Preethi Thomas 2011-08-16 12:22:44 UTC
Closing with Community Release 15

pulp-0.0.223-4.