Bug 1048988 - [plugins] [api] add a hook for MD refresh
[plugins] [api] add a hook for MD refresh
Product: Fedora
Classification: Fedora
Component: dnf (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Ales Kozumplik
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2014-01-06 12:21 EST by Elad Alfassa
Modified: 2014-09-30 19:42 EDT (History)
5 users (show)

See Also:
Fixed In Version: dnf-0.4.11-1.fc20
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2014-01-11 03:48:04 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Elad Alfassa 2014-01-06 12:21:00 EST
For the bash completion plugin, I'd need a hook that will be called every time makecache completes.

Also, if someone runs dnf makecache --cacheonly, dnf should not download anything but run the hook anyway. This will allow the completion plugin to generate the cache it needs if the completion cache does not exist but dnf does have downloaded repository information stored.
Comment 1 Ales Kozumplik 2014-01-06 12:27:40 EST
Elad, I thought the hook would be for any time the MD refresh happens, no? Some people never run makecache FWIW. I might have confused you about disliking the time penalty: I don't mind adding a few ms to every run where new metadata is downloaded, I just don't like adding a few ms to *every run*.
Comment 2 Elad Alfassa 2014-01-06 12:39:18 EST
> I just don't like adding a few ms to *every run*.

neither do I.

> I thought the hook would be for any time the MD refresh happens, no?

You said that's hard. I suggested makecache as a compromise. The timer also runs makecache, so if we assume most people will not turn it off those few ms will be added to a background process, which means users won't notice the slowness, and it'd be also easier for you to implement.

Anyway, I'm okay with having that hook on MD refresh OR every time makecache is run. Either is fine for my use.
Comment 3 Ales Kozumplik 2014-01-07 10:20:59 EST

I just looked at your plugin in detail, you do:

  available_packages = self.base.sack.query().available()

Which means you'll still have to wait for the sack() trigger to fire because you need the sack to be ready. So I guess what we really need is a way to determine if any MD has been updated during while the sack was built, rather then the hook. Admittedly a combination of the two can yield the same results but I think being able to tell where we got the MD from (cache vs. origin) is useful for more API clients then the refresh hook.
Comment 4 Elad Alfassa 2014-01-07 11:18:17 EST
Makes sense, but need to make sure this value will be set to "origin" even if just one repo was updated.
Comment 5 Ales Kozumplik 2014-01-07 12:07:51 EST
this value is now set per-repo (repo.metadata.fresh), see 7e793fc.
Comment 6 Elad Alfassa 2014-01-07 13:53:22 EST
So I should loop on every enabled repo, and if repo.metadata.fresh is set, regen the cache?
Comment 7 Ales Kozumplik 2014-01-08 02:49:25 EST
Comment 8 Fedora Update System 2014-01-09 09:40:28 EST
dnf-0.4.11-1.fc20 has been submitted as an update for Fedora 20.
Comment 9 Fedora Update System 2014-01-10 03:00:11 EST
Package dnf-0.4.11-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-0.4.11-1.fc20'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).
Comment 10 Fedora Update System 2014-01-11 03:48:04 EST
dnf-0.4.11-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.