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

cleanup: fix various cases where cache wasn't being removed properly #16977

Merged
merged 3 commits into from
Mar 31, 2024

Conversation

Bo98
Copy link
Member

@Bo98 Bo98 commented Mar 30, 2024

  • utils/bottles: fix outdated bottle check
    • This check was completely broken under GitHub Packages as it would compare a classic formula bottle file extension to a ghcr.io url which just contains a sha256 string.
    • Now properly compares tag and rebuild.
  • cleanup: better handle version_scheme scenarios
    • When version_scheme is bumped, formula.version > version will not be true. We cannot extract the version scheme here, but we can special case the latest-version-installed case to make that != which should cover most scenarios.
  • cleanup: better support bottle manifests
    • brew cleanup <formula> failed to check any associated bottle manifests and those would only ever be removed by the timed prune.
    • This is now supported under the stale check by removing the _bottle_manifest suffix when parsing the formula name.

Will probably make a tag with this given it's causing some confusion/concern.

@Bo98 Bo98 enabled auto-merge March 30, 2024 03:51
Copy link
Contributor

@apainintheneck apainintheneck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add regression tests for these bugs?

Comment on lines +36 to 39
file = file.resolved_path

filename = file.basename.to_s
return false if formula.bottle.blank?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
file = file.resolved_path
filename = file.basename.to_s
return false if formula.bottle.blank?
return false if formula.bottle.blank?
file = file.resolved_path
filename = file.basename.to_s

Nit: Avoid extra work if the bottle doesn't exist.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @Bo98!

Agreed regression tests would be nice but don't want this to be blocked on that for the tag tomorrow.

@Bo98 Bo98 merged commit da456da into master Mar 31, 2024
25 checks passed
@Bo98 Bo98 deleted the cleanup-fixes branch March 31, 2024 18:27
@lembacon
Copy link
Contributor

lembacon commented Apr 1, 2024

This seems introducing a regression that may aggressively cleanup cached bottle downloads when bottles were ever rebuilt.

For example, with latest ncurses-6.4 and the bottle of which has a rebuild of 1, brew install ncurses && brew cleanup will immediately removed the cached bottle and manifest that have just been downloaded.

@Bo98
Copy link
Member Author

Bo98 commented Apr 1, 2024

Probably the first commit. Rebuilds were previously never removed because it was completely broken. It's possible that the original intended behaviour is now slightly too aggressive or I missed an edge case. Will check your example.

@Bo98
Copy link
Member Author

Bo98 commented Apr 1, 2024

Can't reproduce the cached bottle part but have reproduced the manifest issue and have fixed: #16992

@lembacon
Copy link
Contributor

lembacon commented Apr 1, 2024

Actually it seems also related to the formula's revision.

I just tried brew reinstall glib && brew cleanup -n, it would remove both the downloaded bottle and manifest.

@lembacon
Copy link
Contributor

lembacon commented Apr 1, 2024

It turns out that #16992 also resolves the issue for formulae with non-default revision, i.e. glib. 🥳

@MikeMcQuaid
Copy link
Member

@lembacon Thanks for reporting and testing 🎉

@Bo98
Copy link
Member Author

Bo98 commented Apr 1, 2024

Ah yeah that makes sense if it's glib rather than ncurses. Weren't using pkg_version properly before but we now are!

@github-actions github-actions bot added the outdated PR was locked due to age label May 2, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants