[et-mgmt-tools] Cobbler reposync cron script
Adrian Revill
adrian.revill at shazamteam.com
Fri Jun 13 13:14:31 UTC 2008
Not sure where to post this.
I think i have found a problem in cobbler reposync.
Sometimes if a rpm is partially downloaded and /usr/bin/reposync is stopped,
say by a collegue rebooting the server, grrr.
/usr/bin/reposync wont continue and throws an error untill the file is
deleted. e.g.
Traceback (most recent call last):
File "/usr/bin/reposync", line 264, in ?
main()
File "/usr/bin/reposync", line 245, in main
path = repo.getPackage(pkg)
File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 652, in
getPackage
cache=cache
File "/usr/lib/yum-plugins/rhnplugin.py", line 299, in _getFile
raise yum.Errors.RepoError, \
yum.Errors.RepoError: failed to retrieve
getPackage/openoffice.org-impress-2.0.4
-5.4.17.1.x86_64.rpm from rhel-x86_64-server-productivity-5
error was [Errno 9] Requested Range Not Satisfiable
cobbler reposync failed
This is not caught by my script because cobbler terminates with a return
code of 0, but cobbler knows it has failed.
Looking at action_reposync.py
rc = sub_process.call(cmd, shell=True)
if rc !=0:
raise CX(_("cobbler reposync failed"))
The return code from /usr/bin/reposync is being caught, but it looks like
what ever handles the exception raised does not pass it on.
Sorry my python is non existant so i cant follow it any further, any one
know how to make a quick fix?
Adrian Revill wrote:
>
> Yes feel free to add it.
>
> I tried the change to use "cobbler list repo" and it works fine.
>
>
> Michael DeHaan wrote:
>>
>> Adrian Revill wrote:
>>> Just in case anyone needs a script to run cobbler reposync from cron,
>>> here is one i have written. It runs each repo in turn, and gives each
>>> a number of tries (10) to over come problems with failing syncs.
>>>
>>> #!/bin/bash
>>>
>>> TRIES=10 # number of times to try and run reposync
>>> LOGFILE="/var/log/cobbler/cobbler_reposync.log"
>>>
>>> function running {
>>> PID=$(ps ax| awk '/cobbler reposync/ && !/awk/ {print ($1)}')
>>> if [ -z $PID ]
>>> then
>>> log "cobbler reposync is not running"
>>> return 1
>>> fi
>>> log "cobbler reposync is running PID=$PID"
>>> return 0
>>> }
>>>
>>> function log {
>>> logger -t "COBBLER_REPOSYNC" -- $1
>>> }
>>>
>>> function run {
>>> try=1
>>> ret=1
>>> while [ $try -le $TRIES ]
>>> do
>>> running
>>> ok=$?
>>> if [ $ok -eq 0 ]
>>> then
>>> log "Already running, aborting"
>>> break
>>> fi
>>> log "Attempt $try for $1"
>>> cobbler reposync --only=$1 2>&1 >> $LOGFILE
>>> ret=$?
>>> if [ $ret -eq 0 ]
>>> then
>>> break
>>> fi
>>> log "Attempt $try failed"
>>> try=$[ $try + 1 ]
>>> done
>>> if [ $ret -eq 0 ]
>>> then
>>> log "Compleated $1"
>>> else
>>> log "Too many trys or already running, giving up on $1"
>>>
>>> fi
>>> }
>>>
>>> log "Starting"
>>> mv $LOGFILE $LOGFILE.1
>>>
>>> for name in $(awk '/name:/ {print($2)}' /var/lib/cobbler/repos)
>>> do
>>> run $name
>>> done
>>>
>>> _______________________________________________
>>> et-mgmt-tools mailing list
>>> et-mgmt-tools at redhat.com
>>> https://www.redhat.com/mailman/listinfo/et-mgmt-tools
>>
>> Nice! Do you mind if I put this in a 'contrib' directory in cobbler's
>> version control so other people can find it later?
>>
>> We can mention this on the Wiki too.
>>
>> One small change I'd make is to make the last awk line run 'cobbler repo
>> list' instead of grepping the file, that way
>> it works regardless of the storage backend -- though everyone pretty
>> much uses the stock one.
>>
>> --Michael
>>
>> _______________________________________________
>> et-mgmt-tools mailing list
>> et-mgmt-tools at redhat.com
>> https://www.redhat.com/mailman/listinfo/et-mgmt-tools
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Cobbler-reposync-cron-script-tp17801508p17823138.html
Sent from the et-mgmt-tools mailing list archive at Nabble.com.
More information about the et-mgmt-tools
mailing list