Samba Share .pid permissions issue

4/29/2021

I'll try to concise my issue as much as possible.

Here's what I have:

  • sambashare folder on a raspberry pi
  • kubernetes cluster on some raspberry pi's
  • kubernetes custom plugin to mount fstab https://github.com/fstab/cifs

What I'm trying to do:

  • persist a folder on the container with the right permissions

So here's to the issue. Mounting the folder onto the container works and files get generated including the failing .pid file which tells me rw permissions are valid.

[v3.0.2.4552] System.UnauthorizedAccessException: Access to the path '/config/radarr.pid' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.FileStream.WriteNative(ReadOnlySpan`1 source)
   at System.IO.FileStream.FlushWriteBuffer()
   at System.IO.FileStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at System.IO.StreamWriter.CloseStreamFromDispose(Boolean disposing)
   at System.IO.StreamWriter.Dispose(Boolean disposing)
   at System.IO.TextWriter.Dispose()
   at System.IO.File.WriteAllText(String path, String contents)
   at NzbDrone.Common.Processes.PidFileProvider.Write() in D:\a\1\s\src\NzbDrone.Common\Processes\PidFileProvider.cs:line 37

[Fatal] ConsoleApp: EPIC FAIL!

[v3.0.2.4552] NzbDrone.Common.Exceptions.RadarrStartupException: Radarr failed to start: Unable to write PID file /config/radarr.pid
 ---> System.UnauthorizedAccessException: Access to the path '/config/radarr.pid' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.FileStream.WriteNative(ReadOnlySpan`1 source)
   at System.IO.FileStream.FlushWriteBuffer()
   at System.IO.FileStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at System.IO.StreamWriter.CloseStreamFromDispose(Boolean disposing)
   at System.IO.StreamWriter.Dispose(Boolean disposing)
   at System.IO.TextWriter.Dispose()
   at System.IO.File.WriteAllText(String path, String contents)
   at NzbDrone.Common.Processes.PidFileProvider.Write() in D:\a\1\s\src\NzbDrone.Common\Processes\PidFileProvider.cs:line 37
   --- End of inner exception stack trace ---
   at NzbDrone.Common.Processes.PidFileProvider.Write() in D:\a\1\s\src\NzbDrone.Common\Processes\PidFileProvider.cs:line 42
   at Radarr.Host.Bootstrap.Start(StartupContext startupContext, IUserAlert userAlert, Action`1 startCallback) in D:\a\1\s\src\NzbDrone.Host\Bootstrap.cs:line 37
   at NzbDrone.Console.ConsoleApp.Main(String[] args) in D:\a\1\s\src\NzbDrone.Console\ConsoleApp.cs:line 41

The /config/radarr.pid gets generated from within the container so it absolutely has rw access to it, so I'm guessing the Unable to write PID file /config/radarr.pid message is incorrect and it might have more to do with the execution than read/write permissions.

Here's how I'm mounting the volume from the kubernetes yaml

        - name: master-share-config
          flexVolume:
            driver: "fstab/cifs"
            fsType: "nfs"
            secretRef:
              name: "master-share-secret"
            options:
              networkPath: "//MACHINE_IP_ADDRESS/apps/radarr/"
              mountOptions: "dir_mode=0755,file_mode=0644,uid=k8sadmin,gid=k8sadmin,rw,exec,dev,suid"

Things I've tried that didn't work:

  • a multitude of mountOptions
  • mounting the samba share into the worker machines and use a PersistentVolume in the deployment.yaml (same error exactly)
  • mount as cifs
  • mount as nfs

Things I've tried that did work:

  • Not overwriting the folder on the container
  • PersistentVolume to a location in the worker machine

I've been trying this for a while now, I'm almost certain it's either the setup of samba share or the way the volume is being claimed.

Please note, that I've used the fstab/cibs plugin to help out on debugging this, I'm not keen on remounting a drive over and over again into the containers, but it seemed to work to mount the drive. Having said that, I'm not entirely sure fsType: "nfs" is doing anything as the logs don't state you can do it. But as I said, mounting from /etc/fstab doesn't work either.

If someone has a solution and/or encountered a similar issue before please let me know.

Also, because I was able to run it from a folder on the worker machine, I can only assume it's an issue with the samba or samba claim.

-- Joao Lopes
docker
kubernetes
samba

1 Answer

4/29/2021

Ok, after typing all that I've found my own question. Started to investigate if fsType: "nfs" was working. Turns out I wasn't using nfs at all, not even nfs mount tools were installed.

After fixing all of that it just worked.

I'll leave it here hopefully it can help others.

-- Joao Lopes
Source: StackOverflow