Skip to content

Commit 1067990

Browse files
authored
Merge pull request #788 from jsafrane/fix-xfs-uuid
Disable uuid checks on XFS
2 parents 9cefb03 + b1e0f74 commit 1067990

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-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 {
@@ -155,3 +159,18 @@ func getMultiWriterFromCapabilities(vcs []*csi.VolumeCapability) (bool, error) {
155159
}
156160
return false, nil
157161
}
162+
163+
func collectMountOptions(fsType string, mntFlags []string) []string {
164+
var options []string
165+
166+
for _, opt := range mntFlags {
167+
options = append(options, opt)
168+
}
169+
170+
// By default, xfs does not allow mounting of two volumes with the same filesystem uuid.
171+
// Force ignore this uuid to be able to mount volume + its clone / restored snapshot on the same node.
172+
if fsType == fsTypeXFS {
173+
options = append(options, "nouuid")
174+
}
175+
return options
176+
}

0 commit comments

Comments
 (0)