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

Fix lakectl local diff #7563

Merged
merged 11 commits into from
Mar 19, 2024
Merged

Fix lakectl local diff #7563

merged 11 commits into from
Mar 19, 2024

Conversation

idanovo
Copy link
Contributor

@idanovo idanovo commented Mar 17, 2024

Closes #(Insert issue number closed by this PR)

Change Description

Background

Share context and relevant information for the PR: offline discussions, considerations, design decisions etc.

Bug Fix

If this PR is a bug fix, please let us know about:

  1. Problem - The reason for opening the bug
  2. Root cause - Discovered root cause after investigation
  3. Solution - How the bug was fixed

New Feature

If this PR introduces a new feature, describe it here.

Testing Details

How were the changes tested?

Breaking Change?

Does this change break any existing functionality? (API, CLI, Clients)

Additional info

Logs, outputs, screenshots of changes if applicable (CLI / GUI changes)

Contact Details

How can we get in touch with you if we need more info? (ex. email@example.com)

Copy link

E2E Test Results - DynamoDB Local - Local Block Adapter

10 passed

@idanovo idanovo self-assigned this Mar 17, 2024
@idanovo idanovo linked an issue Mar 17, 2024 that may be closed by this pull request
@idanovo idanovo added the include-changelog PR description should be included in next release changelog label Mar 17, 2024
@idanovo idanovo changed the title Add test case of the bug Fix lakectl local diff Mar 18, 2024
@idanovo idanovo requested a review from N-o-Z March 18, 2024 11:14
@idanovo idanovo marked this pull request as ready for review March 18, 2024 11:14
Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

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

Great job!
Some comments on the code and tests.
One important thing I think we have to do before merging:
Lets check (manually) that we did not break compatibility with windows...

if err != nil {
return err
}
if info.IsDir() || diffShouldIgnore(info.Name()) {
if info.IsDir() || diffShouldIgnore(info.Name()) || strings.HasPrefix(e.RelativeKey, local.CacheDirName) {
Copy link
Member

Choose a reason for hiding this comment

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

We don't actually use the cache so we can just pass an empty path and remove this

return nil
}
localPath := strings.TrimPrefix(path, rightPath)
filePath := e.RelativeKey
localPath := strings.TrimPrefix(filePath, rightPath)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this? Also if we do, do we need the next line then?

@@ -19,7 +19,7 @@ import (
"github.com/treeverse/lakefs/pkg/block/params"
)

const cacheDirName = "_lakefs_cache"
const CacheDirName = "_lakefs_cache"
Copy link
Member

Choose a reason for hiding this comment

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

Can revert this as we don't really use the cache

return nil, err
}
uri := url.URL{Scheme: "local", Path: absPath}
adapter, err := local.NewAdapter(absPath, local.WithRemoveEmptyDir(false), local.WithAllowedExternalPrefixes([]string{"/"}))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
adapter, err := local.NewAdapter(absPath, local.WithRemoveEmptyDir(false), local.WithAllowedExternalPrefixes([]string{"/"}))
adapter, err := local.NewAdapter("", local.WithRemoveEmptyDir(false), local.WithAllowedExternalPrefixes([]string{absPath}))

fd, err = os.Create(filepath.Join(dataDir, "subdir", "test.txt"))
require.NoError(t, err)
fd, err = os.Create(filepath.Join(dataDir, "subdir-a", "test.txt"))
require.NoError(t, err)
Copy link
Member

Choose a reason for hiding this comment

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

I think this is missing verification for this test case (on the status)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the end of the test, we verify that lakectl status returned no diff.
In the original bug, we've got changes after committing

Copy link
Member

Choose a reason for hiding this comment

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

Understood, but we still need to fix the verify status output

@@ -557,7 +557,7 @@ func TestLakectlFsUpload(t *testing.T) {
})
t.Run("single_file_with_recursive", func(t *testing.T) {
vars["FILE_PATH"] = "data/ro/ro_1k.0"
RunCmdAndVerifyFailure(t, Lakectl()+" fs upload --recursive -s files/ro_1k lakefs://"+repoName+"/"+mainBranch+"/"+vars["FILE_PATH"], false, "\ndiff 'local://files/ro_1k/' <--> 'lakefs://${REPO}/${BRANCH}/${FILE_PATH}'...\nlstat files/ro_1k/: not a directory\nError executing command.\n", vars)
Copy link
Member

Choose a reason for hiding this comment

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

How/Why was this changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The walk function of local storage tries to create a new folder for caching

Copy link
Member

Choose a reason for hiding this comment

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

Let's not do that, let's not use caching (see other comments)

@idanovo idanovo requested a review from N-o-Z March 18, 2024 17:50
Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

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

Awesome!
BTW this probably fixed a bug also with local storage import on Windows 🎉

@idanovo idanovo merged commit 839f374 into master Mar 19, 2024
35 checks passed
@idanovo idanovo deleted the fix-lakectl-local-walk-order branch March 19, 2024 08:46
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.

[Bug]: lakectl local diff read object's prefixes in a wrong order
2 participants