mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
cephfs: use shallow volumes for the ROX accessMode
this commit makes shallow volume as default feature for ROX volumes. Signed-off-by: riya-singhal31 <rsinghal@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
8854c8523d
commit
b28b5e6c84
@ -235,6 +235,7 @@ func NewVolumeOptions(
|
||||
opts.Monitors = strings.Join(clusterData.Monitors, ",")
|
||||
opts.SubvolumeGroup = clusterData.CephFS.SubvolumeGroup
|
||||
opts.Owner = k8s.GetOwner(volOptions)
|
||||
opts.BackingSnapshot = IsShallowVolumeSupported(req)
|
||||
|
||||
if err = extractOptionalOption(&opts.Pool, "pool", volOptions); err != nil {
|
||||
return nil, err
|
||||
@ -323,6 +324,28 @@ func NewVolumeOptions(
|
||||
return &opts, nil
|
||||
}
|
||||
|
||||
// IsShallowVolumeSupported returns true only for ReadOnly volume requests
|
||||
// with datasource as snapshot.
|
||||
func IsShallowVolumeSupported(req *csi.CreateVolumeRequest) bool {
|
||||
isRO := IsVolumeCreateRO(req.VolumeCapabilities)
|
||||
|
||||
return isRO && (req.GetVolumeContentSource() != nil && req.GetVolumeContentSource().GetSnapshot() != nil)
|
||||
}
|
||||
|
||||
func IsVolumeCreateRO(caps []*csi.VolumeCapability) bool {
|
||||
for _, cap := range caps {
|
||||
if cap.AccessMode != nil {
|
||||
switch cap.AccessMode.Mode { //nolint:exhaustive // only check what we want
|
||||
case csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY,
|
||||
csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY:
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// newVolumeOptionsFromVolID generates a new instance of volumeOptions and VolumeIdentifier
|
||||
// from the provided CSI VolumeID.
|
||||
// nolint:gocyclo,cyclop // TODO: reduce complexity
|
||||
|
Reference in New Issue
Block a user