Skip to content
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

3085 lakectl ingest adds multiple excess slash to object name #3108

Merged

Conversation

itaidavid
Copy link
Contributor

@itaidavid itaidavid commented Mar 23, 2022

Fixed ingest function not to add a "/" if the to path ends wirh rhe branch name (and thus ends with "/")
Fixed S3 Walk to correctly trim prefixes: with "/" if exists, and partial prefixes too

Tested manually with --from s3:://mybucket/data/, s3:://mybucket/data and s3:://mybucket/da
Opened #3109 for adding tests

@itaidavid itaidavid added the include-changelog PR description should be included in next release changelog label Mar 23, 2022
@itaidavid itaidavid linked an issue Mar 24, 2022 that may be closed by this pull request
Copy link
Contributor

@itaiad200 itaiad200 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix! Looking to see the tests, but probably not part of this PR.
See my 2 comments

@@ -31,6 +31,10 @@ func (s *S3Walker) Walk(ctx context.Context, storageURI *url.URL, walkFn func(e
var continuation *string
const maxKeys = 1000
prefix := strings.TrimLeft(storageURI.Path, "/")
var trimPrefix string
if idx := strings.LastIndex(prefix, "/"); idx != -1 {
trimPrefix = prefix[:idx+1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me some time to understand why this is the right value, it's based on the ObjectStoreEntry definition:

	// RelativeKey represents a path relative to prefix (or directory). If none specified, will be identical to FullKey

Would you mind adding a comment explaining the trimPrefix part?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@itaidavid itaidavid force-pushed the 3085-lakectl-ingest-adds-multiple-excess-slash-to-object-name branch from 3de4fcf to 4796114 Compare March 24, 2022 16:58
@arielshaqed
Copy link
Contributor

Please rebase on origin/master (or merge that branch in): the name of a required test has changed, and GitHub is waiting for the new name.

https://lakefs.slack.com/archives/C01APUNTSGH/p1648120054377969?thread_ts=1648120054.377969&cid=C01APUNTSGH

@itaidavid itaidavid force-pushed the 3085-lakectl-ingest-adds-multiple-excess-slash-to-object-name branch from 1a65f03 to 15830eb Compare March 25, 2022 13:34
itaidavid and others added 3 commits March 25, 2022 09:18
Co-authored-by: johnnyaug <yoni.augarten@treeverse.io>
Co-authored-by: johnnyaug <yoni.augarten@treeverse.io>
@itaidavid itaidavid merged commit 85f6878 into master Mar 25, 2022
@johnnyaug johnnyaug deleted the 3085-lakectl-ingest-adds-multiple-excess-slash-to-object-name branch March 25, 2022 17:59
@johnnyaug johnnyaug restored the 3085-lakectl-ingest-adds-multiple-excess-slash-to-object-name branch March 25, 2022 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include-changelog PR description should be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lakectl ingest adds multiple excess "/" to object name
4 participants