Skip to content

Commit 6b01258

Browse files
authored
Merge pull request #838 from leiyiz/release-1.2
Cherry pick #788 to release-1.2
2 parents 6b2ce66 + a01ec83 commit 6b01258

File tree

9 files changed

+29
-7
lines changed

9 files changed

+29
-7
lines changed

pkg/gce-pd-csi-driver/node.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,7 @@ func (ns *GCENodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePub
137137
}
138138

139139
klog.V(4).Infof("NodePublishVolume with filesystem %s", fstype)
140-
141-
for _, flag := range mnt.MountFlags {
142-
options = append(options, flag)
143-
}
140+
options = append(options, collectMountOptions(fstype, mnt.MountFlags)...)
144141

145142
sourcePath = stagingTargetPath
146143
if err := preparePublishPath(targetPath, ns.Mounter); err != nil {
@@ -307,9 +304,7 @@ func (ns *GCENodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStage
307304
if mnt.FsType != "" {
308305
fstype = mnt.FsType
309306
}
310-
for _, flag := range mnt.MountFlags {
311-
options = append(options, flag)
312-
}
307+
options = collectMountOptions(fstype, mnt.MountFlags)
313308
} else if blk := volumeCapability.GetBlock(); blk != nil {
314309
// Noop for Block NodeStageVolume
315310
klog.V(4).Infof("NodeStageVolume succeeded on %v to %s, capability is block so this is a no-op", volumeID, stagingTargetPath)

pkg/gce-pd-csi-driver/utils.go

+19
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ import (
2727
"k8s.io/klog"
2828
)
2929

30+
const (
31+
fsTypeXFS = "xfs"
32+
)
33+
3034
var ProbeCSIFullMethod = "/csi.v1.Identity/Probe"
3135

3236
func NewVolumeCapabilityAccessMode(mode csi.VolumeCapability_AccessMode_Mode) *csi.VolumeCapability_AccessMode {
@@ -152,3 +156,18 @@ func getMultiWriterFromCapabilities(vcs []*csi.VolumeCapability) (bool, error) {
152156
}
153157
return false, nil
154158
}
159+
160+
func collectMountOptions(fsType string, mntFlags []string) []string {
161+
var options []string
162+
163+
for _, opt := range mntFlags {
164+
options = append(options, opt)
165+
}
166+
167+
// By default, xfs does not allow mounting of two volumes with the same filesystem uuid.
168+
// Force ignore this uuid to be able to mount volume + its clone / restored snapshot on the same node.
169+
if fsType == fsTypeXFS {
170+
options = append(options, "nouuid")
171+
}
172+
return options
173+
}

pkg/gce-pd-csi-driver/utils_linux.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !windows
12
// +build !windows
23

34
/*

pkg/gce-pd-csi-driver/utils_windows.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build windows
12
// +build windows
23

34
/*

pkg/mount-manager/safe-mounter_linux.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build linux
12
// +build linux
23

34
/*

pkg/mount-manager/safe-mounter_windows.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build windows
12
// +build windows
23

34
/*

pkg/mount-manager/statter_windows.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
//go:build windows
12
// +build windows
3+
24
/*
35
Copyright 2019 The Kubernetes Authors.
46

pkg/resizefs/resizefs_linux.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build linux
12
// +build linux
23

34
/*

pkg/resizefs/resizefs_windows.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build windows
12
// +build windows
23

34
/*

0 commit comments

Comments
 (0)