"[Errno -1] Package does not match intended download" error when installing packages from Satellite server

Solution Verified - Updated -

Environment

  • Red Hat Network Satellite
  • Red Hat Enterprise Linux 5.x

Issue

  • While trying to install packages from i386 custom channel through satellite server, following error persists on client system:

    perl-Nagios-Plugin-0.33-1.el5.rf.noarch: failed to retrieve getPackage/perl-Nagios-Plugin-0.33-1.el5.rf.noarch.rpm from nagios_server_513 kB     00:00
    error was [Errno -1] Package does not match intended download
    
  • md5sum doesn't match

  • executing the "file" command on the rpm under /var/satellite on the server identifies the file as data, not as an RPM

Resolution

  • Run the following script on the Satellite server to find all packages in /var/satellite that do not have the expected checksum (md5sum or sha256sum when relevant) :
# python check-varsat.py
  • After reviewing the output, delete the corrupt files

  • Before running satellite-sync command, clear cache on satellite server by running following command:

# rm -fr /var/cache/rhn/satsync/*

Note : if the corruption repeats and you are using location aware updates on the satellite's rhn profile, disable it for a test to see if your problem comes from a bad mirror.

  • Re-sync the channels with the satellite-sync command, to restore the correct rpms :
# satellite-sync -c CHANNEL1 -c CHANNEL2

it is also possible to use a normal full sync :

# satellite-sync

the script check-varsat.py is a simple checksum checker which is attached to this article and offers you to remove the packages which do not have their expected checksum ; it is also available on this github

Alternative method

The checksum method works - but it involves reading all the content of all rpms, which can take a long time. This other method will only base itself on the data of the rpm files :

for i in `find /var/satellite -iname "*.rpm"`
do
        rpm -vK $i 2>&1 | grep -v $i | grep -q "error" && echo "$i is corrupt"
done

to list the rpms then

for i in `find /var/satellite -iname "*.rpm"`
do
        if rpm -vK $i 2>&1 | grep -v $i | grep -q "error"

        then

             rm -f $i

             echo "deleted corrupt rpm $i"

        fi
done

to remove them. However in some scenarios if the downloaded rpm is valid but not what was expected to be downloaded, this method won't pick it.

Root Cause

  • Packages (rpm) files corrupted or missing during download with satellite-sync.

Attachments

  • Component
  • rpm

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

4 Comments

Hello,

We has this problem, so I ran the first resolution script and I am very glad I did not run the second one! If a rpm has a siging error, it should be listed but rpm's with a "error" in it's name will also be listed!! Please correct the code fir script 1 to:

for i in `find /var/satellite -iname "*.rpm"`
do
        rpm -vK $i 2>&1 | grep -v $i | grep -q "error" && echo "$i is corrupt"
done

And for script 2 to:

for i in `find /var/satellite -iname "*.rpm"`
do
        if rpm -vK $i 2>&1 | grep -v $i | grep -q "error"

        then

             rm -f $i

             echo "deleted corrupt rpm $i"

        fi
done

Regards,

Ruud Hendricksen

Dutch Tax Office

Thank you very much for this information, I have committed it to the article.

The Script provided in clean\_varsat.py.zip works, anyway I didn't like that it also outputs all the file names with correct checksums and that it removes files with bad checksums immediately. So i enhanced the script a bit.

\#!/usr/bin/python
\#this script is intended to remove packages from /var/satellite when their intended md5sum (which can be found in the path) does not match the actual md5sum of the file. it will only work on Red Hat packages as of this version.
\# 2012-02-29 stephan.duehr@dass-it.de
\# the original version of this script comes from the Red Hat Knowledgebase Article
\# https://access.redhat.com/knowledge/solutions/41427 (Attachment clean\_varsat.py.zip)
\#
\# Enhancements:
\# - first only verify the checksums, displaying counters of ok and bad files found
\# - after all files are checked, display the list only of files with incorrect checksum
\# - let the user confirm the deletion of the listed files
\# - catch file deletion errors
\#path to the Red Hat data. edit this if you want to treat other packages
VARSAT="/var/satellite/redhat/NULL"
\#note : the full file path is VARSAT/XYZ/packagename/version/arch/md5sum/rpmfile.rpm
import os, hashlib, re, sys
def sumfile(fobj):
m = hashlib.md5()
while True:
d = fobj.read(8096)
if not d:
break
m.update(d)
return m.hexdigest()
def sum2file(fobj):
m = hashlib.sha256()
while True:
d = fobj.read(8096)
if not d:
break
m.update(d)
return m.hexdigest()
def yesno(prompt):
valid = {'y': True, 'n': False}
answer = raw\_input(prompt)
while answer not in valid.keys():
print "please answer with 'y' or 'n'"
answer = raw\_input(prompt)
return valid[answer]
print "script started, exploring the folders. this may take some time as each time a md5sum of the rpm files will be made."
print "checking all RPM files in " + VARSAT
print "ok count bad count"
\#layer 1 : the XYZ list
ok\_count = 0
bad\_count = 0
bad\_files = []
for entry\_layer1 in os.listdir(VARSAT):
currentpath\_l1=VARSAT+"/"+entry\_layer1
if os.path.isdir(currentpath\_l1) == True:
\#layer 2 : the packagename list
for entry\_layer2 in os.listdir(currentpath\_l1):
currentpath\_l2=currentpath\_l1+"/"+entry\_layer2
if os.path.isdir(currentpath\_l2) == True:
\#layer 3: list of versions
for entry\_layer3 in os.listdir(currentpath\_l2):
currentpath\_l3=currentpath\_l2+"/"+entry\_layer3
if os.path.isdir(currentpath\_l3) == True:
\#layer 4: list of archs
for entry\_layer4 in os.listdir(currentpath\_l3):
currentpath\_l4=currentpath\_l3+"/"+entry\_layer4
if os.path.isdir(currentpath\_l4) == True:
\#layer 5: the md5sums
for entry\_layer5 in os.listdir(currentpath\_l4):
currentpath\_l5=currentpath\_l4+"/"+entry\_layer5
if os.path.isdir(currentpath\_l5) == True:
\#layer 6 : the rpm files
for entry\_layer6 in os.listdir(currentpath\_l5):
currentpath\_l6=currentpath\_l5+"/"+entry\_layer6
f = open(currentpath\_l6,'rb')
if (len(entry\_layer5) == 32 and sumfile(f) != entry\_layer5):
bad\_files.append(currentpath_l6)
bad\_count += 1
elif(len(entry\_layer5) > 32 and sum2file(f) != entry\_layer5):
bad\_files.append(currentpath\_l6)
bad\_count += 1
else:
ok\_count += 1
sys.stdout.write("%12d %12d\\r" % (ok\_count, bad\_count))
sys.stdout.flush()
if bad\_files:
print "\\n\\nFound %d files with bad checksum:" % bad\_count
print "\\n".join(bad\_files)
sys.stdout.flush()
really\_delete = yesno("\\nReally delete all the files listed above (y/n)?")
if not really\_delete:
print "ok, exiting"
sys.exit(0)
for f in bad\_files:
print "deleting: " + f
try:
os.remove(f)
except OSError, e:
print "Error: %d (%s)" % (e.errno, e.strerror)
proceed = yesno("Continue (y/n)?")
if not proceed:
print "ok, exiting"
break
print "finished. Please run satellite-sync now if files were deleted."
else:
print "all files ok"

Thanks for the enhanced script - due to some rendering problems we're having I've gone ahead and attached it as a second file attachment to the article.