non ASCII filenames on GCP persistantvolume not displaying correctly

12/9/2019

I am moving our .net core(2.1) API from IIS to linux containers in kubernetes in GCP and am having some trouble with files being retrieved from the mounted fileserver when the filenames contain non ASCII characters. Similar to this GitHub issue, but these are standard UTF8 characters. åäö

var di = new DirectoryInfo(directory);
if (di.Exists)
{
    var dFiles = di.GetFiles("*.pdf", SearchOption.TopDirectoryOnly);
    Log.Information($"Files found in {di.Name} : {string.Join(",", dFiles.Select(f => f.Name))}");
    //Log.Information($"Length of files found in {di.Name} : {string.Join(",", dFiles.Select(f => f.Length))}");
    files.AddRange(dFiles);
}

bost�der.pdf is returned, but it should be bostäder.pdf.

In all other cases, characters are handled correctly, such as reading from the database. It is only when reading filenames that there is a problem. I get a FileNotFoundException when attempting to read the length of these files. LastWriteTime returns 1601-01-01.

The file is in GCP filestore and mounted to the kubernetes cluster using a PersistentVolume and PersistentVolumeClaim and then mounted to the containers.

I have tried to alter the currentthread culture when running this method, but with no luck. The same code works fine on the windows/IIS version using symlinks to point to the fileshare.

If I give the path of the file directly using new FileInfo rather than DirectoryInfo.GetFiles then the resulting FileInfo object returns the correctly encoded filename although the FileInfo.Length method still causes a FileNotFoundException.

Have used multiple Docker images

  • mcr.microsoft.com/dotnet/core/aspnet:2.1-bionic
  • mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim

Have also attempted to set the

ENV LC_ALL=sv_SE.UTF-8 \
    LANG=sv_SE.UTF-8

in the Dockerfile with no luck. Any ideas what else I can try?

Edit:

I have now investigated further and the problem is not with .net, but with the mounted drive on the pods. Local files are shown correctly using ls, but the files on the mount are not. So it appears to be something to do with the way the drive is mounted. I have a persistantvolume.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: fileserver
spec:
  capacity:
    storage: 1T
  accessModes:
  - ReadWriteMany
  nfs:
    path: /mymount
    server: 1.2.3.4

and a persistantvolumeclaim

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: fileserver-claim
spec:
  accessModes:
  - ReadWriteMany
  storageClassName: ""
  resources:
    requests:
      storage: 1T

which is mounted to my pods using

volumeMounts:
          - mountPath: /mnt/fileserver
            name: pvc

and

volumes:
      - name: pvc
        persistentVolumeClaim:
          claimName: fileserver-claim
          readOnly: false

in my deployment.yaml

Edit 2:

Seems to be a problem with Cloud Filestore only supporting NFSv3 - is there any way that I could read these files using NFSv3

-- pantsleftinwash
filesystems
google-cloud-filestore
kubernetes
linux
nfs

0 Answers