Skip to content

Commit

Permalink
UPSTREAM: 1988374: Disable uuid checks on XFS (kubernetes#1614)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jsafrane committed Aug 23, 2021
1 parent 2bec53f commit b2e65d7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/csi/cinder/nodeserver.go
Expand Up @@ -213,7 +213,7 @@ func nodePublishEphemeral(req *csi.NodePublishVolumeRequest, ns *nodeServer) (*c
fsType = mnt.FsType
}
mountFlags := mnt.GetMountFlags()
options = append(options, mountFlags...)
options = append(options, collectMountOptions(fsType, mountFlags)...)
}
// Mount
err = m.Mounter().FormatAndMount(devicePath, targetPath, fsType, nil)
Expand Down Expand Up @@ -402,7 +402,7 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
fsType = mnt.FsType
}
mountFlags := mnt.GetMountFlags()
options = append(options, mountFlags...)
options = append(options, collectMountOptions(fsType, mountFlags)...)
}
// Mount
err = m.Mounter().FormatAndMount(devicePath, stagingTarget, fsType, options)
Expand Down Expand Up @@ -601,3 +601,15 @@ func getDevicePath(volumeID string, m mount.IMount) (string, error) {
return devicePath, 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
}

0 comments on commit b2e65d7

Please sign in to comment.