Skip to content

Commit

Permalink
rbd: remove topologyConstrainedPools parameter
Browse files Browse the repository at this point in the history
This commit removes the `topologyConstrainedPools` parameter
from PV volumeAttributes as it is not required.

Signed-off-by: Praveen M <m.praveen@ibm.com>
  • Loading branch information
iPraveenParihar committed Mar 27, 2024
1 parent 6c43789 commit 21a71d3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
3 changes: 1 addition & 2 deletions internal/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ func (cs *ControllerServer) parseVolCreateRequest(
}

func buildCreateVolumeResponse(req *csi.CreateVolumeRequest, rbdVol *rbdVolume) *csi.CreateVolumeResponse {
// remove kubernetes csi prefixed parameters.
volumeContext := k8s.RemoveCSIPrefixedParameters(req.GetParameters())
volumeContext := rbdVol.getVolumeContext(req.GetParameters())
volumeContext["pool"] = rbdVol.Pool
volumeContext["journalPool"] = rbdVol.JournalPool
volumeContext["imageName"] = rbdVol.RbdImageName
Expand Down
22 changes: 22 additions & 0 deletions internal/rbd/rbd_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"time"

"github.com/ceph/ceph-csi/internal/util"
"github.com/ceph/ceph-csi/internal/util/k8s"
"github.com/ceph/ceph-csi/internal/util/log"

"github.com/ceph/go-ceph/rados"
Expand Down Expand Up @@ -2155,3 +2156,24 @@ func (rv *rbdVolume) unsetAllMetadata(keys []string) error {

return nil
}

// getVolumeContext filters out parameters that are not required in the volume context.
func (rv *rbdVolume) getVolumeContext(parameters map[string]string) map[string]string {
volumeContext := map[string]string{}

// parameters that are not required in the volume context
notRequiredParams := []string{
util.TopologyPoolsParam,
}

for k, v := range parameters {
if !CheckSliceContains(notRequiredParams, k) {
volumeContext[k] = v
}
}

// remove kubernetes csi prefixed parameters.
volumeContext = k8s.RemoveCSIPrefixedParameters(volumeContext)

return volumeContext
}
5 changes: 4 additions & 1 deletion internal/util/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import (
const (
keySeparator rune = '/'
labelSeparator string = ","

// topologyPoolsParam is the parameter name used to pass topology constrained pools.
TopologyPoolsParam = "topologyConstrainedPools"
)

// GetTopologyFromDomainLabels returns the CSI topology map, determined from
Expand Down Expand Up @@ -129,7 +132,7 @@ func GetTopologyFromRequest(
var topologyPools []TopologyConstrainedPool

// check if parameters have pool configuration pertaining to topology
topologyPoolsStr := req.GetParameters()["topologyConstrainedPools"]
topologyPoolsStr := req.GetParameters()[TopologyPoolsParam]
if topologyPoolsStr == "" {
return nil, nil, nil
}
Expand Down

0 comments on commit 21a71d3

Please sign in to comment.