Bug 755677 - failing to add a virt unlimited pool to an activation key
Summary: failing to add a virt unlimited pool to an activation key
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Candlepin
Classification: Community
Component: candlepin
Version: 0.5
Hardware: Unspecified
OS: Solaris
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Bryan Kearney
QA Contact: John Sefler
URL:
Whiteboard:
Depends On:
Blocks: rhsm-rhel62 715031
TreeView+ depends on / blocked
 
Reported: 2011-11-21 18:17 UTC by John Sefler
Modified: 2015-05-14 15:22 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-05-29 19:04:59 UTC
Embargoed:


Attachments (Terms of Use)

Description John Sefler 2011-11-21 18:17:03 UTC
Description of problem:
Our automated tests caught this bug against candlepin deployed with the TESTDATA...

Version-Release number of selected component (if applicable):
[root@jsefler-onprem-62candlepin proxy]# git branch
  0.3
* 0.4
  master
  testdata_cleanup
[root@jsefler-onprem-62candlepin proxy]# git show-ref refs/heads/0.4
f3a03451f01a0798dd9ad31ece6b35ec0bffb147 refs/heads/0.4




How reproducible:


Steps to Reproduce:
[root@jsefler-onprem-62server ~]# subscription-manager register --username testuser1 --password password --org admin
The system has been registered with id: e0413e27-27c8-42ae-b070-c61ec65b346f 

[root@jsefler-onprem-62server ~]# subscription-manager list --avail | grep awesomeos-virt-unlimited -B1 -A6
ProductName:       	Awesome OS with unlimited virtual guests
ProductId:         	awesomeos-virt-unlimited 
PoolId:            	8a90f80533c717ac0133c7193066032e
Quantity:          	10                       
Multi-Entitlement: 	No                       
Expires:           	11/19/2012               
MachineType:       	physical                 

--
ProductName:       	Awesome OS with unlimited virtual guests
ProductId:         	awesomeos-virt-unlimited 
PoolId:            	8a90f80533c717ac0133c71930900335
Quantity:          	unlimited                
Multi-Entitlement: 	No                       
Expires:           	11/19/2012               
MachineType:       	virtual                  

--
ProductName:       	Awesome OS with unlimited virtual guests
ProductId:         	awesomeos-virt-unlimited 
PoolId:            	8a90f80533c717ac0133c719310d0342
Quantity:          	5                        
Multi-Entitlement: 	No                       
Expires:           	11/19/2012               
MachineType:       	physical                 

--
ProductName:       	Awesome OS with unlimited virtual guests
ProductId:         	awesomeos-virt-unlimited 
PoolId:            	8a90f80533c717ac0133c71931450349
Quantity:          	unlimited                
Multi-Entitlement: 	No                       
Expires:           	11/19/2012               
MachineType:       	virtual                  

[root@jsefler-onprem-62server ~]# curl --insecure --user admin:admin --request POST --data '{"name":"MyActivationKey108"}' --header 'accept: application/json' --header 'content-type: application/json' https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
153   277    0   277    0    29   1292    135 --:--:-- --:--:-- --:--:--  2818
{
    "created": "2011-11-21T18:06:40.216+0000", 
    "id": "8a90f80533c717ac0133c74ef4580f73", 
    "name": "MyActivationKey108", 
    "owner": {
        "displayName": "Admin Owner", 
        "href": "/owners/admin", 
        "id": "8a90f80533c717ac0133c7183d5a0006", 
        "key": "admin"
    }, 
    "pools": [], 
    "updated": "2011-11-21T18:06:40.216+0000"
}


[root@jsefler-onprem-62server ~]# curl --insecure --user testuser1:password --request POST https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/activation_keys/8a90f80533c717ac0133c74ef4580f73/pools/8a90f80533c717ac0133c71930900335 | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0    89    0    89    0     0    522      0 --:--:-- --:--:-- --:--:--  1202
{
    "displayMessage": "The quantity must not be greater than the total allowed for the pool"
}

^^^ THE CURL STATEMENT ABOVE IS TRYING TO ADD THE DEFAULT QUANTITY (1) OF POOL 8a90f80533c717ac0133c71930900335 TO THE PRIOR CREATED ACTIVATION KEY.  I EXPECT THIS TO SUCCEED, BUT IT IS BLOCKED BY EXCEPTION IN THE displayMessage ABOVE.



Additional info:

[root@jsefler-onprem-62candlepin proxy]# tail -f /var/log/tomcat6/catalina.out
Nov 21 13:15:04 [http-8443-1] ERROR org.fedoraproject.candlepin.exceptions.CandlepinExceptionMapper - Runtime exception:
org.fedoraproject.candlepin.exceptions.BadRequestException: The quantity must not be greater than the total allowed for the pool
	at org.fedoraproject.candlepin.resource.ActivationKeyResource.addPoolToKey(ActivationKeyResource.java:161)
	at org.fedoraproject.candlepin.resource.ActivationKeyResource$$EnhancerByGuice$$5c0ec59f.CGLIB$addPoolToKey$3(<generated>)
	at org.fedoraproject.candlepin.resource.ActivationKeyResource$$EnhancerByGuice$$5c0ec59f$$FastClassByGuice$$56d3b54f.invoke(<generated>)
	at com.google.inject.internal.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:64)
	at org.fedoraproject.candlepin.auth.interceptor.SecurityInterceptor.invoke(SecurityInterceptor.java:112)
	at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:64)
	at com.google.inject.InterceptorStackCallback.intercept(InterceptorStackCallback.java:44)
	at org.fedoraproject.candlepin.resource.ActivationKeyResource$$EnhancerByGuice$$5c0ec59f.addPoolToKey(<generated>)
	at sun.reflect.GeneratedMethodAccessor339.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
	at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:255)
	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220)
	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209)
	at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:216)
	at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:141)
	at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:93)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:63)
	at org.fedoraproject.candlepin.servlet.filter.ContentTypeHackFilter.doFilter(ContentTypeHackFilter.java:61)
	at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:129)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:59)
	at org.fedoraproject.candlepin.servlet.filter.VersionFilter.doFilter(VersionFilter.java:47)
	at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:129)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:59)
	at org.fedoraproject.candlepin.servlet.filter.logging.LoggingFilter.doFilter(LoggingFilter.java:60)
	at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:129)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:59)
	at com.wideplay.warp.persist.PersistenceFilter$3.run(PersistenceFilter.java:141)
	at com.wideplay.warp.persist.internal.Lifecycles.failEarlyAndLeaveNoOneBehind(Lifecycles.java:29)
	at com.wideplay.warp.persist.PersistenceFilter.doFilter(PersistenceFilter.java:155)
	at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:129)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:59)
	at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:122)
	at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:110)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:679)

Comment 1 Bryan Kearney 2011-11-28 14:11:44 UTC
Fixed in master (0.5.X) at 321b64f404fc30b09874b45e767b222b835e2bc8.

-- bk

Comment 2 John Sefler 2011-12-08 20:37:50 UTC
Verifying Version...
[root@jsefler-f14-5candlepin candlepin]# curl -k https://jsefler-f14-5candlepin.usersys.redhat.com:8443/candlepin/status
{"version":"0.5.5","result":true,"standalone":false,"release":"1"}
[root@jsefler-f14-5candlepin candlepin]# git branch
  0.2
  0.3
  0.4
* master
[root@jsefler-f14-5candlepin candlepin]# git show-ref | grep master
0cae7cf572ae4685dde6f80696238129cf8677db refs/heads/master
0cae7cf572ae4685dde6f80696238129cf8677db refs/remotes/origin/master

NOTE:^ Candlepin was restarted with /etc/candlepin/candlepin.conf => candlepin.standalone = false  and then the admin pools were refreshed



REGISTERING A CLIENT TO FIND A POOL ID WITH UNLIMITED ENTITLEMENTS...

[root@jsefler-onprem-5server ~]# subscription-manager register --username testuser1 --password password --org admin --force
The system has been registered with id: 0b2872e7-199a-4d86-a5f2-4b252edb69c0 
[root@jsefler-onprem-5server ~]# subscription-manager list --avail | grep awesomeos-virt-unlimited -B1 -A6
ProductName:          	Awesome OS with unlimited virtual guests
ProductId:            	awesomeos-virt-unlimited 
PoolId:               	8a90f857341b34e501341b35bd0501e1
Quantity:             	9                        
Multi-Entitlement:    	No                       
Expires:              	01/05/2013               
MachineType:          	physical                 

ProductName:          	Awesome OS with unlimited virtual guests
ProductId:            	awesomeos-virt-unlimited 
PoolId:               	8a90f857341b34e501341b35bd2d01e8
Quantity:             	5                        
Multi-Entitlement:    	No                       
Expires:              	01/05/2013               
MachineType:          	physical                 

--
ProductName:          	Awesome OS with unlimited virtual guests
ProductId:            	awesomeos-virt-unlimited 
PoolId:               	8a90f857341b34e501341c9f047c66a3
Quantity:             	unlimited                
Multi-Entitlement:    	No                       
Expires:              	01/05/2013               
MachineType:          	virtual                  



CREATING AN ACTIVATION KEY...

[root@jsefler-onprem-5server ~]# curl --insecure --user admin:admin --request POST --data '{"name":"MyActivationKey"}' --header 'accept: application/json' --header 'content-type: application/json' https://jsefler-f14-5candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -m simplejson/tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   274    0   274    0     0   1188      0 --:--:-- --:--:-- --:--:--     0
{
    "created": "2011-12-08T20:21:16.078+0000", 
    "id": "8a90f857341f4e9201341f564aae002b", 
    "name": "MyActivationKey", 
    "owner": {
        "displayName": "Admin Owner", 
        "href": "/owners/admin", 
        "id": "8a90f857341b34e501341b3521690007", 
        "key": "admin"
    }, 
    "pools": [], 
    "updated": "2011-12-08T20:21:16.078+0000"
}


ADDING THE UNLIMITED POOL TO THE KEY...

[root@jsefler-onprem-5server ~]# curl --insecure --user admin:admin --request POST https://jsefler-f14-5candlepin.usersys.redhat.com:8443/candlepin/activation_keys/8a90f857341f4e9201341f564aae002b/pools/8a90f857341b34e501341c9f047c66a3 | python -m simplejson/tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2683    0  2683    0     0   9106      0 --:--:-- --:--:-- --:--:--     0
{
    "accountNumber": "12331131231", 
    "activeSubscription": true, 
    "attributes": [
        {
            "created": "2011-12-08T07:41:50.588+0000", 
            "id": "8a90f857341b34e501341c9f047c66a4", 
            "name": "requires_host", 
            "updated": "2011-12-08T07:41:50.588+0000", 
            "value": "50464efc-1b18-4961-95ba-e620fe2437b8"
        }, 
        {
            "created": "2011-12-08T07:41:50.588+0000", 
            "id": "8a90f857341b34e501341c9f047c66a5", 
            "name": "requires_consumer_type", 
            "updated": "2011-12-08T07:41:50.588+0000", 
            "value": "system"
        }, 
        {
            "created": "2011-12-08T07:41:50.589+0000", 
            "id": "8a90f857341b34e501341c9f047d66a7", 
            "name": "pool_derived", 
            "updated": "2011-12-08T07:41:50.589+0000", 
            "value": "true"
        }, 
        {
            "created": "2011-12-08T07:41:50.588+0000", 
            "id": "8a90f857341b34e501341c9f047c66a6", 
            "name": "virt_only", 
            "updated": "2011-12-08T07:41:50.588+0000", 
            "value": "true"
        }
    ], 
    "consumed": 0, 
    "contractNumber": "37", 
    "created": "2011-12-08T07:41:50.588+0000", 
    "endDate": "2013-01-05T05:00:00.000+0000", 
    "exported": 0, 
    "href": "/pools/8a90f857341b34e501341c9f047c66a3", 
    "id": "8a90f857341b34e501341c9f047c66a3", 
    "owner": {
        "displayName": "Admin Owner", 
        "href": "/owners/admin", 
        "id": "8a90f857341b34e501341b3521690007", 
        "key": "admin"
    }, 
    "productAttributes": [
        {
            "created": "2011-12-08T08:29:51.238+0000", 
            "id": "8a90f857341b34e501341ccaf9076fa6", 
            "name": "type", 
            "productId": "awesomeos-virt-unlimited", 
            "updated": "2011-12-08T08:29:51.238+0000", 
            "value": "MKT"
        }, 
        {
            "created": "2011-12-08T08:29:51.239+0000", 
            "id": "8a90f857341b34e501341ccaf9076fa7", 
            "name": "arch", 
            "productId": "awesomeos-virt-unlimited", 
            "updated": "2011-12-08T08:29:51.239+0000", 
            "value": "ALL"
        }, 
        {
            "created": "2011-12-08T08:29:51.239+0000", 
            "id": "8a90f857341b34e501341ccaf9076fa8", 
            "name": "version", 
            "productId": "awesomeos-virt-unlimited", 
            "updated": "2011-12-08T08:29:51.239+0000", 
            "value": "6.1"
        }, 
        {
            "created": "2011-12-08T08:29:51.239+0000", 
            "id": "8a90f857341b34e501341ccaf9076fa9", 
            "name": "virt_limit", 
            "productId": "awesomeos-virt-unlimited", 
            "updated": "2011-12-08T08:29:51.239+0000", 
            "value": "unlimited"
        }, 
        {
            "created": "2011-12-08T08:29:51.239+0000", 
            "id": "8a90f857341b34e501341ccaf9076faa", 
            "name": "variant", 
            "productId": "awesomeos-virt-unlimited", 
            "updated": "2011-12-08T08:29:51.239+0000", 
            "value": "ALL"
        }
    ], 
    "productId": "awesomeos-virt-unlimited", 
    "productName": "Awesome OS with unlimited virtual guests", 
    "providedProducts": [
        {
            "created": "2011-12-08T07:41:50.589+0000", 
            "id": "8a90f857341b34e501341c9f047d66a8", 
            "productId": "37060", 
            "productName": "Awesome OS Server Bits", 
            "updated": "2011-12-08T07:41:50.589+0000"
        }
    ], 
    "quantity": -1, 
    "restrictedToUsername": null, 
    "sourceEntitlement": {
        "href": "/entitlements/8a90f857341b34e501341c9f047a66a2", 
        "id": "8a90f857341b34e501341c9f047a66a2"
    }, 
    "startDate": "2011-11-06T04:00:00.000+0000", 
    "subscriptionId": "8a90f857341b34e501341b35b0470188", 
    "updated": "2011-12-08T10:57:49.649+0000"
}

