Bug 1373992

Summary: [RFE] repo configured using "baseurl" should only be re-downloaded when changed, just like repo with "metalink"
Product: [Fedora] Fedora Reporter: Alan Jenkins <alan.christopher.jenkins>
Component: dnfAssignee: Igor Gnatenko <ignatenko>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: ignatenko, jmracek, mluscon, packaging-team-maint, pnemade, rpm-software-management, vmukhame
Target Milestone: ---Keywords: Triaged, UserExperience
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-2.0.1-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-10 10:59:37 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:

Description Alan Jenkins 2016-09-07 15:43:55 UTC
Description of problem:

When baseurl is *not* used, dnf apparently checks whether the repo has changed, before re-downloading it.

When dnf is configured with a repo with a baseurl (i.e. for a local repo) and the cache passes it's maximum age, dnf has to download tens of megabytes.


Version-Release number of selected component (if applicable): 
dnf-1.1.10-1.fc24.noarch

How reproducible: always

Steps to Reproduce:
1. edit /etc/yum.repo.d/fedora.repo, comment out "metalink" and uncomment "baseurl"
2. dnf --refresh check-update
3. dnf --refresh check-update

Actual results:

Step 3 re-downloads 10s of megabytes, despite the repo not having changed since step 2.

Expected results:

Only repomd.xml needs to be re-downloaded to check for changes.


Additional info:

I noticed this after configuring my system with baseurl.  I checked the source code of dnf and found this code, which relies on metalink.

The check could be changed, or a check added, to re-download repomd.xml, if the file contents are identical then the existing cache can be re-used.


        if self.metadata or self._try_cache():
            if self.sync_strategy in (SYNC_ONLY_CACHE, SYNC_LAZY) or \
               not self._expired:
                logger.debug('repo: using cache for: %s', self.id)
                return False
        if self.sync_strategy == SYNC_ONLY_CACHE:
            msg = "Cache-only enabled but no cache for '%s'" % self.id
            raise dnf.exceptions.RepoError(msg)
        try:
            if self._try_revive():
                # the expired metadata still reflect the origin:
                self.metadata.reset_age()
                self._expired = False
                return True


    def _try_revive(self):
        """Use metalink to check whether our metadata are still current."""
        if not self.metadata:
            return False
        if not self.metalink:
            return False

Comment 2 Jaroslav Mracek 2017-03-10 10:59:37 UTC
Fixed in dnf-2.0.1-1 and released into rawhide