-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Allow overriding of the default response format for custom errors #7245
Allow overriding of the default response format for custom errors #7245
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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/test-infra repository. I understand the commands that are listed here. |
Welcome @ianroberts! |
Hi @ianroberts. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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/test-infra repository. |
CLA signed. |
6d83b85
to
227ca18
Compare
/ok-to-test |
@ianroberts thanks for your PR! I'll post the sha of the new image here |
/retest |
@ianroberts can you please rebase over main? This problem is a bit well known, and was solved on past :) Thanks! |
Rather than hard-coding the default response format as HTML, allow the default to be overridden by an environment variable. For example, given a REST API endpoint that defaults to responding in JSON, you may wish to configure the error messages to be JSON by default as well.
227ca18
to
dcd8bca
Compare
Doesn't seem to have helped, sorry. Though I can't see how anything I've changed in my PR could cause it to fail this way, as I haven't touched any code in the ingress controller itself, only the custom errors image. |
hum, this may be my fault, as I just did some changes in image runner. Let me check here |
yeap, tried to reproduce and got the same error. Let me fix this here |
@ianroberts please rebase again, now this should work :) This was due to the migration to go v1.16 and some changes |
/retest |
no need to rebase |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ianroberts, rikatz 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 |
So I though this image was published on gcr.k8s.io but it isn't so no further action seems to be required. Thanks |
Rather than hard-coding the default response format as HTML, allow the default to be overridden by an environment variable. For example, given a REST API endpoint that defaults to responding in JSON, you may wish to configure the error messages to be JSON by default as well.
What this PR does / why we need it:
Currently the example custom-errors back-end always defaults to responding with HTML error messages if the caller's
Accept
header does not specify otherwise. This is sub-optimal in cases where, for example, we are generating custom errors for an ingress that refers to a REST API endpoint whose default response format is e.g. JSON - in the absence of anAccept
header, the default format of the error messages should be the same as the default format of the endpoint's own successful responses.This PR modifies the example custom error generator so it can take the default response MIME type from an environment variable, instead of always using
text/html
. HTML is still the default if the variable is not set, to preserve backwards compatibility, but this makes it possible to setDEFAULT_RESPONSE_FORMAT=application/json
in the deployment spec for the case described above to make a particular instance respond in JSON by default.Types of changes
How Has This Been Tested?
I am running a copy of this code in my own cluster successfully.
Checklist: