spacewalk-api-scripts icon indicating copy to clipboard operation
spacewalk-api-scripts copied to clipboard

spacewalk-remove-old-packages -A / --all-channels

Open TJM opened this issue 9 years ago • 9 comments

It would be really nice if spacewalk-remove-old-packages had a -A / --all-channels option to parse through all channels. Currently I am looping through the output provided by spacecmd softwarechannel_list. I have seen another script that does loop through all channels, but it apparently requires Python 2.7 (seems kindof silly since spacewalk servers tend to be RHEL/CentOS and use 2.6 by default.

ANYHOW.. here is the "other" script: https://github.com/00willo/spacewalk-scripts

I like the way this one is laid out better (oh and it works on my spacewalk server) better.

I may take this on, but that depends on time available ;)

~tommy

TJM avatar Jan 15 '15 23:01 TJM

My "workaround" is:

for channel in $(spacecmd -q softwarechannel_list); do python spacewalk-remove-old-packages.py -f config -c $channel; done
spacewalk-data-fsck -r

TJM avatar Jan 16 '15 07:01 TJM

Hi, the intention was to provide a basic usage for one channel and script around that tool if more then one channels need to be deleted. However, if the need is there to put an --all option in there I will look at it (as soon as there is more time - no promises!)

angrox avatar Sep 22 '15 13:09 angrox

Hi.

There is a way to remove finally old packages from a channel? I can use spacewalk-remove-old-packages.py script to do it, but after a sync of the channel Spacewalk will download again the same old packages.

Please let me know, thanks. Morgan

mmarodin avatar Nov 16 '15 09:11 mmarodin

You cannot delete the packages from a channel which you sync on a regular base. The spacewalk-repo-sync will always sync all packages. The package remove script is only useful on cloned channels (to reduce metadata size).

angrox avatar Nov 19 '15 12:11 angrox

@mmarodin - I use the "filters" feature in the Repo settings to exclude older versions... for example on the "jenkinks-stable" repo (http://pkg.jenkins-ci.org/redhat-stable), which is way better than the main one (http://pkg.jenkins-ci.org/redhat/), it still has way more packages than I care to sync. They also tend to hang when trying to sync the older packages. I have a filter like -jenkins-1.4*,jenkins-1.5[0-7]* ... which effectively means I only see packages newer than jenkins-1.580. That was written a while ago, now I could probably just put -jenkins-[45]* because the stable builds are in the 600s :)

Jenkins is the one example I can think of, where they don't have a "-archive" repo and so they have every package since the beginning of time. Another way we used to do it (before spacewalk had the filter feature) was to use mrepo, and do a partial replication of whatever public repo we needed, then point spacewalk at mrepo.

TJM avatar Nov 19 '15 16:11 TJM

Would it be possible to add functionality where you can have a parameter to keep "n" number of packages? I have a scenario where we need to do cleanup on developer packages.. they may have for instance 100 versions of a package. We need to keep a certain number of those packages around in case of a rollback scenario, but we want to clean up the rest. I think the dry run option will allow me to start parsing through the output and I can figure out how to script the deletion while leaving "n" number in the channel. Just curious if this was something that could be added

djcloudy avatar May 10 '18 18:05 djcloudy

@djcloudy It would be possible, of course. Sadly I have other projects to do - if you could implement that I would happily accept the Pull Request

angrox avatar May 11 '18 13:05 angrox

@djcloudy @angrox

https://github.com/angrox/spacewalk-api-scripts/pull/33/files

The "max" option was there, just needed some code mangling to have it used in the logic while looping through the packages. It can now be easily wrapped in a shell script like below:

PKGNUM=1000
/usr/bin/python /usr/local/bin/spacewalk-remove-old-packages.py -A -d -c /etc/rhn/spacewalk-api.cfg -m "${PKGNUM}" | tee -a /var/log/spacewalk-remove-old-packages.py.log

sandwormusmc avatar Dec 18 '18 16:12 sandwormusmc

You cannot delete the packages from a channel which you sync on a regular base. The spacewalk-repo-sync will always sync all packages. The package remove script is only useful on cloned channels (to reduce metadata size).

As a workaround by clearing the cache spacecmd clear_caches you can delete packages you sync on regular basis.

Ansah7 avatar Oct 26 '20 20:10 Ansah7