Bug 1104995

Summary: yumdownloader can't download package when there's an oversize RPM in the destdir.
Product: Red Hat Enterprise Linux 7 Reporter: Karel Srot <ksrot>
Component: yum-utilsAssignee: Valentina Mukhamedzhanova <vmukhame>
Status: CLOSED ERRATA QA Contact: Karel Srot <ksrot>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: ksrot, vmukhame
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: yum-utils-1.1.31-26.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1004089 Environment:
Last Closed: 2015-03-05 09:03:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Karel Srot 2014-06-05 07:44:56 UTC
The bug is present on RHEL-7 too, tested with yum-utils-1.1.31-24.el7

Also, the behavior doesn't match the intended fix for RHEL-6,see bug 1004089 comments #c5 and #c7.

case 1:
I am missing the message '... already exists and appears to be complete' 
case 2: getting HTTP Error 416 - Requested Range Not Satisfiable while the package should be downloaded again.
case 3: getting Package does not match intended download. Suggestion: run yum --enablerepo=beaker-Server clean metadata  while the package should be downloaded again.

+++ This bug was initially created as a clone of Bug #1004089 +++

Description of problem:
When repo cache is disabled (e.g. as used in yumdownloader), YumRepository._getFile() would never check if a local file exists (both for metadata files and for RPMs), so the url is always passed to urlgrabber. The latter then finds that the target file on the local file system already exists and generates a GET with Range: header set to the size of the local file.

This of itself is a problem as it generates unnecessary HTTP load on the repo server, but it gets worse because curl doesn't check Content-Length header on receiving HTTP status 416 (https://tools.ietf.org/html/rfc2616#section-10.4.17), not to mention that some HTTP servers wouldn't add Content-Length header when returning 416. In that case, yum download fails and the requested packages are not installed.

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

How reproducible:
Always.

Steps to Reproduce:
1. Install yum-utils.
2. Download a package.rpm into a local directory dir.
3. Run yumdownloader --destdir=dir package

Actual results:
http://.../package.rpm: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 416 Requested Range Not Satisfiable"

Expected results:
dir/package.rpm already exists and appears to be complete

Additional info:
Attached patch makes this problem go away. I didn't check what the impact on use cases outside of the yumdownloader scenario outlined above is going to be.


--- Additional comment from Karel Srot on 2014-03-26 07:53:59 EDT ---

Testing the current behaviour with yum-utils-1.1.20-17 I am getting:

1. for local file smaller than the download:
Package does not match intended download. Suggestion: run yum clean metadata 

the message is not very descriptive and yum clean metadata won't help here.
Something like: rpm already exists but doesn't match the intended download but be better I guess

2. for already downloaded file:
xy.rpm already downloaded and appears to be complete

This is IMO OK

3. for a local file larger than the download:
The requested URL returned error: 416 Requested Range Not Satisfiable.


Could you please clarify how this is supposed to be fixed? I guess that the best option for 1. and 3. would be something similar to 2., e.g. just write that the local copy already exists but doesn't match

--- Additional comment from Valentina Mukhamedzhanova on 2014-03-28 09:47:31 EDT ---

This is supposed to work pretty much like in upstream, so in cases 1 and 3 the existing file will be deleted and a new one will be downloaded.

Comment 11 errata-xmlrpc 2015-03-05 09:03:15 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-0401.html