Skip to content

Commit 3135cea

Browse files
committed
add ResourceVersion check to Preconditions#Check
1 parent 64ecf9d commit 3135cea

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: staging/src/k8s.io/apiserver/pkg/storage/interfaces.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,14 @@ func (p *Preconditions) Check(key string, obj runtime.Object) error {
128128
objMeta.GetUID())
129129
return NewInvalidObjError(key, err)
130130
}
131+
if p.ResourceVersion != nil && *p.ResourceVersion != objMeta.GetResourceVersion() {
132+
err := fmt.Sprintf(
133+
"Precondition failed: ResourceVersion in precondition: %v, ResourceVersion in object meta: %v",
134+
*p.ResourceVersion,
135+
objMeta.GetResourceVersion())
136+
return NewInvalidObjError(key, err)
137+
}
131138
return nil
132-
133139
}
134140

135141
// Interface offers a common interface for object marshaling/unmarshaling operations and

0 commit comments

Comments
 (0)