-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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
shutil.copytree fails when copying NFS to NFS #68752
Comments
shutil.copytree seems to fail when copying files across NFS filesystems. In this example (see bug_demo.py), /tmp is a normal ext4 filesystem and the current working directory is NFS (version 4). Interestingly, it works fine to to copy between ext4 and NFS, just not NFS and NFS (even if it's the same NFS mount). Depending on the specific version of 3.4, there are slightly different errors. For 3.4.0: $ uname -a
Linux compmodels-node 3.13.0-55-generic #94-Ubuntu SMP Thu Jun 18 00:27:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ python3 bug_demo.py Python version info: Copying NFS --> /tmp
Copying /tmp --> NFS
Copying NFS --> NFS
Traceback (most recent call last):
File "/usr/lib/python3.4/shutil.py", line 336, in copytree
copystat(src, dst)
File "/usr/lib/python3.4/shutil.py", line 212, in copystat
_copyxattr(src, dst, follow_symlinks=follow)
File "/usr/lib/python3.4/shutil.py", line 152, in _copyxattr
os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
OSError: [Errno 22] Invalid argument: 'demo_files3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "bug_demo.py", line 27, in <module>
shutil.copytree('demo_files', 'demo_files3')
File "/usr/lib/python3.4/shutil.py", line 339, in copytree
if why.winerror is None:
AttributeError: 'OSError' object has no attribute 'winerror' And for 3.4.3: $ uname -a
Linux compmodels-node-02 3.19.0-21-generic #21-Ubuntu SMP Sun Jun 14 18:31:11 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ python3 bug_demo.py Python version info: Copying NFS --> /tmp
Copying /tmp --> NFS
Copying NFS --> NFS
Traceback (most recent call last):
File "bug_demo.py", line 27, in <module>
shutil.copytree('demo_files', 'demo_files3')
File "/usr/lib/python3.4/shutil.py", line 343, in copytree
raise Error(errors)
shutil.Error: [('demo_files', 'demo_files3', "[Errno 22] Invalid argument: 'demo_files3'")] This is probably related to https://bugs.python.org/issue17076 and my guess is that's also why there is a difference in the error messages between 3.4.0 and 3.4.3. |
Some further information: if I run copystat directly on 3.4.3, I get essentially the same error as on 3.4.0. So really it only looks like the difference is just in how the error is reported: Traceback (most recent call last):
File "bug_demo.py", line 31, in <module>
shutil.copystat('demo_files', 'demo_files3')
File "/usr/lib/python3.4/shutil.py", line 213, in copystat
_copyxattr(src, dst, follow_symlinks=follow)
File "/usr/lib/python3.4/shutil.py", line 153, in _copyxattr
os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
OSError: [Errno 22] Invalid argument: 'demo_files3' Also, I should mention that I did test this on 2.7 as well, and it is not an issue there. |
On a bit of further investigation, the NFS files have an xattr Adding Since the |
There are a number of open issues with copytree originating from copystat. It would be great if someone could pull them all together and propose a solution. Making it optional might indeed be the best solution. |
I'm running into this issue with python 3.5 and a ZFS-backed NFS4 mount. Strace of a setuptools install: |
I'm also affected by this, with Python 3.6. My home directory is on a ZFS-backed NFS share. Basically: Note that also by other tools, such as |
[ https://bugs.python.org/issue24564#msg246278 ]
I think this is an acceptable compromise considering that:
For completeness, other than copytree() also copy2() and move() are affected. |
Related: https://bugs.python.org/issue32073 |
I completely agree with msg322848, both with the suggested fix and with its rationale. A future API improvement could be to have a "strict" mode where errors copying xattr are not silently ignored anymore (if there are src xattr, but they cannot be written, or if src xattr cannot be read, for instance), but the current functionality seems to be "copy xattr if possible", and that should be fixed accordingly. I also opened bpo-36850 arguing that in any case, EINVAL should be ignored when *reading* extended attributes, acknowledging that people might have more problems with ignoring errors on *writing* them when they were present on the source. However, as stated above, I personally vote for the fix suggested in msg322848. |
Nosying Hynek and Larry, as they had done the original code. |
This is still a problem when shutil gets a errno.ENOSYS I hit this bug on Microsoft Azure when I mount an Azure File (managed NFS) into an AKS cluster (managed Kubernetes offering) and try to copy a file from the NFS over to the local disk on the node using shutil.copytree(). The workaround I am using came from this StackOverflow answer: https://stackoverflow.com/a/51635427/3736286 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: