Unverified Commit 4344d337 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #63014 from fisherxu/removerv

Automatic merge from submit-queue (batch tested with PRs 63046, 62925, 63014). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Remove repeated get resourceversion in update **What this PR does / why we need it**: Obj have no updated, so no need to reGet. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
parents 61a8454c 87de76fa
...@@ -586,19 +586,15 @@ func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest. ...@@ -586,19 +586,15 @@ func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest.
} else { } else {
// Check if the object's resource version matches the latest // Check if the object's resource version matches the latest
// resource version. // resource version.
newVersion, err := e.Storage.Versioner().ObjectResourceVersion(obj) if resourceVersion == 0 {
if err != nil {
return nil, nil, err
}
if newVersion == 0 {
// TODO: The Invalid error should have a field for Resource. // TODO: The Invalid error should have a field for Resource.
// After that field is added, we should fill the Resource and // After that field is added, we should fill the Resource and
// leave the Kind field empty. See the discussion in #18526. // leave the Kind field empty. See the discussion in #18526.
qualifiedKind := schema.GroupKind{Group: qualifiedResource.Group, Kind: qualifiedResource.Resource} qualifiedKind := schema.GroupKind{Group: qualifiedResource.Group, Kind: qualifiedResource.Resource}
fieldErrList := field.ErrorList{field.Invalid(field.NewPath("metadata").Child("resourceVersion"), newVersion, "must be specified for an update")} fieldErrList := field.ErrorList{field.Invalid(field.NewPath("metadata").Child("resourceVersion"), resourceVersion, "must be specified for an update")}
return nil, nil, kubeerr.NewInvalid(qualifiedKind, name, fieldErrList) return nil, nil, kubeerr.NewInvalid(qualifiedKind, name, fieldErrList)
} }
if newVersion != version { if resourceVersion != version {
return nil, nil, kubeerr.NewConflict(qualifiedResource, name, fmt.Errorf(OptimisticLockErrorMsg)) return nil, nil, kubeerr.NewConflict(qualifiedResource, name, fmt.Errorf(OptimisticLockErrorMsg))
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment