From 9e429a3e1e1065f13fd0fa8e578035ab5e1e5a69 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Fri, 30 Jul 2021 14:27:03 +0200 Subject: [PATCH] fix: Disable uuid checks on XFS Add 'nouuid' mount option to all XFS mounts to be able to mount a volume and its restored snapshot on the same node. Without the option, such a mount fails, because XFS detects that two different volumes with the same filesystem UUID are being mounted. --- pkg/azuredisk/nodeserver.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/azuredisk/nodeserver.go b/pkg/azuredisk/nodeserver.go index a2c0b3c69e..06da76b39f 100644 --- a/pkg/azuredisk/nodeserver.go +++ b/pkg/azuredisk/nodeserver.go @@ -131,7 +131,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe if mnt.FsType != "" { fstype = mnt.FsType } - options = append(options, mnt.MountFlags...) + options = append(options, collectMountOptions(fstype, mnt.MountFlags)...) } volContextFSType := getFStype(req.GetVolumeContext()) @@ -600,3 +600,15 @@ func (d *Driver) ensureBlockTargetFile(target string) error { return nil } + +func collectMountOptions(fsType string, mntFlags []string) []string { + var options []string + options = append(options, mntFlags...) + + // 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 == "xfs" { + options = append(options, "nouuid") + } + return options +}