Skip to content

Commit

Permalink
rbd: make pool optional in rbd sc if topologyconstraints are present
Browse files Browse the repository at this point in the history
if rbd storage class is created with topologyconstraintspools
replicated pool was still mandatory, making the pool optional if the
topologyconstraintspools is requested

Closes: #4380

Signed-off-by: parth-gr <[email protected]>
  • Loading branch information
parth-gr committed Mar 8, 2024
1 parent 83ec709 commit 3f06ab0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
4 changes: 3 additions & 1 deletion charts/ceph-csi-rbd/templates/storageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ metadata:
provisioner: {{ .Values.driverName }}
parameters:
clusterID: {{ .Values.storageClass.clusterID }}
pool: {{ .Values.storageClass.pool }}
imageFeatures: {{ .Values.storageClass.imageFeatures }}
{{- if .Values.storageClass.pool }}
pool: {{ .Values.storageClass.pool }}
{{- end }}
{{- if .Values.storageClass.tryOtherMounters }}
tryOtherMounters: {{ .Values.storageClass.tryOtherMounters | quote}}
{{- end }}
Expand Down
1 change: 1 addition & 0 deletions charts/ceph-csi-rbd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ storageClass:
dataPool: ""

# (required) Ceph pool into which the RBD image shall be created
# (optional) if topologyConstrainedPools is provided
# eg: pool: replicapool
pool: replicapool

Expand Down
1 change: 1 addition & 0 deletions examples/rbd/storageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ parameters:
# dataPool: <ec-data-pool>

# (required) Ceph pool into which the RBD image shall be created
# (optional) If the topologyConstrainedPools is provided
# eg: pool: rbdpool
pool: <rbd-pool-name>

Expand Down
35 changes: 19 additions & 16 deletions internal/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,33 +225,36 @@ func (cs *ControllerServer) parseVolCreateRequest(
}

func buildCreateVolumeResponse(req *csi.CreateVolumeRequest, rbdVol *rbdVolume) *csi.CreateVolumeResponse {
// remove kubernetes csi prefixed parameters.
volumeContext := k8s.RemoveCSIPrefixedParameters(req.GetParameters())
volumeContext["pool"] = rbdVol.Pool
volumeContext["journalPool"] = rbdVol.JournalPool
volumeContext["imageName"] = rbdVol.RbdImageName
if rbdVol.RadosNamespace != "" {
volumeContext["radosNamespace"] = rbdVol.RadosNamespace
}

if rbdVol.DataPool != "" {
volumeContext["dataPool"] = rbdVol.DataPool
}

volume := &csi.Volume{
VolumeId: rbdVol.VolID,
CapacityBytes: rbdVol.VolSize,
VolumeContext: volumeContext,
ContentSource: req.GetVolumeContentSource(),
}
if rbdVol.Topology != nil {
volume.AccessibleTopology = []*csi.Topology{

// remove kubernetes csi prefixed parameters.
volumeContext := k8s.RemoveCSIPrefixedParameters(req.GetParameters())
volumeContext["journalPool"] = rbdVol.JournalPool
volumeContext["imageName"] = rbdVol.RbdImageName

if rbdVol.Topology == nil {
volumeContext["pool"] = rbdVol.Pool
if rbdVol.RadosNamespace != "" {
volumeContext["radosNamespace"] = rbdVol.RadosNamespace
}
if rbdVol.DataPool != "" {
volumeContext["dataPool"] = rbdVol.DataPool
}
} else {
accessibleTopology := []*csi.Topology{
{
Segments: rbdVol.Topology,
},
}
volume.AccessibleTopology = accessibleTopology
}

volume.VolumeContext = volumeContext

return &csi.CreateVolumeResponse{Volume: volume}
}

Expand Down

0 comments on commit 3f06ab0

Please sign in to comment.