Return BadRequest for node proxy when node has no usable address#139603
Return BadRequest for node proxy when node has no usable address#139603sanidhyasin wants to merge 1 commit into
Conversation
A node proxy request to a Node that has no usable address in status.addresses (for example a Node object created without any addresses) caused the apiserver to return an HTTP 500. The error originates from GetPreferredNodeAddress, which returns a typed NoMatchError that was passed through unchanged and therefore treated as an internal server error. This is a client-correctable condition rather than a server fault, so ResourceLocation now detects the NoMatchError and returns a 400 Bad Request, consistent with how an unresolvable proxy hostname is already handled in the same function.
|
|
|
Welcome @sanidhyasin! |
|
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The DetailsInstructions 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. |
|
Hi @sanidhyasin. 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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sanidhyasin The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
What this PR does / why we need it:
A node proxy request (e.g.
POST /api/v1/nodes/<name>/proxy/) to a Node that has no usable address instatus.addressescurrently returns an HTTP500 Internal Server Error:{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Failure", "message": "no preferred addresses found; known addresses: []", "code": 500 }The error originates from
GetPreferredNodeAddress, which returns a typed*node.NoMatchErrorwhen none of the preferred address types are present. That error was passed throughResourceLocationunchanged and, since it is not a recognized API status error, the endpoint reported it as an internal server error.A Node without a routable address is not a server fault — there is simply nowhere to proxy to, which the client can correct. This PR makes
ResourceLocationdetect theNoMatchErrorand return a400 Bad Requestinstead, consistent with how an unresolvable proxy hostname is already handled a few lines below in the same function (isProxyableHostname->NewBadRequest). Other errors fromGetConnectionInfo(such as aNotFoundwhen the node does not exist) are left untouched.Which issue(s) this PR is related to:
Fixes #139486
Special notes for your reviewer:
The chosen status code (400) mirrors the existing behavior of the sibling pod proxy
ResourceLocation, which returnsNewBadRequest("address not allowed")when a pod has no usable address, and the adjacent non-proxyable-hostname branch in this same function.TestResourceLocationis extended with a "node without any address" case and now asserts that every error case is aBadRequestrather than a generic error.Does this PR introduce a user-facing change?