diff --git a/pkg/gce-pd-csi-driver/node.go b/pkg/gce-pd-csi-driver/node.go index f195afd2a..c98e6636b 100644 --- a/pkg/gce-pd-csi-driver/node.go +++ b/pkg/gce-pd-csi-driver/node.go @@ -137,10 +137,7 @@ func (ns *GCENodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePub } klog.V(4).Infof("NodePublishVolume with filesystem %s", fstype) - - for _, flag := range mnt.MountFlags { - options = append(options, flag) - } + options = append(options, collectMountOptions(fstype, mnt.MountFlags)...) sourcePath = stagingTargetPath if err := preparePublishPath(targetPath, ns.Mounter); err != nil { @@ -307,9 +304,7 @@ func (ns *GCENodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStage if mnt.FsType != "" { fstype = mnt.FsType } - for _, flag := range mnt.MountFlags { - options = append(options, flag) - } + options = collectMountOptions(fstype, mnt.MountFlags) } else if blk := volumeCapability.GetBlock(); blk != nil { // Noop for Block NodeStageVolume klog.V(4).Infof("NodeStageVolume succeeded on %v to %s, capability is block so this is a no-op", volumeID, stagingTargetPath) diff --git a/pkg/gce-pd-csi-driver/utils.go b/pkg/gce-pd-csi-driver/utils.go index 1d76f3bc3..9a394056e 100644 --- a/pkg/gce-pd-csi-driver/utils.go +++ b/pkg/gce-pd-csi-driver/utils.go @@ -27,6 +27,10 @@ import ( "k8s.io/klog" ) +const ( + fsTypeXFS = "xfs" +) + var ProbeCSIFullMethod = "/csi.v1.Identity/Probe" func NewVolumeCapabilityAccessMode(mode csi.VolumeCapability_AccessMode_Mode) *csi.VolumeCapability_AccessMode { @@ -155,3 +159,18 @@ func getMultiWriterFromCapabilities(vcs []*csi.VolumeCapability) (bool, error) { } return false, nil } + +func collectMountOptions(fsType string, mntFlags []string) []string { + var options []string + + for _, opt := range mntFlags { + options = append(options, opt) + } + + // By default, xfs does not allow mounting of two volumes with the same filesystem uuid. + // Force ignore this uuid to be able to mount volume + its clone / restored snapshot on the same node. + if fsType == fsTypeXFS { + options = append(options, "nouuid") + } + return options +}