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

Fix GitHub API cache to work with GitHub App authentication #1210

Merged
merged 3 commits into from
Mar 12, 2022

Conversation

mumoshu
Copy link
Collaborator

@mumoshu mumoshu commented Mar 12, 2022

The version of bradleyfalzon/ghinstallation which is used to enable GitHub App authentication turned out to add an extra header application/vnd.github.machine-man-preview+json to every HTTP request. That revealed an edge-case in our HTTP cache layer gregjones/httpcache that results in it to not serve responses from cache when it should.

There were two problems. One was that it does not support multi-valued header and it only looked for the first value for each header, and another is that it does not support any http.RoundTripper implementation that modifies HTTP request headers in a RoundTrip function call.

I fixed it in my fork of httpcache, which is hosted at https://github.com/actions-runner-controller/httpcache.

The relevant commits are:

This can be considered as a follow-up for #1127, which turned out to have enabled the cache only for the case that ARC uses PAT for authentication.
Since this fix, the cache is also enabled when ARC authenticates as a GitHub App.

The version of `bradleyfalzon/ghinstallation` which is used to enable GitHub App authentication turned out to add an extra header `application/vnd.github.machine-man-preview+json` to every HTTP request. That revealed an edge-case in our HTTP cache layer `gregjones/httpcache` that results it to not serve responses from cache when it should.

There were two problems. One was that it does not support multi-valued header and it only looked for the first value for each header, and another is that it does not support any http.RoundTripper implementation that modifies HTTP request headers in a RoundTrip function call.

I fixed it in my fork of httpcache, which is hosted at https://github.com/actions-runner-controller/httpcache.

The relevant commits are:

- actions-runner-controller/httpcache@70d975e
- actions-runner-controller/httpcache@197a8a3

This can be considered as a follow-up for #1127, which turned out to have enabled the cache only for the case that ARC uses PAT for authentication.
Since this fix, the cache is also enabled when ARC authenticates as a GitHub App.
@mumoshu mumoshu added this to the v0.22.0 milestone Mar 12, 2022
@mumoshu mumoshu merged commit 757e0a8 into master Mar 12, 2022
@mumoshu mumoshu deleted the fix-github-api-cache-for-github-app-mode branch March 12, 2022 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant