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

lakectl local: add option to skip non regular files #8055

Merged
merged 5 commits into from
Aug 6, 2024

Conversation

N-o-Z
Copy link
Member

@N-o-Z N-o-Z commented Aug 5, 2024

Closes #8054

Change Description

Background

Add option which allows ignoring symbolic links found in local directory instead of failing the sync.
This will allow users to use lakectl local even if they have symlinks in their sync directory

New Feature

Added new configuration parameter: lakectl.local.skip_non_regular_files - which is disabled by default.
When set, lakectl local will ignore non regular files found in local directory when performing diff and when syncing local path with remote.

Testing Details

Tested manually

Breaking Change?

No

Additional info

Full context: https://github.com/treeverse/product/issues/450

@N-o-Z N-o-Z added area/lakectl Issues related to lakeFS' command line interface (lakectl) include-changelog PR description should be included in next release changelog lakectl-local labels Aug 5, 2024
@N-o-Z N-o-Z requested review from arielshaqed and a team August 5, 2024 16:50
@N-o-Z N-o-Z self-assigned this Aug 5, 2024
Copy link

github-actions bot commented Aug 5, 2024

E2E Test Results - DynamoDB Local - Local Block Adapter

13 passed

Copy link

github-actions bot commented Aug 5, 2024

E2E Test Results - Quickstart

10 passed

Copy link
Contributor

@arielshaqed arielshaqed left a comment

Choose a reason for hiding this comment

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

Not a fan of EvalSymlink, which has potential to cause trouble. Requesting replacing it with the POSIX API.

Also... How well are we testing this?

@@ -94,6 +94,10 @@ type Configuration struct {
// setting FixSparkPlaceholder to true will change spark placeholder with the actual location. for more information see https://github.com/treeverse/lakeFS/issues/2213
FixSparkPlaceholder bool `mapstructure:"fix_spark_placeholder"`
}
Local struct {
// IgnoreSymLinks - By default lakectl local fails if local directory contains a symbolic link. When set, lakectl will ignore the symbolic links instead.
IgnoreSymLinks bool `mapstructure:"ignore_symlinks"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider renaming to SkipSymlinks. "Ignore" is a bit unclear?

@@ -179,11 +179,19 @@ func VerifySafeFilename(absPath string) error {
if !filepath.IsAbs(absPath) {
return fmt.Errorf("relative path not allowed: %w", ErrInvalidPath)
}
filename, err := filepath.EvalSymlinks(absPath)
if err != nil {
if err := EvalSymlink(absPath); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be messy and slow. Also the implementation may miss the case of a dumping to itself - depending on how cyclic symlink expansion is handled.
Prefer to use the Symlink bit on FileMode returned by Stat. It is faster, precise, and does not depend on precisely understanding the implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added tests + modified configuration param and check for all irregular files

@N-o-Z N-o-Z requested a review from arielshaqed August 6, 2024 01:40
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.

LGTM - thanks for the quick fix. And you didn't just test manually, you added some unit tests to prevent a regression!

Added 2 comments, on minor and the other I'm not sure if that case is even possible..

@@ -179,12 +179,5 @@ func VerifySafeFilename(absPath string) error {
if !filepath.IsAbs(absPath) {
return fmt.Errorf("relative path not allowed: %w", ErrInvalidPath)
}
filename, err := filepath.EvalSymlinks(absPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

Function comment needs a do over

}
return false, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Can in Irregular file be in the ignoreFileList?

Copy link
Member Author

Choose a reason for hiding this comment

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

The ignore file list is a list of files we decided to ignore. It should not contain any irregular files and if at some point it would - we'd need to resolve that internally (it's not something controlled by the user)

Copy link
Contributor

@arielshaqed arielshaqed left a comment

Choose a reason for hiding this comment

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

Neat, thanks!

@@ -94,6 +94,10 @@ type Configuration struct {
// setting FixSparkPlaceholder to true will change spark placeholder with the actual location. for more information see https://github.com/treeverse/lakeFS/issues/2213
FixSparkPlaceholder bool `mapstructure:"fix_spark_placeholder"`
}
Local struct {
// SkipIrregularFiles - By default lakectl local fails if local directory contains a symbolic link. When set, lakectl will ignore the symbolic links instead.
SkipIrregularFiles bool `mapstructure:"skip_irregular_files"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer skip_not_regular_files. I cannot find any references to "irregular files", even we say "not a regular file" in the error message.

Or reverse the flag and give it a positive description and default true with fail_on_non_regular_file.

@@ -94,6 +94,10 @@ type Configuration struct {
// setting FixSparkPlaceholder to true will change spark placeholder with the actual location. for more information see https://github.com/treeverse/lakeFS/issues/2213
FixSparkPlaceholder bool `mapstructure:"fix_spark_placeholder"`
}
Local struct {
// SkipIrregularFiles - By default lakectl local fails if local directory contains a symbolic link. When set, lakectl will ignore the symbolic links instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// SkipIrregularFiles - By default lakectl local fails if local directory contains a symbolic link. When set, lakectl will ignore the symbolic links instead.
// SkipNotRegularegularFiles - If set, skip any non-regular files encountered but keep working. If
// clear, fail if any non-regular file is encountered. Non-regular files include symbolic links,
// UNIX-domain sockets, devices, and FIFOs (named pipes).

@N-o-Z N-o-Z merged commit aec418c into master Aug 6, 2024
36 checks passed
@N-o-Z N-o-Z deleted the task/lakectl-local-ignore-symlinks-8054 branch August 6, 2024 15:57
@N-o-Z N-o-Z changed the title lakectl local: add option to ignore symlinks lakectl local: add option to ignore non regular files Aug 7, 2024
@N-o-Z N-o-Z changed the title lakectl local: add option to ignore non regular files lakectl local: add option to skip non regular files Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/lakectl Issues related to lakeFS' command line interface (lakectl) include-changelog PR description should be included in next release changelog lakectl-local
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lakectl local: add option to ignore symbolic links
3 participants