Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Copy mode: files in different source directories end up in the same destination dir #525

Closed
kcgthb opened this issue Jul 19, 2023 · 1 comment · Fixed by #539
Closed
Assignees
Labels
Milestone

Comments

@kcgthb
Copy link
Contributor

kcgthb commented Jul 19, 2023

Copying multiple files located in different source directories end up in the destination files being created in the same destination directory. The effective destination directory is the source dir of the first file in the list.

To reproduce this, consider the following source tree:

# tree /tmp/test/
/tmp/test/
├── dir1
│   └── file2
└── file1

1 directory, 2 files

Copying /tmp/test/file1 and /tmp/test/dir1/file2 to sh03-sn01 results in file1 and file2 being copied in the directory where file1 was on the source machine (/tmp/test/).

# clush -d -c /tmp/test/file1 /tmp/test/dir1/file2 -w sh03-sn01
DEBUG:root:clush: STARTING DEBUG
Changing max open files soft limit from 14096 to 8192
User interaction: True
Create STDIN worker: False
clush: nodeset=sh03-sn01 fanout=512 [timeout conn=15.0 cmd=0.0] copy sources=['/tmp/test/file1', '/tmp/test/dir1/file2'] dest=/tmp/test/
SCPCLIENT: scp -oConnectTimeout=15 /tmp/test/file1 [sh03-sn01]:/tmp/test/
SCPCLIENT: scp -oConnectTimeout=15 /tmp/test/dir1/file2 [sh03-sn01]:/tmp/test/
`/tmp/test/dir1/file2' -> sh03-sn01:`/tmp/test/'
`/tmp/test/file1' -> sh03-sn01:`/tmp/test/'
DEBUG:ClusterShell.Worker.EngineClient:<EnginePort at 0x139629430609104 (streams=(8, 9))>: dropped msg: (<function _abort at 0x7efe0333aa28>, (False,), {})

Running with -d shows the 2 scp commands being used:

SCPCLIENT: scp -oConnectTimeout=15 /tmp/test/file1 [sh03-sn01]:/tmp/test/
SCPCLIENT: scp -oConnectTimeout=15 /tmp/test/dir1/file2 [sh03-sn01]:/tmp/test/

Here's the resulting destination tree:

# ssh sh03-sn01 tree /tmp/test/
/tmp/test/
├── file1
└── file2

The expected result would be to get the same directory structure recreated on the destination machine, that is:

  • file1 in /tmp/test
  • file2 in /tmp/test/dir1
@thiell thiell added this to the 1.9.2 milestone Sep 17, 2023
@thiell thiell self-assigned this Sep 17, 2023
@thiell thiell added the Scripts label Sep 17, 2023
@thiell
Copy link
Collaborator

thiell commented Sep 18, 2023

Thanks! Great find! The current code (1.9.1) supports multiple source files but if --dest is NOT specified, the dirname() of the first source file is used as the destination directory. This is a limitation that should be fixed:

options.dest_path = join(dirname(abspath(args[0])), '')

We use a call to task.copy() per source file so the problem resides in Clush.py only.

thiell added a commit to thiell/clustershell that referenced this issue Sep 28, 2023
When multiple files or directories are specified as arguments with
--[r]copy, and --dest is omitted, use each argument's dirnname for each
destination, instead of the dirname of the first argument only.

Fixes cea-hpc#525.
github-merge-queue bot pushed a commit that referenced this issue Sep 29, 2023
When multiple files or directories are specified as arguments with
--[r]copy, and --dest is omitted, use each argument's dirnname for each
destination, instead of the dirname of the first argument only.

Fixes #525.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants