Bug 655835

Summary: Pools are no longer removed after their expiration date
Product: [Community] Candlepin Reporter: Jeff Weiss <jweiss>
Component: candlepinAssignee: Bryan Kearney <bkearney>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: medium Docs Contact:
Priority: medium    
Version: 0.5CC: bkearney, dajohnso
Target Milestone: ---Keywords: QA-Closed
Target Release: ---   
Hardware: Unspecified   
OS: Solaris   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-02-23 21:51:36 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: 639436    

Description Jeff Weiss 2010-11-22 13:50:34 UTC
Description of problem:


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


How reproducible:


Steps to Reproduce:
1. run the following in irb (ruby REPL), from [$candlepin]/client/ruby :

require 'date'
require 'candlepin_api'

cp = Candlepin.new('admin', 'admin')

# Using donald duck owner
cp.create_subscription('donaldduck', 'MKT-simple-rhel-server-mkt', 5, ['37060'],
 '887673', Date.today - 60, (Time.now + (5*60)).strftime("%a, %d %b %Y %H:%M:%S
 %Z"))


2. That creates a subscription that expires 5 minutes from now.
3. Wait 5 minutes
4. run
 curl -k -u admin:admin https://localhost:8443/candlepin/owners 
to get donaldduck's userid, then
 curl -k -u admin:admin https://jweiss.usersys.redhat.com:8443/candlepin/pools?owner=[donaldduck's userid]
  
Actual results:
The pool that you created and has now expired it still listed.  In fact, you can go to a rhsm client and it'll be listed in list --all --available.  I have checked on my setup that 3 days later those expired pools are still there, so it's not just a matter of not waiting long enough

Expected results:
Pools should be removed as soon as they expire.

Additional info:

Comment 1 Ajay Kumar Nadathur Sreenivasan 2010-11-22 18:24:02 UTC
Nice catch!
Fix in: 
-------
[ajay@garuda-rh proxy{master}]$ git show-ref master
bdcb9b57923e730fa494dbabbaeac05ffae0be66 refs/heads/master
bdcb9b57923e730fa494dbabbaeac05ffae0be66 refs/remotes/origin/master

Comment 3 John Sefler 2011-01-07 22:50:46 UTC
[root@jsefler-f12-candlepin ruby]# irb
irb(main):001:0> require 'date'
=> true
irb(main):002:0> require 'candlepin_api'
=> true
irb(main):003:0> cp = Candlepin.new('admin', 'admin')
=> #<Candlepin:0xb728b894 @client=#<RestClient::Resource:0xb728b7f4 @block=nil, @options={:password=>"admin", :user=>"admin", :headers=>{:accept_language=>nil}}, @url="https://localhost:8443/candlepin">, @links={"status"=>"/status", "owners"=>"/owners", "pools"=>"/pools", "subscriptions"=>"/subscriptions", "products"=>"/products", "admin"=>"/admin", "subscriptiontokens"=>"/subscriptiontokens", "rules"=>"/rules", "events"=>"/events", "crl"=>"/crl", "content"=>"/content", "consumertypes"=>"/consumertypes", "consumers"=>"/consumers", "serials"=>"/serials", "entitlements"=>"/entitlements", "atom"=>"/atom"}, @lang=nil, @base_url="https://localhost:8443/candlepin">
irb(main):004:0> 
irb(main):005:0> 
irb(main):006:0> cp.create_subscription('donaldduck', 'MKT-simple-rhel-server-mkt', 5,['37060'],'887673','54321',Date.today - 60, (Time.now + (5*60)).strftime("%a, %d %b %Y %H:%M:%S %Z"))
=> {"providedProducts"=>[{"href"=>"/products/37060", "name"=>"RHEL for Physical Servers SVC", "multiplier"=>1, "productContent"=>[{"flexEntitlement"=>0, "physicalEntitlement"=>0, "enabled"=>true, "content"=>{"contentUrl"=>"/foo/path/always", "name"=>"always-enabled-content", "type"=>"yum", "id"=>"1", "created"=>"2011-01-07T19:43:05.863+0000", "vendor"=>"test-vendor", "updated"=>"2011-01-07T19:43:05.863+0000", "label"=>"always-enabled-content", "gpgUrl"=>"/foo/path/always/gpg"}}, {"flexEntitlement"=>0, "physicalEntitlement"=>0, "enabled"=>false, "content"=>{"contentUrl"=>"/foo/path/never", "name"=>"never-enabled-content", "type"=>"yum", "id"=>"0", "created"=>"2011-01-07T19:43:05.723+0000", "vendor"=>"test-vendor", "updated"=>"2011-01-07T19:43:05.723+0000", "label"=>"never-enabled-content", "gpgUrl"=>"/foo/path/never/gpg"}}, {"flexEntitlement"=>0, "physicalEntitlement"=>0, "enabled"=>true, "content"=>{"contentUrl"=>"/foo/path", "name"=>"content", "type"=>"yum", "id"=>"1111", "created"=>"2011-01-07T19:43:05.967+0000", "vendor"=>"test-vendor", "updated"=>"2011-01-07T19:43:05.967+0000", "label"=>"content-label", "gpgUrl"=>"/foo/path/gpg/"}}], "attributes"=>[{"name"=>"variant", "value"=>"ALL", "created"=>"2011-01-07T19:43:15.652+0000", "updated"=>"2011-01-07T19:43:15.652+0000"}, {"name"=>"arch", "value"=>"ALL", "created"=>"2011-01-07T19:43:15.652+0000", "updated"=>"2011-01-07T19:43:15.652+0000"}, {"name"=>"sockets", "value"=>"2", "created"=>"2011-01-07T19:43:15.652+0000", "updated"=>"2011-01-07T19:43:15.652+0000"}, {"name"=>"type", "value"=>"SVC", "created"=>"2011-01-07T19:43:15.653+0000", "updated"=>"2011-01-07T19:43:15.653+0000"}, {"name"=>"warning_period", "value"=>"30", "created"=>"2011-01-07T19:43:15.653+0000", "updated"=>"2011-01-07T19:43:15.653+0000"}, {"name"=>"version", "value"=>"6.1", "created"=>"2011-01-07T19:43:15.653+0000", "updated"=>"2011-01-07T19:43:15.653+0000"}], "id"=>"37060", "created"=>"2011-01-07T19:43:15.652+0000", "updated"=>"2011-01-07T19:43:15.652+0000"}], "certificate"=>nil, "modified"=>nil, "tokens"=>nil, "accountNumber"=>"54321", "quantity"=>5, "product"=>{"href"=>"/products/MKT-simple-rhel-server-mkt", "name"=>"Basic RHEL Server", "multiplier"=>1, "productContent"=>[], "attributes"=>[{"name"=>"version", "value"=>"1.0", "created"=>"2011-01-07T19:43:19.284+0000", "updated"=>"2011-01-07T19:43:19.284+0000"}, {"name"=>"variant", "value"=>"ALL", "created"=>"2011-01-07T19:43:19.285+0000", "updated"=>"2011-01-07T19:43:19.285+0000"}, {"name"=>"arch", "value"=>"ALL", "created"=>"2011-01-07T19:43:19.285+0000", "updated"=>"2011-01-07T19:43:19.285+0000"}, {"name"=>"sockets", "value"=>"2", "created"=>"2011-01-07T19:43:19.285+0000", "updated"=>"2011-01-07T19:43:19.285+0000"}, {"name"=>"type", "value"=>"MKT", "created"=>"2011-01-07T19:43:19.286+0000", "updated"=>"2011-01-07T19:43:19.286+0000"}, {"name"=>"warning_period", "value"=>"30", "created"=>"2011-01-07T19:43:19.286+0000", "updated"=>"2011-01-07T19:43:19.286+0000"}], "id"=>"MKT-simple-rhel-server-mkt", "created"=>"2011-01-07T19:43:19.284+0000", "updated"=>"2011-01-07T19:43:19.284+0000"}, "startDate"=>"2010-11-08T00:00:00.000+0000", "id"=>"ff8080812d620091012d629c5c6e0259", "upstreamPoolId"=>nil, "created"=>"2011-01-07T22:32:50.542+0000", "owner"=>{"href"=>"/owners/donaldduck", "id"=>"ff8080812d620091012d6200ee220012"}, "updated"=>"2011-01-07T22:32:50.542+0000", "contractNumber"=>"887673", "endDate"=>"2011-01-07T22:37:50.000+0000"}
irb(main):007:0> quit



[root@jsefler-f12-candlepin ruby]# curl -k -u admin:admin -n --request PUT https://jsefler-f12-candlepin.usersys.redhat.com:8443/candlepin/owners/donaldduck/subscriptions

^^^ REFRESH POOLS FOR donaldduck


[root@jsefler-f12-candlepin ruby]# curl -k -u admin:admin https://localhost:8443/candlepin/owners | grep -A1 donaldduck
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
102   821    0   821    0     0   2410      0 --:--:-- --:--:-- --:--:--  3297
  "key" : "donaldduck",
  "id" : "ff8080812d620091012d6200ee220012",
  "displayName" : "donaldduck",
  "parentOwner" : null,
  "href" : "/owners/donaldduck",
  "upstreamUuid" : null,
[root@jsefler-f12-candlepin ruby]# 

^^^ GOT donaldducks id


[root@jsefler-f12-candlepin ruby]# curl -k -u admin:admin https://jsefler-f12-candlepin.usersys.redhat.com:8443/candlepin/pools?owner=ff8080812d620091012d6200ee220012
[ {
  "id" : "ff8080812d620091012d629cefaf025a",
  "attributes" : [ ],
  "owner" : {
    "href" : "/owners/donaldduck",
    "id" : "ff8080812d620091012d6200ee220012"
  },
  "providedProducts" : [ {
    "id" : "ff8080812d620091012d629cefaf025b",
    "productId" : "37060",
    "productName" : "RHEL for Physical Servers SVC",
    "updated" : "2011-01-07T22:33:28.239+0000",
    "created" : "2011-01-07T22:33:28.239+0000"
  } ],
  "endDate" : "2011-01-07T22:37:50.000+0000",
  "startDate" : "2010-11-08T00:00:00.000+0000",
  "quantity" : 5,
  "contractNumber" : "887673",
  "accountNumber" : "54321",
  "subscriptionId" : "ff8080812d620091012d629c5c6e0259",
  "productId" : "MKT-simple-rhel-server-mkt",
  "href" : "/pools/ff8080812d620091012d629cefaf025a",
  "consumed" : 0,
  "sourceEntitlement" : null,
  "productName" : "Basic RHEL Server",
  "activeSubscription" : true,
  "restrictedToUsername" : null,
  "updated" : "2011-01-07T22:33:39.926+0000",
  "created" : "2011-01-07T22:33:28.239+0000"
} ]

^^^ YUP - THAT'S THE NEW POOL I CREATED AND IT LOOKS LIKE IT WILL EXPIRE IN 5 MIN FROM NOW.  WAITING 5 MIN....

[root@jsefler-f12-candlepin ruby]# curl -k -u admin:admin https://jsefler-f12-candlepin.usersys.redhat.com:8443/candlepin/pools?owner=ff8080812d620091012d6200ee220012
[ ]

^^^^ NO MORE POOL AFTER 5 MIN WAIT

MOVING TO VERIFIED...