-
Notifications
You must be signed in to change notification settings - Fork 394
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
Improve CloudFlare cache clear logging and GitHub Stars bugfix #1587
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Since Heroku's runtime logs are much trickier to track down than dyno runtime logs, this change will allow us to better see CloudFlare cache clearing feedback. The script in `clear-cloudflare-cache` is changed from a shell-invoked style to a Node module that's imported into `deploy-with-s3`.
rogermparent
changed the title
Fix CloudFlare cache clearing
Improve CloudFlare cache logging
Jul 17, 2020
rogermparent
changed the title
Improve CloudFlare cache logging
Improve CloudFlare cache clear logging
Jul 17, 2020
This replaces the Node with a Resolver, so the in-between layer is thinner and not subject to stale cache pruning as it is only a middleman. This also adds `createResolvers` to Gatsby APIs exposed to Models
Closed
do we want to merge this? |
…x-cloudflare-cache-clearer
I believe we do want to merge this, the primary change will mean any future CloudFlare cache cleaner problems will be much more visible (i.e. if the new token I make ever expires for some reason) |
rogermparent
changed the title
Improve CloudFlare cache clear logging
Improve CloudFlare cache clear logging and GitHub Stars bugfix
Jul 18, 2020
shcheklein
approved these changes
Jul 19, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR was made to help diagnose the CloudFlare cache purge issue we've been having, though Review Apps don't actually have CloudFlare credentials.
The changes of this PR move the CloudFlare cache cleaning logic into a regular Node module instead of a CLI-invoked script. This module is then used at the end of the deploy script. Effectively, this moves the CloudFlare cache clean to "the end of the deploy phase" as opposed to "the start of the runtime process".
As I understand it, this effectively doesn't change anything except for logs. The log changes, however, mean that the CloudFlare script outputs in the build logs instead of the runtime logs- this is good because runtime logs expire without add-ons, but build-time logs last forever by default.
You can see in the Deploy Preview for this PR that the cache clear module is being run, as it outputs the line
Skipping CloudFlare cache purge because CONTEXT is not set to production.
. To actually test it out, I just need to manually add keys to the deploy app's env vars. I'll do another update when I do.Update: When testing with the keys in prod on the Heroku review app, this error appears:
When testing with a new token on a Review App, the CloudFlare cache is successfully cleared. This could either be because the token is invalid or deploy apps fail an auth check on the old key that prod passes. Either way, I think it's worth trying this new log behavior and a new key on the production Heroku instance.
Update: While working on this issue, I ran into a bug related to GitHub stars that would break our cache re-use occasionally and force a full rebuild- the fix was to turn the static stars GraphQL endpoint into a simple resolver instead of a true Node, solving the issue that necessitated the separate node as well as the cache issue the first iteration of the fix introduced.