-
Notifications
You must be signed in to change notification settings - Fork 395
API: Add support to copy object logical mode #9500
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
base: master
Are you sure you want to change the base?
Conversation
Make a shallow copy of an object, copy metadata only. Limited to the same repository and branch. Experimental.
📚 Documentation preview at https://pr-9500.docs-lakefs-preview.io/ (Updated: 9/9/2025, 2:46:00 PM - Commit: 6c92dbd) |
if srcRepository != destRepository { | ||
return nil, fmt.Errorf("%w: clone must be between the same repository", graveler.ErrInvalid) | ||
} | ||
if srcRef != destBranch { | ||
return nil, fmt.Errorf("%w: clone must be between the same branch", graveler.ErrInvalid) | ||
} |
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.
I think this should default to the CopyEntry
behaviour
dstEntry := *srcEntry | ||
dstEntry.Path = destPath | ||
dstEntry.CreationDate = time.Now() | ||
err = c.CreateEntry(ctx, destRepository, destBranch, dstEntry, opts...) |
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.
You're not checking if you're allowed to use the same physical address! There are possible races with GC!
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.
What are the conditions to allowed? this version does not take responsibility and it can cause issues if the caller will cause this race with GC.
It assume that the caller will use this API on uncommitted data.
@@ -2765,6 +2765,29 @@ func (c *Catalog) PrepareGCUncommitted(ctx context.Context, repositoryID string, | |||
}, nil | |||
} | |||
|
|||
func (c *Catalog) CloneEntry(ctx context.Context, srcRepository, srcRef, srcPath, destRepository, destBranch, destPath string, opts ...graveler.SetOptionsFunc) (*DBEntry, error) { |
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.
Why not change CopyEntry
behavior and create CloneEntry
?
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.
The GC grace time is associated to the physical object creation. Here I'm not accessing the underlaying storage and I can't verify based on the entry if it is a valid 'clone' candidate.
This is why the additional 'mode' where the caller is responsible in the clone - assume that lakeFSFS will create clones while the data is uncommitted on the same branch.
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.
@itaiad200 do you have a suggestion when to verify that the copy is a safe clone on lakeFS?
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.
LGTM
IMO the documentation should be clear what this does and clear that there is some risk that the caller should consider
expectedError: graveler.ErrNotFound, | ||
}, | ||
{ | ||
name: "successful_clone_with_metadata", |
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.
🥇
Co-authored-by: guy-har <[email protected]>
Co-authored-by: guy-har <[email protected]>
Make a shallow copy of an object, copy metadata only.
Limited to the same repository and branch.
Experimental
Closes #9499