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

feat(docker): Long-term cache for Docker Hub tags #28489

Merged
merged 7 commits into from
Apr 19, 2024

Conversation

zharinov
Copy link
Collaborator

@zharinov zharinov commented Apr 17, 2024

Changes

  • Store all tags in the package cache for 3 months
  • Update cached items incrementally

Context

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@zharinov zharinov requested review from viceice and rarkins April 17, 2024 23:58
@rarkins
Copy link
Collaborator

rarkins commented Apr 18, 2024

@zharinov can we rethink how this long term caching works?

Ideally we don't want to expire a valid cache ever.

So for example we set a hard expiry limit of X days. I no updates, and no use in X days, then we expire the cache. But if there's any update within the X days, or access within <0.5X left, then we update the cache.

e.g. let's say the cache expiry is 10 days. It's created on day 0, expires day 10.

If on day 1 it's updated, then it now expires on day 11.

Now assume it's not updated, so expiry remains on day 11, and we have reached day 7 and it's accessed. Because <5 days remain, we then push the cache expiry out again to day 17.

In other words we never expire a cache as long as it's accessed approximately once every half X.

I think in your current approach that we'll expire after 90 days if no new tags released in that time?

@zharinov
Copy link
Collaborator Author

I think in your current approach that we'll expire after 90 days if no new tags released in that time?

30 days

@zharinov can we rethink how this long term caching works?

Seems like we have to extend our package cache API to read/write TTL data, otherwise we have to rewrite payload on every access operation.

Relevant commands for Redis:

Also I could figure out the query for the SQLite backend, however we could do nothing but rewrite for the cacache one.

@zharinov zharinov requested a review from viceice April 18, 2024 14:15
@rarkins
Copy link
Collaborator

rarkins commented Apr 18, 2024

I'm ok with rewriting the payload once every 15 days

@zharinov
Copy link
Collaborator Author

zharinov commented Apr 18, 2024

Yes, but also I don't want to overcomplicate this logic. How about something like this:

  • set 45 to 90 days of TTL for all long-term caches
  • implement setTTL for 2 of 3 caching backends, i.e. redis and sqlite
  • bump TTL every time the long-term cache record is read
  • ignore bumping for cacache-based backend, since 45–90 days TTL is good enough
    • as an alternative, we're okay with payload rewrite on every read for long-term cache records

@zharinov
Copy link
Collaborator Author

Anyway, this should be a separate issue/PR

@rarkins
Copy link
Collaborator

rarkins commented Apr 18, 2024

I'm trying to test this locally over night/tomorrow with a few scenarios

@rarkins rarkins added this pull request to the merge queue Apr 19, 2024
Merged via the queue into renovatebot:main with commit 569f28b Apr 19, 2024
35 checks passed
@rarkins rarkins deleted the feat/docker-hub-tags-cache branch April 19, 2024 05:56
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 37.308.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker Hub tags - cache and reuse multiple pages
4 participants