On a KVM VM running Centos 7.5, I have a service running that writes to an NFS-mounted file system. When a shutdown or reboot is issued, the service is throwing an exception that indicates that it does not have permission to write to a directory that is on this NFS file system. If, instead, I manually stop the service using systemctl, the service completes normally, i.e., no exception is thrown. Because of the exception, I am speculating that, before my service can write its final data to the NFS mount, the OS is shutting down the NFS service, thus removing the mounted volume. When the service tries to write to this location, it cannot because the directory is gone. Do NFS mounts get removed before user services are told to stop?
What is odd about this is that I have two versions of the VM. This one, that is has the issue, has an LUKS-encrypted root partition. The other VM has the same code but is running on an unencrypted partition. The OS is the same on both. I don't see why this would stimulate this issue but it is the only difference in the VMs.
Is there some way I can ensure that my service is done before NFS is killed?