-
Notifications
You must be signed in to change notification settings - Fork 40k
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
change the "too old resource version" error from NewInternalError to NewBadRequest #16628
change the "too old resource version" error from NewInternalError to NewBadRequest #16628
Conversation
Labelling this PR as size/XS |
GCE e2e build/test failed for commit 7de7ec8413eb237e7baa6ae08010cc9a502b1782. |
Sorry. I should have tested it locally first. I will fix it. |
7de7ec8
to
0feb4e8
Compare
GCE e2e test build/test passed for commit 0feb4e8e8c043ccb0ff09244d7a197c242092d02. |
@@ -266,7 +266,7 @@ func (w *watchCache) GetAllEventsSinceThreadUnsafe(resourceVersion uint64) ([]wa | |||
return result, nil | |||
} | |||
if resourceVersion < oldest { | |||
return nil, errors.NewInternalError(fmt.Errorf("too old resource version: %d (%d)", resourceVersion, oldest)) | |||
return nil, errors.NewBadRequest(fmt.Sprintf("too old resource version: %d (%d)", resourceVersion, oldest)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest - I'm not convinced about this change.
From the logic point of view - it's not a bad request - it's totally valid request.
It's the implementation limitation, that we cannot handle this request, because we don't have old enough data.
So for me it look more like "InternalError" - the request is correct - we just aren't good enough to serve it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't think it's a bad request. Also I think InternalError will give you a stack trace in apiserver logs, I would like to avoid this if it's the case. I suggest 410 if it avoids the stack trace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bprashanth. 410 seems to be most accurate one. Currently we don't have a NewGone method. I'll add one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - 410 sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually what do you guys think about "412 Precondition Failed"-- I think
410 Gone sounds much too permanent?
On Mon, Nov 2, 2015 at 10:32 AM, Wojciech Tyczynski <
notifications@github.com> wrote:
In pkg/storage/watch_cache.go
#16628 (comment)
:@@ -266,7 +266,7 @@ func (w *watchCache) GetAllEventsSinceThreadUnsafe(resourceVersion uint64) ([]wa
return result, nil
}
if resourceVersion < oldest {
return nil, errors.NewInternalError(fmt.Errorf("too old resource version: %d (%d)", resourceVersion, oldest))
return nil, errors.NewBadRequest(fmt.Sprintf("too old resource version: %d (%d)", resourceVersion, oldest))
Yeah - 410 sounds good.
—
Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/16628/files#r43662572.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"416 Requested Range Not Satisfiable" and "417 Expectation Failed" both
sound reasonable, too. Unfortunately all 3 are talking about headers and
we are doing this via a query parameter.
On Mon, Nov 2, 2015 at 10:52 AM, Daniel Smith dbsmith@google.com wrote:
Actually what do you guys think about "412 Precondition Failed"-- I think
410 Gone sounds much too permanent?On Mon, Nov 2, 2015 at 10:32 AM, Wojciech Tyczynski <
notifications@github.com> wrote:In pkg/storage/watch_cache.go
#16628 (comment)
:@@ -266,7 +266,7 @@ func (w *watchCache) GetAllEventsSinceThreadUnsafe(resourceVersion uint64) ([]wa
return result, nil
}
if resourceVersion < oldest {
return nil, errors.NewInternalError(fmt.Errorf("too old resource version: %d (%d)", resourceVersion, oldest))
return nil, errors.NewBadRequest(fmt.Sprintf("too old resource version: %d (%d)", resourceVersion, oldest))
Yeah - 410 sounds good.
—
Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/16628/files#r43662572.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as it's not one of the more frequently used return codes I don't have a preference. 404 is what you generally use for things like http://www.google.com/lkajsdlkf, and of course a 5xx means we messed up. I agree 410 is generally what one would apply for: I know for sure this resource used to exist, but it's been deleted, and for it to apply in this scenario the "resource" in question needs to be the in-memory watch window etcd has flushed.
OK, I guess let's go with 410 Gone. We can change it later if we get complaints. I don't know that we currently consider HTTP response codes part of our API, though perhaps we should. |
// StatusReasonGone means the item is no longer available at the server and no | ||
// forwarding address is known. | ||
// Status code 410 | ||
StatusReasonGone StatusReason = "Gone" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lavalamp, this actually is an API change. [edit] Let me know if it's appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it's totally fine to add this status code to the api. The thing I was talking about was the range of codes we could possibly return from a given request. I don't think we consider that part of the API, or at least it's not written down places. I could be wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm..The status code that will be sent by the server is listed In the api-converions doc, and 410 is not there. https://github.com/kubernetes/kubernetes/blob/master/docs/devel/api-conventions.md#http-status-codes. Does that make the status code part of the API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Please include a change to that doc in this PR!
On Wed, Nov 11, 2015 at 2:27 PM, Chao Xu notifications@github.com wrote:
In pkg/api/unversioned/types.go
#16628 (comment)
:@@ -162,6 +162,11 @@ const (
// Status code 409
StatusReasonConflict StatusReason = "Conflict"
- // StatusReasonGone means the item is no longer available at the server and no
- // forwarding address is known.
- // Status code 410
- StatusReasonGone StatusReason = "Gone"
Hmm..Status code that will be sent by the server is listed In the
api-converions doc, and 410 is not there.
https://github.com/kubernetes/kubernetes/blob/master/docs/devel/api-conventions.md#http-status-codes.
Does that make the status code part of the API?—
Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/16628/files#r44596262.
Labelling this PR as size/S |
GCE e2e build/test failed for commit 0a50730fb9a756344125411d584bbca8c482ed8a. |
@k8s-bot test this please. |
GCE e2e build/test failed for commit 0a50730fb9a756344125411d584bbca8c482ed8a. |
* `410 StatusGone` | ||
* Indicates that the item is no longer available at the server and no forwarding address is known. | ||
* Suggested client recovery behavior | ||
* Do not retry. Fix the request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The status code is added to the api-conventions.md. PTAL. I'll squash later.
GCE e2e test build/test passed for commit 4c38b2b0f4a89c3d685f902128a0002dcd0b982e. |
@caesarxuchao - LGTM Can you please squash the commits? (I think that we should merge it finally). |
4c38b2b
to
a470070
Compare
Thanks @wojtek-t. Squashed. I'll ping lavalamp after the holiday. |
GCE e2e test build/test passed for commit a470070. |
LGTM. I'm pretty sure that clients (ours, at least) will treat this the same, as evidenced by the fact that you didn't update any client code, so there shouldn't be a compatibility problem. |
@k8s-bot test this Tests are more than 48 hours old. Re-running tests. |
GCE e2e test build/test passed for commit a470070. |
@k8s-bot unit test this please |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e test build/test passed for commit a470070. |
Automatic merge from submit-queue |
Auto commit by PR queue bot
@k8s-oncall, why did the bot merge this even if the unit test failed? |
#16662 also merged despite unit tests failing. I suspect mergebot is not looking at the unit tests result, which is worrying. |
@ixdy Basically yes. Merge bot looks a unit+e2e+travis when it decides to retest. It only looks at e2e on the re-test. I will switch it today to look at e2e+unit on retest. |
(this logic was built back when we had shippable doing unit testing and didn't have a reasonable mechanism to retest) |
Auto commit by PR queue bot
fix #14384
cc @erictune