gateway-api icon indicating copy to clipboard operation
gateway-api copied to clipboard

Add 307 / 308 Redirect Status Code Support

Open davidwin93 opened this issue 6 months ago • 16 comments

What type of PR is this? /kind bug /area conformance-test

What this PR does / why we need it:

This PR allows users to select either a 307 or 308 status code along with the existing options of 301 and 302. This matches RFC 9110 and by letting users select 308 it will match the existing nginx ingress behaviour of using a 308 for HTTP -> HTTPS redirects.

Which issue(s) this PR fixes:

Fixes #2748

Does this PR introduce a user-facing change?: This will allow users to select 307 or 308 as redirect status codes along with 301 and 302.

Adds support to select 307 or 308 status codes along with the current options of 301 and 302

davidwin93 avatar May 29 '25 01:05 davidwin93

Welcome @davidwin93!

It looks like this is your first PR to kubernetes-sigs/gateway-api 🎉. 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/gateway-api 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 avatar May 29 '25 01:05 k8s-ci-robot

Hi @davidwin93. 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. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar May 29 '25 01:05 k8s-ci-robot

Thanks @davidwin93, this will be a great improvement!

/ok-to-test

robscott avatar May 30 '25 00:05 robscott

/cc

LiorLieberman avatar Jun 03 '25 01:06 LiorLieberman

Note: For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request. If this behavior is undesired, the 307 (Temporary Redirect) or 308 (Permanent Redirect) status code can be used instead.

Is there any suggestion that we would want to include in docs for this behavior for 301 and 302 responses?

mikemorris avatar Jun 03 '25 15:06 mikemorris

I'd like to see the user-facing docs updated as part of this PR -- thanks!!

kflynn avatar Jun 03 '25 15:06 kflynn

@LiorLieberman in regards to SupportedFeature do I need to wait for this to get in first? Do you happen to have any examples of any in flight work that is currently using this functionality, or would this be the first change to leverage supported features?

davidwin93 avatar Jun 03 '25 18:06 davidwin93

this may benefit from a SupportedFeature for gradual enablement, because if this gets in, if there is any implementation that does not support 307 and 308 they go out of conformance

Can we add this as Extended (optional)?

candita avatar Jun 03 '25 22:06 candita

@LiorLieberman in regards to SupportedFeature do I need to wait for this to get in first? Do you happen to have any examples of any in flight work that is currently using this functionality, or would this be the first change to leverage supported features?

no, these are two different things. when I said supported features I really meant a FeatureName - like https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-response-header-modifier.go#L40 for example.

And @candita, to your point, adding a featureName would mean it is initially extended, but as said during the meeting, we should communicate clearly we are only doing it for gradual enablement, with intentions to move it to core (and remove the featureName) once we communicated it enough

LiorLieberman avatar Jun 03 '25 23:06 LiorLieberman

@davidwin93 let me know if you need any assistance with this.

See recent commit that did the same thing almost - https://github.com/kubernetes-sigs/gateway-api/pull/3826/commits/e77c6120ea5bd66822f61c73225697b4c9e88010

LiorLieberman avatar Jun 04 '25 20:06 LiorLieberman

@LiorLieberman thanks for that example. I've added some new tests with a new feature. I assume I should revert my changes to the existing conformance tests?

Ill also work on updating the docs shortly.

davidwin93 avatar Jun 05 '25 03:06 davidwin93

Not sure if this needs to take a step back in terms of process, but I was wondering if it would be possible to also add the 303 status code to cover the entire space of redirect codes.

303 is a more standardized alternative to 302 which is already supported. There is some inconsistency in whether clients preserve the original request body and method or switch to GET with 302, while 303 clearly defines this behavior.

sybereal avatar Jun 26 '25 15:06 sybereal

I'd be supportive of adding 303 as an acceptable analogue for 302 too @sybereal, adding support for that was a specific request from our Application Gateway for Containers team at Microsoft.

/cc @JackStromberg

mikemorris avatar Jun 26 '25 16:06 mikemorris

[like] Jack Stromberg reacted to your message:


