diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index 9e924710a6f2..27d71debd1ad 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -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 diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index 401711a9bf7d..3fe8515f89be 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -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" @@ -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 +} diff --git a/internal/util/topology.go b/internal/util/topology.go index 1f08ca6ff049..2ab2bd2a06ec 100644 --- a/internal/util/topology.go +++ b/internal/util/topology.go @@ -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 @@ -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 }