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

pkg/apiserver: use correct HTTP status code for bad method #7155

Closed
wants to merge 1 commit into from
Closed

pkg/apiserver: use correct HTTP status code for bad method #7155

wants to merge 1 commit into from

Conversation

xiang90
Copy link
Contributor

@xiang90 xiang90 commented Apr 22, 2015

405 is more accurate than 403 according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.

But I am not sure if this breaks the existing API.

@fabioy
Copy link
Contributor

fabioy commented Apr 22, 2015

I think this change is safe, but would want someone from the API team to confirm.

@bgrant0607 - Could you or someone in API LGTM it? Thank you.

w.WriteHeader(http.StatusForbidden)
fmt.Fprintf(w, "This is a read-only endpoint.")
w.Header().Set("Allow", "GET")
http.Error(w, "This is a read-only endpoint.", http.StatusMethodNotAllowed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use NewMethodNotSupported:
https://github.com/GoogleCloudPlatform/kubernetes/blob/a927c239fe5845ce2b515b932f5d7dfa7a9c88d5/pkg/api/errors/errors.go#L197

We want to return Status json structs for all errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a few other places in this file where we do the same thing (return a plain text response instead of a json status object). Feel free to update them all while you are it :)
Ref #1990

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bgrant0607
Copy link
Member

cc @nikhiljindal

@smarterclayton
Copy link
Contributor

So 403 was intentional in our early discussions, because of this The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity.

I've in the past typically reserved 405 for "not implemented", but in this case, the 403 is because the user is accessing the core server via a path that only allows a subset of requests.

Can you describe more why you think it's 405?

@bgrant0607
Copy link
Member

That's a good point. It is an authorization policy rather than an unimplemented or invalid verb/path.

We still should return structured error responses, though.

@bgrant0607
Copy link
Member

This may be pointless if we rip out the readonly service, though. #4567

@erictune
Copy link
Member

erictune commented Jun 1, 2015

I'm persuaded by @smarterclayton explanation. No recent activity. Closing.

@erictune erictune closed this Jun 1, 2015
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.

7 participants