Bug 678113

Summary: candlepin restAPI is failing to delete a subscription
Product: [Community] Candlepin Reporter: John Sefler <jsefler>
Component: candlepinAssignee: Devan Goodwin <dgoodwin>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 0.5CC: dgoodwin, spandey
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-30 20:44: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:
Bug Depends On:    
Bug Blocks: 568421    

Description John Sefler 2011-02-16 18:52:41 UTC
Description of problem:
after deploying a fresh on-premises candlepin server with TESTDATA=1, I am trying to delete a subscription (the one associated with a beav-blahblah pool) but I am getting this error:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><exceptionMessage><displayMessage>Runtime Error org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,569</displayMessage></exceptionMessage>


Version-Release number of selected component (if applicable):
[root@jsefler-f12-candlepin candlepin]# git branch
  ALPHA
* BETA
  master
[root@jsefler-f12-candlepin candlepin]# git show-ref BETA
379580b09a7e14d17a17b09fb665518dd0036b97 refs/heads/BETA
3b0042c82f8277ef3cc1e81771b0c19181721fa7 refs/remotes/origin/BETA


How reproducible:


Steps to Reproduce:

[root@jsefler-onprem01 ~]# subscription-manager register --username testuser1 --password password
6404b3e2-914e-4dca-a083-77d9990d2b63 jsefler-onprem01.usersys.redhat.com

[root@jsefler-onprem01 ~]# subscription-manager list --available | grep -A1 beav-blahblah
ProductId:         	beav-blahblah            
PoolId:            	ff8080812e2fb2cc012e2fb4502401e8
--
ProductId:         	beav-blahblah            
PoolId:            	ff8080812e2fb2cc012e2fb4503801eb

[root@jsefler-onprem01 ~]# curl -u admin:admin -k   https://jsefler-f12-candlepin.usersys.redhat.com:8443/candlepin/pools/ff8080812e2fb2cc012e2fb4503801eb
{
  "id" : "ff8080812e2fb2cc012e2fb4503801eb",
  "attributes" : [ ],
  "owner" : {
    "href" : "/owners/admin",
    "id" : "ff8080812e2fb2cc012e2fb2e1390005"
  },
  "providedProducts" : [ {
    "id" : "ff8080812e2fb2cc012e2fb4503901ec",
    "productName" : "PRAD390 Awesome OS for IBM s390x systems",
    "productId" : "100000000000000",
    "updated" : "2011-02-16T18:21:09.561+0000",
    "created" : "2011-02-16T18:21:09.561+0000"
  } ],
  "endDate" : "2012-02-16T00:00:00.000+0000",
  "startDate" : "2011-02-16T00:00:00.000+0000",
  "productName" : "Beav product with a dependency",
  "quantity" : 10,
  "contractNumber" : "34",
  "accountNumber" : "12331131231",
  "consumed" : 0,
  "subscriptionId" : "ff8080812e2fb2cc012e2fb438fd0103",
  "productId" : "beav-blahblah",
  "href" : "/pools/ff8080812e2fb2cc012e2fb4503801eb",
  "sourceEntitlement" : null,
  "activeSubscription" : true,
  "restrictedToUsername" : null,
  "updated" : "2011-02-16T18:21:09.560+0000",
  "created" : "2011-02-16T18:21:09.560+0000"
}

[root@jsefler-onprem01 ~]#curl -u admin:admin -k  --request DELETE https://jsefler-f12-candlepin.usersys.redhat.com:8443/candlepin/subscriptions/ff8080812e2fb2cc012e2fb438fd0103
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><exceptionMessage><displayMessage>Runtime Error org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,569</displayMessage></exceptionMessage>

^^^ I don't know how to interpret that error.  Nevertheless it blocked the attempt to delete a subscription.  Note that because the server was newly deployed, there should not have been any outstanding entitlements. 

  
Actual results:


Expected results:


Additional info:

Comment 1 Devan Goodwin 2011-03-02 17:39:23 UTC
Can't reproduce this yet, any chance you have the full tomcat trace?

Comment 2 Devan Goodwin 2011-03-02 18:10:55 UTC
Ignore that request, I found the problem, you need to create a subscription token associated with the subscription, then try to delete the sub. Fix incoming shortly.

Comment 3 Devan Goodwin 2011-03-02 18:56:59 UTC
Fixed in candlepin master: 8dce48accf27a548563519a2ad987b62d79d41b1
Will appear in: candlepin-0.2.10

