mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
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 ```
This commit is contained in:
commit
4344d33772
@ -586,19 +586,15 @@ func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest.
|
||||
} else {
|
||||
// Check if the object's resource version matches the latest
|
||||
// resource version.
|
||||
newVersion, err := e.Storage.Versioner().ObjectResourceVersion(obj)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if newVersion == 0 {
|
||||
if resourceVersion == 0 {
|
||||
// TODO: The Invalid error should have a field for Resource.
|
||||
// After that field is added, we should fill the Resource and
|
||||
// leave the Kind field empty. See the discussion in #18526.
|
||||
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)
|
||||
}
|
||||
if newVersion != version {
|
||||
if resourceVersion != version {
|
||||
return nil, nil, kubeerr.NewConflict(qualifiedResource, name, fmt.Errorf(OptimisticLockErrorMsg))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user