-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
GHProxy: Fix cache mode detection and log an error if cache write fails #22610
Conversation
I've created upstream PRs for the two issues here, just in case the author responds:
Should those get merged, I'll switch us back. IMHO we should switch to the fork for now though, the completely borked cache mode detection is pretty bad. |
If we wanted TTL-based pruning for the cache data would that need to come as a new commit to the library as well? |
Another possible approach would be to just copy the lib into test-infra, not sure if that is better or worse. |
We're ok with the vendoring approach if it is the best option, but I think we might be working around the problem rather than solving it. |
It does, but the cache replaces the GitHub response with the cached response if that happens: https://github.com/gregjones/httpcache/blob/901d90724c7919163f472a9812253fb26761123d/httpcache.go#L195 The only thing it keeps from the 304 response is the headers, except for a list of disabled ones (https://github.com/gregjones/httpcache/blob/901d90724c7919163f472a9812253fb26761123d/httpcache.go#L418) which I strongly presume is the reason the detection works by inspecting this I am very certain there is no way to get this working without modifying the httpcache lib, I did try that first. |
Hm, we could feed a custom http transport into the lib that sets this Header. But the "log error when writing to cache fails" is definitely not fixable without changing the lib and I would like to have that. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, cjwagner The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold cancel |
Currently, the ghproxy cache mode detection is broken:
The second and third request return an
X-Cache-Mode
ofCHANGED
, even though they didn't use a token (X-Ratelimit-Remaining
remains the same). This is because the cache mode detection relies on a header that is never present:test-infra/ghproxy/ghcache/ghcache.go
Line 119 in 4131bdb
I presume that Header used to be returned by GitHub but isn't anymore. Because the cache lib we are using is unmtaintained, I have forked it and made it inject that very same header when it serves a request from cache: alvaroaleman/httpcache@0b0fe54
All of this investigation happened in the first place because we ran out of tokens. This turned out to ultimatively be caused by the disk used by ghproxy running out of inodes. Unfortunately, the cache doesn't log any error in that case. I have added another commit to my fork that does that: alvaroaleman/httpcache@ab9a1a3
/assign @chaodaiG @cjwagner