^ SUCCESS!  THAT VERIFYING THE BUG FIX.  LET'S DO LITTLE MORE TESTING...
VERIFYING THAT THE ACTIVATION KEY CONTAINS THE ADDED POOL...

[root@jsefler-onprem-5server ~]# curl --insecure --user admin:admin --request GET https://jsefler-f14-5candlepin.usersys.redhat.com:8443/candlepin/activation_keys/8a90f857341f4e9201341f564aae002b | python -m simplejson/tool  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   508    0   508    0     0   2432      0 --:--:-- --:--:-- --:--:--     0
{
    "created": "2011-12-08T20:21:16.078+0000", 
    "id": "8a90f857341f4e9201341f564aae002b", 
    "name": "MyActivationKey", 
    "owner": {
        "displayName": "Admin Owner", 
        "href": "/owners/admin", 
        "id": "8a90f857341b34e501341b3521690007", 
        "key": "admin"
    }, 
    "pools": [
        {
            "created": "2011-12-08T20:24:25.982+0000", 
            "id": "8a90f857341f4e9201341f59307e002d", 
            "pool": {
                "href": "/pools/8a90f857341b34e501341c9f047c66a3", 
                "id": "8a90f857341b34e501341c9f047c66a3"
            }, 
            "quantity": 1, 
            "updated": "2011-12-08T20:24:25.982+0000"
        }
    ], 
    "updated": "2011-12-08T20:21:16.078+0000"
}


NOW LET'S REGISTER WITH THE ACTIVATION KEY...

[root@jsefler-onprem-5server ~]# subscription-manager unregister
System has been un-registered.
[root@jsefler-onprem-5server ~]# subscription-manager register --org admin --activationkey MyActivationKey
The system has been registered with id: 5b146a05-ffab-4484-b3db-169f3249ff33 

AND ASSERT THAT AN ENTITLEMENT IS BEING CONSUMED FROM THE POOL...

[root@jsefler-onprem-5server ~]# subscription-manager list --consumed
+-------------------------------------------+
    Consumed Product Subscriptions
+-------------------------------------------+

ProductName:          	Awesome OS Server Bits   
ContractNumber:       	37                       
AccountNumber:        	12331131231              
SerialNumber:         	8555816908660056637      
Active:               	True                     
QuantityUsed:         	1                        
Begins:               	11/06/2011               
Expires:              	01/05/2013               

[root@jsefler-onprem-5server ~]# 


Moving to VERIFIED


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