Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use a better heuristic for the apt update last run time #184

Merged

Conversation

anarcat
Copy link
Contributor

@anarcat anarcat commented Oct 17, 2023

As reported in #182, pkgcache.bin gets updated on more than just apt update. In particular, it gets modified when a package is installed, upgraded or removed.

So let's fallback on a better heuristic, which is the APT::Periodic timestamp. This should give us a much more precise and deliberate status.

We also fallback to the lists directory, which gets updated when new mirror lists gets moved into place. This does run the risk of staying silently unchanged if there's no change on mirrors but (a) that's rather infrequent and (b) we might actually want to warn on that anyway.

Closes: #183

@anarcat
Copy link
Contributor Author

anarcat commented Oct 17, 2023

@julian-klode could you review this? I think it covers the comments you made in #182...

@jcharaoui
Copy link

If APT::Periodic is used at some point, and then disabled, wouldn't this report a false metric if apt is updated in another manner?

@anarcat
Copy link
Contributor Author

anarcat commented Oct 17, 2023 via email

@anarcat anarcat force-pushed the apt-update-check-fine-tune branch from 88a2d30 to 598c352 Compare October 17, 2023 14:55
@jcharaoui
Copy link

On 2023-10-17 07:50:27, Jerome Charaoui wrote: If APT::Periodic is used at some point, and then disabled, wouldn't this report a false metric if apt is updated in another manner?
If it's disabled, the code won't check that timestamp file, unless I got this wrong.

Right, my bad!

@julian-klode
Copy link

I think you want to use get_b or what it's called in the config object that returns a boolean so that it parses everything correctly.

@anarcat
Copy link
Contributor Author

anarcat commented Oct 17, 2023

I think you want to use get_b or what it's called in the config object that returns a boolean so that it parses everything correctly.

It's a boolean? That wasn't quite clear to me, reading the documentation... I thought it could be a time delta (e.g. 1d) as well, which is why I compare against "0", as a string.

@anarcat
Copy link
Contributor Author

anarcat commented Oct 17, 2023

@julian-klode you mean find_b()?

@julian-klode
Copy link

Yes indeed, find_b sorry. Wasn't on my laptop so didn't look it up :)

As reported in prometheus-community#182, `pkgcache.bin` gets updated on more than just
`apt update`. In particular, it gets modified when a package is
installed, upgraded or removed.

So let's fallback on a better heuristic, which is the `APT::Periodic`
timestamp. This should give us a much more precise and deliberate
status.

We also fallback to the `lists` directory, which gets updated when new
mirror lists gets moved into place. This does run the risk of staying
silently unchanged if there's no change on mirrors but (a) that's
rather infrequent and (b) we might actually want to warn on that
anyway.

Signed-off-by: Antoine Beaupré <[email protected]>
Closes: prometheus-community#183
@anarcat anarcat force-pushed the apt-update-check-fine-tune branch from 598c352 to feb943f Compare October 17, 2023 20:04
@anarcat
Copy link
Contributor Author

anarcat commented Oct 17, 2023

thanks, fixed.

@SuperQ SuperQ merged commit f5c56e7 into prometheus-community:master Oct 18, 2023
3 checks passed
@anarcat anarcat deleted the apt-update-check-fine-tune branch October 20, 2023 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

apt cache age computed incorrectly
4 participants