Bug 672349

Summary: repo package count goes negative!
Product: [Retired] Pulp Reporter: Pradeep Kilambi <pkilambi>
Component: z_otherAssignee: John Matthews <jmatthew>
Status: CLOSED CURRENTRELEASE QA Contact: Preethi Thomas <pthomas>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: skarmark
Target Milestone: ---Keywords: Triaged
Target Release: Sprint 20   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-16 12:10:50 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 Pradeep Kilambi 2011-01-24 21:57:15 UTC
To speed things up we store the package_count in the db. But evidently the logic is buggy

* create a repo and add couple of packages

* delete these packages using repo delete_package command with some duplicates

* the count goes negative.. lol!

Id                 	testrepo2                
Name               	testrepo2                
FeedURL            	None                     
FeedType           	None                     
Arch               	noarch                   
Sync Schedule      	None                     
Packages           	-3                       
Files              	0                        
Distributions      	None                     
Publish            	True                     
Clones             	[]                       
Groups             	None      

The issue seems to be how remove_package api call is implemented:

        repo['packages'].pop(p['id'], None)
        repo['package_count'] = repo['package_count'] - 1
        self.objectdb.save(repo, safe=True)

so we try to pop and reduce the count by one.. but if this list has some duplicates, instead of checking if pop succeed or not, we reduce the count by 1 always.

Comment 1 John Matthews 2011-02-02 16:50:45 UTC
Fixed during changes for repo["packages"] from dictionary to list.

Comment 2 Jay Dobies 2011-02-02 20:07:08 UTC
Fixed in 0.134.

Comment 3 Preethi Thomas 2011-02-07 20:34:02 UTC
verified
[root@preethi ~]# rpm -q pulp
pulp-0.0.135-1.fc14.noarch


[root@preethi ~]# pulp-admin repo delete_package --id=upload-repo -p pulp-cds -ppulp-cds
['pulp-cds-0.0.121-1.fc14.noarch', 'pulp-cds-0.0.121-1.fc14.noarch'] [{'name': 'pulp-cds', 'checksum': {'sha256': '834fb545f765603e697ab016755f59afe48c22fb7a2e1411514a165b28ea36d8'}, 'repos': ['upload-repo'], 'filename': 'pulp-cds-0.0.121-1.fc14.noarch.rpm', 'epoch': '0', 'version': '0.0.121', 'release': '1.fc14', '_id': '3b24148c-ec5b-4fc4-a850-bd7796b3871f', 'arch': 'noarch', 'id': '3b24148c-ec5b-4fc4-a850-bd7796b3871f'}, {'name': 'pulp-cds', 'checksum': {'sha256': '834fb545f765603e697ab016755f59afe48c22fb7a2e1411514a165b28ea36d8'}, 'repos': ['upload-repo'], 'filename': 'pulp-cds-0.0.121-1.fc14.noarch.rpm', 'epoch': '0', 'version': '0.0.121', 'release': '1.fc14', '_id': '3b24148c-ec5b-4fc4-a850-bd7796b3871f', 'arch': 'noarch', 'id': '3b24148c-ec5b-4fc4-a850-bd7796b3871f'}]
No dependencies to process..
Successfully removed package ['pulp-cds-0.0.121-1.fc14.noarch.rpm'] from repo [upload-repo].

[root@preethi ~]# pulp-admin repo list
+------------------------------------------+
       List of Available Repositories
+------------------------------------------+



Id                 	upload-repo              
Name               	upload-repo              
FeedURL            	None                     
FeedType           	None                     
Arch               	noarch                   
Sync Schedule      	None                     
Packages           	0                        
Files              	0                        
Distributions      	None                     
Publish            	True                     
Clones             	[]                       
Groups             	None

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

pulp-0.0.223-4.

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

pulp-0.0.223-4.