From 3fd4c0167f1aacbf3944363b23b51b7d31767129 Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Fri, 12 Apr 2024 12:09:01 -0500 Subject: [PATCH 1/4] Verify that the volume is not yet mounted on the target. (#71) Signed-off-by: Dean Roehrich --- pkg/lustre-driver/service/node.go | 38 ++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/pkg/lustre-driver/service/node.go b/pkg/lustre-driver/service/node.go index ca150d1..49032a3 100644 --- a/pkg/lustre-driver/service/node.go +++ b/pkg/lustre-driver/service/node.go @@ -1,5 +1,5 @@ /* - * Copyright 2021, 2022 Hewlett Packard Enterprise Development LP + * Copyright 2021, 2022, 2024 Hewlett Packard Enterprise Development LP * Other additional copyright holders may be indicated within. * * The entirety of this work is licensed under the Apache License, @@ -73,18 +73,34 @@ func (s *service) NodePublishVolume( return nil, status.Errorf(codes.Internal, "NodePublishVolume - Mountpoint mkdir Failed: Error %v", err) } - // 2. Perform the mount + // 2. Verify that it's not yet mounted. mounter := mount.New("") - err = mounter.Mount( - req.GetVolumeId(), - req.GetTargetPath(), - req.GetVolumeCapability().GetMount().GetFsType(), - req.GetVolumeCapability().GetMount().GetMountFlags()) - + isMounted := false + mountpoints, err := mounter.List() if err != nil { - return nil, status.Errorf(codes.Internal, "NodePublishVolume - Mount Failed: Error %v", err) - } else { - log.WithField("source", req.GetVolumeId()).WithField("target", req.GetTargetPath()).Info("Mounted") + return nil, status.Errorf(codes.Internal, "NodePublishVolume - List mounts failed: Error %v", err) + } + for idx := range mountpoints { + if mountpoints[idx].Path == req.GetTargetPath() && mountpoints[idx].Device == req.GetVolumeId() { + log.WithField("source", req.GetVolumeId()).WithField("target", req.GetTargetPath()).Info("Already mounted") + isMounted = true + break + } + } + + // 3. Perform the mount. + if !isMounted { + err := mounter.Mount( + req.GetVolumeId(), + req.GetTargetPath(), + req.GetVolumeCapability().GetMount().GetFsType(), + req.GetVolumeCapability().GetMount().GetMountFlags()) + + if err != nil { + return nil, status.Errorf(codes.Internal, "NodePublishVolume - Mount Failed: Error %v", err) + } else { + log.WithField("source", req.GetVolumeId()).WithField("target", req.GetTargetPath()).Info("Mounted") + } } return &csi.NodePublishVolumeResponse{}, nil From d89a0bc4ab22af3f93732035ffa847a1a0749e74 Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Fri, 12 Apr 2024 13:59:49 -0500 Subject: [PATCH 2/4] Upgrade to csi-node-driver-registrar v2.10.0 (#72) Signed-off-by: Dean Roehrich --- README.md | 7 ++++--- charts/lustre-csi-driver/templates/plugin.yaml | 2 +- deploy/kubernetes/base/plugin.yaml | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 75bbadf..5ea668d 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,11 @@ frameworks to mount and unmount Lustre filesystems to/from containers in their p ## Kubernetes Compatibility Matrix -| Lustre CSI Driver / Kubernetes Version | v1.13-1.18 | v1.25 | v1.27 | -|----------------------------------------|------------|-------|-------| -| v0.0.1 | yes | yes | yes | +| Lustre CSI Driver / Kubernetes Version | v1.13-1.18 | v1.25 | v1.27 | v1.28 | v1.29 +|----------------------------------------|------------|-------|-------|------|------ | v0.0.10 | yes | yes | yes | +| v0.1.0 | | | | yes | yes + ## Deployment diff --git a/charts/lustre-csi-driver/templates/plugin.yaml b/charts/lustre-csi-driver/templates/plugin.yaml index 0c0ba59..df56c4b 100644 --- a/charts/lustre-csi-driver/templates/plugin.yaml +++ b/charts/lustre-csi-driver/templates/plugin.yaml @@ -77,7 +77,7 @@ spec: # node-driver-registrar registers your CSI driver with Kubelet so that it knows which Unix # domain socket to issue the CSI calls on. - name: csi-node-driver-registrar - image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.6.3 + image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.10.0 args: - --v=5 - --csi-address=/csi/csi.sock diff --git a/deploy/kubernetes/base/plugin.yaml b/deploy/kubernetes/base/plugin.yaml index df0ee02..e4e843d 100644 --- a/deploy/kubernetes/base/plugin.yaml +++ b/deploy/kubernetes/base/plugin.yaml @@ -80,7 +80,7 @@ spec: # node-driver-registrar registers your CSI driver with Kubelet so that it knows which Unix # domain socket to issue the CSI calls on. - name: csi-node-driver-registrar - image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.6.3 + image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.10.0 args: - --v=5 - --csi-address=/csi/csi.sock From c559e76880e8380e1fe1bdbdbfe3b229ea995b3b Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Tue, 30 Apr 2024 09:30:29 -0500 Subject: [PATCH 3/4] Let NodeUnpublishVolume pass when it cannot find volume (#73) This can happen when the volume is manually unmounted or the kubelet's volume bread crumbs in the pod's namespace have been manually removed. Signed-off-by: Dean Roehrich --- pkg/lustre-driver/service/node.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/lustre-driver/service/node.go b/pkg/lustre-driver/service/node.go index 49032a3..b5f5137 100644 --- a/pkg/lustre-driver/service/node.go +++ b/pkg/lustre-driver/service/node.go @@ -21,6 +21,7 @@ package service import ( "os" + "strings" log "github.com/sirupsen/logrus" "golang.org/x/net/context" @@ -121,7 +122,9 @@ func (s *service) NodeUnpublishVolume( mounter := mount.New("") notMountPoint, err := mount.IsNotMountPoint(mounter, req.GetTargetPath()) - if err != nil { + if err != nil && strings.Contains(err.Error(), "no such") { + // consider it unmounted + } else if err != nil { return nil, status.Errorf(codes.Internal, "NodeUnpublishVolume - Mount point check Failed: Error %v", err) } else if !notMountPoint { err := mounter.Unmount(req.GetTargetPath()) From c5044898a1e661a16cb89dfe3e4ecc34938c52e8 Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Wed, 1 May 2024 10:43:37 -0500 Subject: [PATCH 4/4] Update release in chart and kustomization Signed-off-by: Dean Roehrich --- charts/lustre-csi-driver/values.yaml | 2 +- deploy/kubernetes/base/kustomization.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/lustre-csi-driver/values.yaml b/charts/lustre-csi-driver/values.yaml index 7716767..0ae5183 100644 --- a/charts/lustre-csi-driver/values.yaml +++ b/charts/lustre-csi-driver/values.yaml @@ -4,4 +4,4 @@ deployment: image: "ghcr.io/hewlettpackard/lustre-csi-driver" - tag: "0.1.0" + tag: "0.1.1" diff --git a/deploy/kubernetes/base/kustomization.yaml b/deploy/kubernetes/base/kustomization.yaml index ccdcb79..25e3829 100644 --- a/deploy/kubernetes/base/kustomization.yaml +++ b/deploy/kubernetes/base/kustomization.yaml @@ -13,4 +13,4 @@ resources: images: - name: controller newName: ghcr.io/hewlettpackard/lustre-csi-driver - newTag: 0.1.0 + newTag: 0.1.1