From: Mike Morris @.> Sent: Thursday, June 26, 2025 4:25:09 PM To: kubernetes-sigs/gateway-api @.> Cc: Jack Stromberg @.>; Manual @.> Subject: Re: [kubernetes-sigs/gateway-api] Add 307 / 308 Redirect Status Code Support (PR #3823)

[https://avatars.githubusercontent.com/u/1149913?s=20&v=4]mikemorris left a comment (kubernetes-sigs/gateway-api#3823)https://github.com/kubernetes-sigs/gateway-api/pull/3823#issuecomment-3009056745

I'd be supportive of adding 303 as an acceptable analogue for 302 too @syberealhttps://github.com/sybereal, adding support for that was a specific request from our Application Gateway for Containers team at Microsoft.

— Reply to this email directly, view it on GitHubhttps://github.com/kubernetes-sigs/gateway-api/pull/3823#issuecomment-3009056745, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADSTTY6SGIIJIVJXTQ6K32T3FQNGLAVCNFSM6AAAAAB6EJLAHOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMBZGA2TMNZUGU. You are receiving this because you are subscribed to this thread.Message ID: @.***>

JackStromberg avatar Jun 26 '25 16:06 JackStromberg

I agree that adding 303 while we're adding things makes sense too, and I also agree that the user-facing docs should be updated as part of this.

Also very important to call this out as a planned transition, maybe with a timeline deprecating this FeatureName and moving it into Core conformance. I'd suggest adding this in v1.4, and planning on removing this Feature and making it conformance in v1.8 (probably early 2027).

youngnick avatar Jun 30 '25 03:06 youngnick

Also very important to call this out as a planned transition, maybe with a timeline deprecating this FeatureName and moving it into Core conformance. I'd suggest adding this in v1.4, and planning on removing this Feature and making it conformance in v1.8 (probably early 2027).

@youngnick To clarify, are you suggesting adding a temporary feature name to cover these new status codes with the idea that it would merge into the existing feature name in the future?

robscott avatar Jul 01 '25 00:07 robscott

Yes, that's it. We haven't done that before, but I don't see why we can't, as long as we document everything clearly.

youngnick avatar Jul 01 '25 01:07 youngnick

Yes, that's it. We haven't done that before, but I don't see why we can't, as long as we document everything clearly.

SGTM, look like we're on the same page here, just wanted to confirm.

robscott avatar Jul 01 '25 04:07 robscott

@youngnick for documentation would updating this doc be the correct place or should this be documented elsewhere?

davidwin93 avatar Jul 11 '25 22:07 davidwin93

@youngnick for documentation would updating this doc be the correct place or should this be documented elsewhere?

Yep, that looks correct to me

robscott avatar Jul 12 '25 00:07 robscott

@davidwin93 just checking in, anything we can help with?

LiorLieberman avatar Aug 23 '25 17:08 LiorLieberman

@LiorLieberman Sorry it's been a bit busy. Im planning on getting back to this in the next few days.

davidwin93 avatar Aug 26 '25 15:08 davidwin93

@LiorLieberman this should be good for another pass. I believe I've addressed the comments correctly.

davidwin93 avatar Sep 11 '25 17:09 davidwin93

do we have some implementation already supporting these return codes, just so we can do a run and guarantee that conformance is also ok?

Thanks!

rikatz avatar Oct 10 '25 17:10 rikatz

Thanks everyone for the work and discussion on this. I completely understand why this has taken some time to make it in, and also why it didn't make the most recent release. These things happen, and the process around release management and validation criteria is important to keep stable.

That said, I do want to highlight a concern from the perspective of downstream adopters and integrators. When changes like this can't make it into a patch or minor release—even when they're relatively small, such as expanding an enum or adding a bit of CEL validation—it effectively means that these improvements can take close to a year to reach users, given the six-month release cadence.

That long gap can make it difficult for projects building on Gateway API to support their users or align on conformance, especially when a missing option or validation rule blocks certain use cases. Over time, this can lead to the same challenges that the Ingress API experienced, where implementations resorted to annotations or custom extensions to fill gaps that the upstream API couldn't evolve quickly enough to cover. You can see in the reference above where we have moved to do exactly that in kgateway due to this not merging and that given prior discussion here our understanding is that changes like this can only go in minor versions.

For those reasons, I'd like to suggest we re-evaluate how we classify and handle changes like this. It seems like there should be a safe path for small, backward-compatible improvements to land in patch releases, especially when they improve expressiveness or correctness without changing behavior or compliance.

Really appreciate everyone's continued work here; I just want to make sure Gateway API can keep evolving fast enough to stay broadly usable across the ecosystem.

josh-pritchard avatar Oct 14 '25 17:10 josh-pritchard

This is part of the point of the changes discussed in #4164 -- the idea is that yes, it should be faster to get things into an experimental-channel release that people can experiment with.

kflynn avatar Oct 14 '25 17:10 kflynn

Thanks @kflynn! A very timely discussion, from a skim I think moving to a model of monthly releases for the experimental channel makes a lot of sense. To make sure I understand correctly, in the context of this PR where there is an agreed upon change that should be made to the stable & experimental versions simultaneously, it just means that the changes would be available at most within a month of merging via the experimental channel? Then they will be in the next stable release whenever that happens?

josh-pritchard avatar Oct 14 '25 20:10 josh-pritchard

That said, I do want to highlight a concern from the perspective of downstream adopters and integrators. When changes like this can't make it into a patch or minor release—even when they're relatively small, such as expanding an enum or adding a bit of CEL validation—it effectively means that these improvements can take close to a year to reach users, given the six-month release cadence.

You're completely right, this took too long to get in. Improving this is a big focus for us, a big thanks to @kflynn for helping move this forward.

robscott avatar Oct 14 '25 20:10 robscott

There was some concern if this was too late to squeeze in before v1.4, but now that that release is out, I think it's past time to get this change in.

robscott avatar Oct 14 '25 20:10 robscott

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidwin93, robscott

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 /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Oct 14 '25 20:10 k8s-ci-robot