kubernetes-sigs / prow

Prow is a Kubernetes based CI/CD system developed to serve the Kubernetes community. This repository contains Prow source code and Hugo sources for Prow documentation site.
https://docs.prow.k8s.io
Apache License 2.0
129 stars 99 forks source link

Fix cache mode determination #280

Closed netomi closed 1 month ago

netomi commented 2 months ago

This PR fixes 2 things:

in coalescer RoundTrip method, the cache Mode is determined at the end by inspecting the final response object. However, at this point the response object is not the original 304 response from the GitHub server anymore, but the cache response which has usually a status code of 200. So the method cacheResponseMode never returns ModeRevalidated but Changed which is also reflected in the cache.

This does not seem to have another negative effect afaict apart from being confusing and triggered me to inspect whether ghproxy really correctly cached and revalidates requests. Instead of looking at the status code (which is not reliable anymore at this step of the processing), the fix looks at the X-From-Cache header that is set by the httpcache package in case a cached version is returned.

A test case had to be adapted to take that change into account correctly.

This is my first go PR so please bear with me. With these fixes ghproxy runs pretty nice for our use-case (https://github.com/eclipse-csi/otterdog)

Thanks a a lot for this very helpful piece of software.

linux-foundation-easycla[bot] commented 2 months ago

CLA Signed


The committers listed above are authorized under a signed CLA.

k8s-ci-robot commented 2 months ago

Welcome @netomi!

It looks like this is your first PR to kubernetes-sigs/prow πŸŽ‰. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/prow has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. :smiley:

k8s-ci-robot commented 2 months ago

Hi @netomi. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
netlify[bot] commented 2 months ago

Deploy Preview for k8s-prow ready!

Name Link
Latest commit 47ea047bf43659ecd967a93c12b87cdeda509dfa
Latest deploy log https://app.netlify.com/sites/k8s-prow/deploys/66edbbd1cbbc860008d8cdef
Deploy Preview https://deploy-preview-280--k8s-prow.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

petr-muller commented 2 months ago

Wow, thanks for looking into this :+1:

/ok-to-test

k8s-ci-robot commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: netomi, petr-muller

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: - ~~[pkg/OWNERS](https://github.com/kubernetes-sigs/prow/blob/main/pkg/OWNERS)~~ [petr-muller] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment