From 8728f0519042cd42df253e7e1570f6799e0d9a3d Mon Sep 17 00:00:00 2001 From: James Munson Date: Wed, 6 Mar 2024 17:53:17 -0700 Subject: [PATCH] fix(csi): Add node info to failed mount logging. Make csi-plugin mount of host root conformant to standard and ns utils Signed-off-by: James Munson (cherry picked from commit ffe359d4f04574fc295f95ca4ad9ba687ce4aab2) --- csi/deployment.go | 2 +- csi/node_server.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/csi/deployment.go b/csi/deployment.go index 073b7e60ec..faeb45d9f6 100644 --- a/csi/deployment.go +++ b/csi/deployment.go @@ -414,7 +414,7 @@ func NewPluginDeployment(namespace, serviceAccount, nodeDriverRegistrarImage, li }, { Name: "host", - MountPath: "/rootfs", // path is required for namespaced mounter + MountPath: "/host", MountPropagation: &MountPropagationBidirectional, }, { diff --git a/csi/node_server.go b/csi/node_server.go index b6c84dc74f..21bcf5c47a 100644 --- a/csi/node_server.go +++ b/csi/node_server.go @@ -23,6 +23,8 @@ import ( "github.com/longhorn/longhorn-manager/csi/crypto" + lhns "github.com/longhorn/go-common-libs/ns" + longhornclient "github.com/longhorn/longhorn-manager/client" longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2" ) @@ -269,6 +271,16 @@ func (ns *NodeServer) nodeStageSharedVolume(volumeID, shareEndpoint, targetPath if err == nil { return nil } + // Still failed. Log with mounting node and kernel version for possible troubleshooting. Don't step on actual mount error. + kernelRelease, err1 := lhns.GetKernelRelease() + if err1 != nil { + kernelRelease = err1.Error() + } + osDistro, err2 := lhns.GetOSDistro() + if err2 != nil { + osDistro = err2.Error() + } + log.WithError(err).Warnf("Failed to mount volume %v on node %s with kernel release %s, os distro %s", volumeID, ns.nodeID, kernelRelease, osDistro) } return status.Error(codes.Internal, err.Error()) }