Skip to content

Commit b060171

Browse files
jsafraneleiyiz
authored andcommitted
Disable uuid checks on XFS
By default, XFS does not allow mounting two devices that have the same UUID of the XFS filesystem. Therefore it's not possible to mount a volume + its restored snapshot. Therefore disable UUID check in XFS using a mount option.
1 parent 6b2ce66 commit b060171

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 {
@@ -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+
}

0 commit comments

Comments
 (0)