diff --git a/pkg/client/fake/client.go b/pkg/client/fake/client.go index 91886d278f..d4a47c0974 100644 --- a/pkg/client/fake/client.go +++ b/pkg/client/fake/client.go @@ -403,6 +403,7 @@ func (t versionedTracker) update(gvr schema.GroupVersionResource, obj runtime.Ob if err := copyStatusFrom(obj, oldObject); err != nil { return fmt.Errorf("failed to copy non-status field for object with status subresouce: %w", err) } + obj = oldObject.DeepCopyObject().(client.Object) } else { // copy status from original object if err := copyStatusFrom(oldObject, obj); err != nil { @@ -436,6 +437,14 @@ func (t versionedTracker) update(gvr schema.GroupVersionResource, obj runtime.Ob intResourceVersion++ accessor.SetResourceVersion(strconv.FormatUint(intResourceVersion, 10)) + // obtain the current obj accessor's pointer, + // so we can make an update on the current obj + currentAccessor, err := meta.Accessor(obj) + if err != nil { + return fmt.Errorf("failed to get accessor for object: %w", err) + } + currentAccessor.SetResourceVersion(strconv.FormatUint(intResourceVersion, 10)) + if !deleting && !deletionTimestampEqual(accessor, oldAccessor) { return fmt.Errorf("error: Unable to edit %s: metadata.deletionTimestamp field is immutable", accessor.GetName()) }