mirror of
https://github.com/oracle/zfssa-csi-driver.git
synced 2025-06-29 15:06:57 +00:00
NodeUnpublishVolume should be idempotent (#19)
This commit is contained in:
parent
e33ae8e8dd
commit
817778f1c6
@ -10,9 +10,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
"github.com/oracle/zfssa-csi-driver/pkg/utils"
|
"github.com/oracle/zfssa-csi-driver/pkg/utils"
|
||||||
"github.com/oracle/zfssa-csi-driver/pkg/zfssarest"
|
"github.com/oracle/zfssa-csi-driver/pkg/zfssarest"
|
||||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
@ -75,12 +75,19 @@ func (zd *ZFSSADriver) nodeUnpublishFilesystemVolume(token *zfssarest.Token,
|
|||||||
return nil, status.Error(codes.InvalidArgument, "Target path not provided")
|
return nil, status.Error(codes.InvalidArgument, "Target path not provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, pathErr := os.Stat(targetPath); os.IsNotExist(pathErr) {
|
||||||
|
//targetPath doesn't exist; nothing to do
|
||||||
|
utils.GetLogNODE(ctx, 2).Println("nodeUnpublishFilesystemVolume targetPath doesn't exist", targetPath)
|
||||||
|
return &csi.NodeUnpublishVolumeResponse{}, nil
|
||||||
|
}
|
||||||
err := zd.NodeMounter.Unmount(targetPath)
|
err := zd.NodeMounter.Unmount(targetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.GetLogNODE(ctx, 2).Println("Cannot unmount volume",
|
utils.GetLogNODE(ctx, 2).Println("Cannot unmount volume",
|
||||||
"volume_id", req.GetVolumeId(), "error", err.Error())
|
"volume_id", req.GetVolumeId(), "error", err.Error())
|
||||||
|
if !strings.Contains(err.Error(), "not mounted") {
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
notMnt, mntErr := zd.NodeMounter.IsLikelyNotMountPoint(targetPath)
|
notMnt, mntErr := zd.NodeMounter.IsLikelyNotMountPoint(targetPath)
|
||||||
if mntErr != nil {
|
if mntErr != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user