失败的代码在基于python:3.6-stretch
debian 的 Docker 容器中运行。它发生在 Django 将文件从一个 Docker 卷移动到另一个卷时。
当我在 MacOS 10 上测试时,它可以正常工作。在这里,Docker 容器使用 docker-compose 启动,并在本地机器上使用常规 Docker 卷。
部署到 Azure(AKS - Azure 上的 Kubernetes),移动文件成功,但复制统计信息失败,并出现以下错误:
File "/usr/local/lib/python3.6/site-packages/django/core/files/move.py", line 70, in file_move_safe
copystat(old_file_name, new_file_name)
File "/usr/local/lib/python3.6/shutil.py", line 225, in copystat
_copyxattr(src, dst, follow_symlinks=follow)
File "/usr/local/lib/python3.6/shutil.py", line 157, in _copyxattr
names = os.listxattr(src, follow_symlinks=follow_symlinks)
OSError: [Errno 38] Function not implemented: '/some/path/file.pdf'
ReadWriteMany
Azure 上的卷是具有访问模式的持久卷声明。
现在,copystat
记录为:
copystat() 永远不会返回失败。
https://docs.python.org/3/library/shutil.html
我的问题是:
- 这是一个“错误”,因为文档说它应该“永远不会返回失败”吗?
- 我可以节省地尝试/排除这个错误,因为有问题的文件被移动了(它只会在稍后失败,同时尝试复制统计信息)
- 我可以更改解决此问题的 Azure 设置吗?(可能不是)
这里在 Azure 本身的机器上进行了一些小测试:
root:/media/documents# ls -al
insgesamt 267
drwxrwxrwx 2 1000 1000 0 Jul 31 15:29 .
drwxrwxrwx 2 1000 1000 0 Jul 31 15:29 ..
-rwxrwxrwx 1 1000 1000 136479 Jul 31 16:48 orig.pdf
-rwxrwxrwx 1 1000 1000 136479 Jul 31 15:29 testfile
root:/media/documents# lsattr
--S-----c-jI------- ./orig.pdf
--S-----c-jI------- ./testfile
root:/media/documents# python
Python 3.6.6 (default, Jul 17 2018, 11:12:33)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copystat('orig.pdf', 'testfile')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/shutil.py", line 225, in copystat
_copyxattr(src, dst, follow_symlinks=follow)
File "/usr/local/lib/python3.6/shutil.py", line 157, in _copyxattr
names = os.listxattr(src, follow_symlinks=follow_symlinks)
OSError: [Errno 38] Function not implemented: 'orig.pdf'
>>> shutil.copystat('orig.pdf', 'testfile', follow_symlinks=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/shutil.py", line 225, in copystat
_copyxattr(src, dst, follow_symlinks=follow)
File "/usr/local/lib/python3.6/shutil.py", line 157, in _copyxattr
names = os.listxattr(src, follow_symlinks=follow_symlinks)
OSError: [Errno 38] Function not implemented: 'orig.pdf'
>>>