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

ci: Cache postgres volume after first migration #3488

Merged
merged 41 commits into from
Dec 30, 2024
Merged

Conversation

BYK
Copy link
Member

@BYK BYK commented Dec 21, 2024

This patch caches all DB volumes based on the sentry and snuba images to avoid doing the same migrations over and over for every test run.

This shaved off a whole minute from "Install self-hosted" jobs (so ~20% speed increase).

Left side: cached re-run -- Right side: no-cache initial run
image

Should prevent us from doing migrations over and over for the same Sentry image
Copy link

codecov bot commented Dec 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.06%. Comparing base (1bb22c0) to head (413b08e).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3488   +/-   ##
=======================================
  Coverage   98.06%   98.06%           
=======================================
  Files           3        3           
  Lines         207      207           
=======================================
  Hits          203      203           
  Misses          4        4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BYK BYK requested a review from hubertdeng123 December 22, 2024 19:53
@BYK BYK marked this pull request as ready for review December 22, 2024 19:53
Copy link
Collaborator

@aminvakil aminvakil left a comment

Choose a reason for hiding this comment

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

Can we have an env or something like that to punch through cache, I don't think of a reason which someone would need this right now (not using cache), and we can always add it later, what do you think?

On another matter, shouldn't we take postgres, clickhouse version into cache id, so if that gets changed, cache gets invalidated?

@BYK
Copy link
Member Author

BYK commented Dec 30, 2024

Can we have an env or something like that to punch through cache, I don't think of a reason which someone would need this right now (not using cache), and we can always add it later, what do you think?

Don't think this would be useful as this is only happening on CI and changing the cache env variable would require a new commit where we can simply bump the cache key or disable the cache step if we want to.

On another matter, shouldn't we take postgres, clickhouse version into cache id, so if that gets changed, cache gets invalidated?

Don't think so as we should be fine with upgrades too. We still run migrations, upgrade etc. We just happen to start from a warm state which is quite similar to our upgrade test.

key: db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}-${{ steps.cache_key.outputs.SNUBA_IMAGE_SHA }}
restore-keys: |
db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}
db-volumes-v4-
Copy link
Member

Choose a reason for hiding this comment

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

It does not seem like this is intentional? Perhaps

db-volumes-v4-${{ steps.cache_key.outputs.SNUBA_IMAGE_SHA }} ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Completely intentional. These are prefix matched in order for stale cache restoration. So if we cannot match on both sentry and snuba image SHA, then we fallback to one with sentry image sha regardless of snuba, and finally, it just restores any cache as long as it is v4.

@hubertdeng123
Copy link
Member

This is great, wondering how much time this shaves off CI time

@BYK
Copy link
Member Author

BYK commented Dec 30, 2024

This is great, wondering how much time this shaves off CI time

It is in the description 😅:

This shaved off a whole minute from "Install self-hosted" jobs (so ~20% speed increase).

@BYK BYK requested a review from hubertdeng123 December 30, 2024 22:29
@BYK BYK merged commit d5b49a4 into master Dec 30, 2024
14 checks passed
@BYK BYK deleted the byk/ci/postgres-cache branch December 30, 2024 22:37
BYK added a commit that referenced this pull request Dec 31, 2024
BYK added a commit that referenced this pull request Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants