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

change the "too old resource version" error from NewInternalError to NewBadRequest #16628

Merged
merged 1 commit into from
Dec 1, 2015

Conversation

caesarxuchao
Copy link
Member

fix #14384

cc @erictune

@k8s-github-robot
Copy link

Labelling this PR as size/XS

@k8s-github-robot k8s-github-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 30, 2015
@k8s-bot
Copy link

k8s-bot commented Oct 30, 2015

GCE e2e build/test failed for commit 7de7ec8413eb237e7baa6ae08010cc9a502b1782.

@caesarxuchao
Copy link
Member Author

Sorry. I should have tested it locally first. I will fix it.
[update]
Fixed.

@k8s-bot
Copy link

k8s-bot commented Oct 30, 2015

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))
Copy link
Member

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 :)

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah - 410 sounds good.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor

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.

@caesarxuchao caesarxuchao reopened this Nov 2, 2015
@lavalamp
Copy link
Member

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"
Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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.

@k8s-github-robot
Copy link

Labelling this PR as size/S

@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 11, 2015
@k8s-bot
Copy link

k8s-bot commented Nov 11, 2015

GCE e2e build/test failed for commit 0a50730fb9a756344125411d584bbca8c482ed8a.

@caesarxuchao
Copy link
Member Author

@k8s-bot test this please.

@k8s-bot
Copy link

k8s-bot commented Nov 11, 2015

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.
Copy link
Member Author

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.

@k8s-bot
Copy link

k8s-bot commented Nov 13, 2015

GCE e2e test build/test passed for commit 4c38b2b0f4a89c3d685f902128a0002dcd0b982e.

@k8s-github-robot k8s-github-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Nov 24, 2015
@wojtek-t
Copy link
Member

@caesarxuchao - LGTM

Can you please squash the commits? (I think that we should merge it finally).

@caesarxuchao
Copy link
Member Author

Thanks @wojtek-t. Squashed. I'll ping lavalamp after the holiday.

@k8s-bot
Copy link

k8s-bot commented Nov 25, 2015

GCE e2e test build/test passed for commit a470070.

@lavalamp lavalamp added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 30, 2015
@lavalamp
Copy link
Member

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-github-robot
Copy link

@k8s-bot test this

Tests are more than 48 hours old. Re-running tests.

@k8s-bot
Copy link

k8s-bot commented Nov 30, 2015

GCE e2e test build/test passed for commit a470070.

@wojtek-t
Copy link
Member

@k8s-bot unit test this please

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Dec 1, 2015

GCE e2e test build/test passed for commit a470070.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Dec 1, 2015
@k8s-github-robot k8s-github-robot merged commit 55f5e48 into kubernetes:master Dec 1, 2015
@caesarxuchao
Copy link
Member Author

@k8s-oncall, why did the bot merge this even if the unit test failed?

@caesarxuchao
Copy link
Member Author

cc @eparis @ixdy

@ixdy
Copy link
Member

ixdy commented Dec 1, 2015

#16662 also merged despite unit tests failing. I suspect mergebot is not looking at the unit tests result, which is worrying.

@eparis
Copy link
Contributor

eparis commented Dec 1, 2015

@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.

@eparis
Copy link
Contributor

eparis commented Dec 1, 2015

(this logic was built back when we had shippable doing unit testing and didn't have a reasonable mechanism to retest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

apiserver: too old resource version error reported with wrong type
10 participants