Comment 4 John Sefler 2011-03-10 22:07:26 UTC
[root@jsefler-f14-candlepin candlepin]# git log | grep 8dce48accf27a548563519a2ad987b62d79d41b1
commit 8dce48accf27a548563519a2ad987b62d79d41b1
[root@jsefler-f14-candlepin candlepin]# git show-ref master
88a5ec56ab4b222377acf8a8cccdb3792e7292fb refs/heads/master
563c6c3b91c11d517e8f0de7d44f64133cbbb4df refs/remotes/origin/master



[root@jsefler-onprem03 ~]# subscription-manager register --username=testuser1 --password=password 
2318d74a-6b51-427d-9c96-59de9ff6635f jsefler-onprem03.usersys.redhat.com

[root@jsefler-onprem03 ~]# subscription-manager list --available --all | grep -A4 390
ProductName:       	Awesome OS for S390X     
ProductId:         	awesomeos-s390x          
PoolId:            	8a90f8b42ea1aeed012ea1af6c4e0168
Quantity:          	10                       
Expires:           	2012-03-08               

--
ProductName:       	Awesome OS for S390X     
ProductId:         	awesomeos-s390x          
PoolId:            	8a90f8b42ea1aeed012ea1af6c6c016b
Quantity:          	5                        
Expires:           	2012-03-08   



[root@jsefler-onprem03 ~]# curl -u admin:admin -k https://jsefler-f14-candlepin.usersys.redhat.com:8443/candlepin/pools/8a90f8b42ea1aeed012ea1af6c6c016b | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
104   838    0   838    0     0   3823      0 --:--:-- --:--:-- --:--:--  6925
{
    "accountNumber": "12331131231", 
    "activeSubscription": true, 
    "attributes": [], 
    "consumed": 0, 
    "contractNumber": "30", 
    "created": "2011-03-10T21:32:31.724+0000", 
    "endDate": "2012-03-09T00:00:00.000+0000", 
    "href": "/pools/8a90f8b42ea1aeed012ea1af6c6c016b", 
    "id": "8a90f8b42ea1aeed012ea1af6c6c016b", 
    "owner": {
        "href": "/owners/admin", 
        "id": "8a90f8b42ea1aeed012ea1af012a0005"
    }, 
    "productId": "awesomeos-s390x", 
    "productName": "Awesome OS for S390X", 
    "providedProducts": [
        {
            "created": "2011-03-10T21:32:31.724+0000", 
            "id": "8a90f8b42ea1aeed012ea1af6c6c016c", 
            "productId": "100000000000000", 
            "productName": "Awesome OS for S390X Bits", 
            "updated": "2011-03-10T21:32:31.724+0000"
        }
    ], 
    "quantity": 5, 
    "restrictedToUsername": null, 
    "sourceEntitlement": null, 
    "startDate": "2011-03-10T00:00:00.000+0000", 
    "subscriptionId": "8a90f8b42ea1aeed012ea1af59d700e5", 
    "updated": "2011-03-10T21:32:31.724+0000"
}

[root@jsefler-onprem03 ~]# curl -u admin:admin -k  --request DELETE https://jsefler-f14-candlepin.usersys.redhat.com:8443/candlepin/subscriptions/8a90f8b42ea1aeed012ea1af59d700e5

[root@jsefler-onprem03 ~]# curl -u admin:admin -k  --request PUT https://jsefler-f14-candlepin.usersys.redhat.com:8443/candlepin/owners/admin/subscriptions/ | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
140   280    0   280    0     0   2166      0 --:--:-- --:--:-- --:--:--  8235
{
    "created": "2011-03-10T22:04:12.128+0000", 
    "finishTime": null, 
    "id": "refresh_pools_b29182fc-1c39-4432-9714-d82498f5409a", 
    "result": null, 
    "startTime": null, 
    "state": "CREATED", 
    "statusPath": "/jobs/refresh_pools_b29182fc-1c39-4432-9714-d82498f5409a", 
    "updated": "2011-03-10T22:04:12.128+0000"
}
[root@jsefler-onprem03 ~]# subscription-manager list --available --all | grep 8a90f8b42ea1aeed012ea1af6c6c016b
[root@jsefler-onprem03 ~]# subscription-manager list --available --all | grep -A4 390ProductName:       	Awesome OS for S390X     
ProductId:         	awesomeos-s390x          
PoolId:            	8a90f8b42ea1aeed012ea1af6c4e0168
Quantity:          	10                       
Expires:           	2012-03-08   



Success! The api subscription delete subscription succeeded and after a refresh pools, the corresponding pool was gone.
 
moving to VERIFIED

Comment 5 John Sefler 2011-05-04 14:40:47 UTC
Group move of VERIFIED Candlepin component bugs to RELEASE_PENDING