-
Notifications
You must be signed in to change notification settings - Fork 39.5k
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
Give better error message for PUTs with no resource version #5690
Conversation
@@ -294,6 +295,22 @@ func UpdateResource(r RESTUpdater, ctxFn ContextFunc, namer ScopeNamer, codec ru | |||
return | |||
} | |||
|
|||
// Check to see if a resource version has been supplied. | |||
// If there is no resource version then fail this update request. | |||
// ALTERNATIVE: Update at the most recent resource version. |
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.
We should not coerce to the most recent version by default. That would make it too easy to clobber the desired state.
Seems like this should be done in ValidateObjectMetaUpdate:
https://github.com/GoogleCloudPlatform/kubernetes/blob/9bc2b0c2dbb92e25a48c5aa21e3d3e2ef7d18687/pkg/api/validation/validation.go#L216
It can't be done here, because we allow creation via PUT as well, in which case there is no resourceVersion -- see line 327 below.
@bgrant0607 : thanks, I will move the check. I will try to return the "details" as before and perhaps a different status code (bad request). |
bebe124
to
77d1bc3
Compare
Changed. Now when a
PTAL. |
Did you push your change? |
edd7fb4
to
b0e8262
Compare
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
b0e8262
to
93feb7a
Compare
CLAs look good, thanks! |
I have now. Lots of Git confusion on my part. |
One e2e failure.
|
Running a second time made the guestbook test pass.
|
LGTM. Rerunning tests. |
Well, the check does something:
|
@smarterclayton What's your opinion on whether we should require resourceVersion for non-creating PUTs? It feels like there should be a way to circumvent the concurrency check, but doing that by just omitting resourceVersion feels dangerous. I'd prefer the default behavior be safe. |
93feb7a
to
cd05c8b
Compare
Updated the unit tests. PTAL. |
LGTM |
Give better error message for PUTs with no resource version
Addresses issue #3085
Before if a PUT was made without a resource version an unhelpful error like this was returned:
Now a more specific error is returned:
I ignore the error value from
typer.ObjectVersionAndKind(obj)
since I think it is more important to return the error message about the version.Likewise, I ignore the error message from
a.Name(obj)
.