该插件有个问题,就是当CSI插件重启之后,会丢失调内部负责远程连接s3服务的s3fs进程,因此会导致业务Pod内部挂载目录失效,访问/var/lib/kubelet/pods/<pod-uuid>/volumes/<pod-uuid>kubernetes.io~csi/<pvc-name>/mount目录会出现Transport endpoint is not connected的问题。此时为了让业务Pod能够正常访问,需要重启业务Pod,但这种方式很不优雅。
解决思路
为了解决Transport endpoint is not connected问题,首先需要恢复s3fs进程,但恢复进程依赖几个数据:Pvc的名称、Pod的uid、s3服务的地址以及访问使用的AK/SK等。有两种方式可以保存这类数据:
业务容器没有挂载成功的原因是整个恢复流程并没有触发kubelet执行umount/mount来将pvc重新挂载到业务容器。解决方式与CSI插件的/var/lib/kubelet/pods/<targetUid>/volumes/<targetUid>kubernetes.io~csi/<targetPvc-name>/mount一样,执行umount在mount即可。但这么做首先要知道Pod映射到主机上的挂载路径,这样就比较麻烦了,因为pod映射到主机上的路径与使用的CRI相关,如果朝这一方向下去,难度比较大,在CSI Volume Plugins in Kubernetes Design Doc中也提过,正常情况下是由kubelet执行的:
The volume manager component of kubelet, notices a mounted CSI volume, referenced by a pod that has been deleted or terminated, so it calls the in-tree CSI volume plugin’s UnmountDevice method which is a no-op and returns immediately.
Next kubelet calls the in-tree CSI volume plugin’s unmount (teardown) method, which causes the in-tree volume plugin to issue a NodeUnpublishVolume call via the registered unix domain socket to the local CSI driver. If this call fails from any reason, kubelet re-tries the call periodically.
Upon successful completion of the NodeUnpublishVolume call the specified path is unmounted from the pod container.
该插件有个问题,就是当CSI插件重启之后,会丢失调内部负责远程连接s3服务的s3fs进程,因此会导致业务Pod内部挂载目录失效,访问/var/lib/kubelet/pods/<pod-uuid>/volumes/<pod-uuid>kubernetes.io~csi/<pvc-name>/mount目录会出现Transport endpoint is not connected的问题。此时为了让业务Pod能够正常访问,需要重启业务Pod,但这种方式很不优雅。
解决思路
为了解决Transport endpoint is not connected问题,首先需要恢复s3fs进程,但恢复进程依赖几个数据:Pvc的名称、Pod的uid、s3服务的地址以及访问使用的AK/SK等。有两种方式可以保存这类数据:
业务容器没有挂载成功的原因是整个恢复流程并没有触发kubelet执行umount/mount来将pvc重新挂载到业务容器。解决方式与CSI插件的/var/lib/kubelet/pods/<targetUid>/volumes/<targetUid>kubernetes.io~csi/<targetPvc-name>/mount一样,执行umount在mount即可。但这么做首先要知道Pod映射到主机上的挂载路径,这样就比较麻烦了,因为pod映射到主机上的路径与使用的CRI相关,如果朝这一方向下去,难度比较大,在CSI Volume Plugins in Kubernetes Design Doc中也提过,正常情况下是由kubelet执行的:
The volume manager component of kubelet, notices a mounted CSI volume, referenced by a pod that has been deleted or terminated, so it calls the in-tree CSI volume plugin’s UnmountDevice method which is a no-op and returns immediately.
Next kubelet calls the in-tree CSI volume plugin’s unmount (teardown) method, which causes the in-tree volume plugin to issue a NodeUnpublishVolume call via the registered unix domain socket to the local CSI driver. If this call fails from any reason, kubelet re-tries the call periodically.
Upon successful completion of the NodeUnpublishVolume call the specified path is unmounted from the pod container.