long paths must be enabled on Windows to fix obscure errors in applications that are accessing SMB content via volume mounts
doctorpangloss opened this issue · comments
What happened:
Python 3.11 os.path.getmtime
will error with an arcane WinError 87
on a path that is actually quite short from the application's point of view but very long because it is touching a long Windows SMB directory mount path.
Example error:
[ERROR] An error occurred (application specific mumbo jumbo)
Traceback (most recent call last):
....
File "xxx.py", line 214, in xyz
if os.path.getmtime(folder) != time_modified:
^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen genericpath>", line 55, in getmtime
OSError: [WinError 87] The parameter is incorrect: 'C:\\smb-mount\\some\\short\\path'
What is the real path? Related error appeared in Kubelet events:
Warning Failed 60s kubelet Error: failed to generate container "64734c626aa7850738775d9da28e6240fa73b3c2529be337b2d5e77cb13bccdd" spec: failed to generate spec: failed to stat "c:\\var\\lib\\kubelet\\pods\\bda20205-6274-4f8e-9094-21fedabd5ab8\\volumes\\kubernetes.io~csi\\pvc-365af285-dd45-4376-86a8-64fa28c78f49\\mount": CreateFile c:\var\lib\kubelet\pods\bda20205-6274-4f8e-9094-21fedabd5ab8\volumes\kubernetes.io~csi\pvc-365af285-dd45-4376-86a8-64fa28c78f49\mount: Access is denied.
The underlying issue is that the SMB mount directory on the host is already very very long. Once longpaths were enabled, everything worked.
What you expected to happen:
You shouldn't
How to reproduce it:
- Disable long paths using
reg add 'HKLM\SYSTEM\CurrentControlSet\Control\FileSystem' /v LongPathsEnabled /t REG_DWORD /d 0 /f
on the host. Unclear if this has any effect inside a container. - Mount an SMB PVC on Windows.
- Create 100 characters worth of path inside of it.
- run Python
os.path.getmtime
on the path and observe an exception. - Enable long paths using
reg add 'HKLM\SYSTEM\CurrentControlSet\Control\FileSystem' /v LongPathsEnabled /t REG_DWORD /d 1 /f
- Run the same python snippet and observe everything works.
Anything else we need to know?:
Long paths should be enabled on a Windows system with:
reg add 'HKLM\SYSTEM\CurrentControlSet\Control\FileSystem' /v LongPathsEnabled /t REG_DWORD /d 1 /f
This isn't the default on Windows 2022.
Environment:
- CSI Driver version:
image: registry.k8s.io/sig-storage/smbplugin:v1.14.0
imageID: registry.k8s.io/sig-storage/smbplugin@sha256:4e97e6f8c122c87253c89fce466e760f88122aa4a7b21677fad4c603144cc0dd
- Kubernetes version (use
kubectl version
):
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.3", GitCommit:"25b4e43193bcda6c7328a6d147b1fb73a33f1598", GitTreeState:"clean", BuildDate:"2023-06-14T09:53:42Z", GoVersion:"go1.20.5", Compiler:"gc", Platform:"windows/amd64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.2+k0s", GitCommit:"fc04e732bb3e7198d2fa44efa5457c7c6f8c0f5b", GitTreeState:"clean", BuildDate:"2023-03-02T19:21:48Z", GoVersion:"go1.19.6", Compiler:"gc", Platform:"linux/amd64"}
- OS (e.g. from /etc/os-release): Windows Server 2022 Datacenter
- Kernel (e.g.
uname -a
): 10.0.20348.1970
thanks for the info, I don't think this is related to smb csi driver.