rbd: remove topologyConstrainedPools parameter

This commit removes the `topologyConstrainedPools` parameter
from PV volumeAttributes as it is not required.

Signed-off-by: Praveen M <m.praveen@ibm.com>
This commit is contained in:
Praveen M 2024-03-14 17:15:01 +05:30 committed by mergify[bot]
parent 9fb3743280
commit 3538b23794
5 changed files with 38 additions and 16 deletions

View File

@ -240,8 +240,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 := util.GetVolumeContext(req.GetParameters())
volumeContext["pool"] = rbdVol.Pool
volumeContext["journalPool"] = rbdVol.JournalPool
volumeContext["imageName"] = rbdVol.RbdImageName

View File

@ -353,7 +353,6 @@ func attachRBDImage(ctx context.Context, volOptions *rbdVolume, device string, c
}
err = waitForrbdImage(ctx, backoff, volOptions)
if err != nil {
return "", err
}
@ -364,7 +363,7 @@ func attachRBDImage(ctx context.Context, volOptions *rbdVolume, device string, c
}
func appendNbdDeviceTypeAndOptions(cmdArgs []string, userOptions, cookie string) []string {
isUnmap := CheckSliceContains(cmdArgs, "unmap")
isUnmap := util.CheckSliceContains(cmdArgs, "unmap")
if !isUnmap {
if !strings.Contains(userOptions, useNbdNetlink) {
cmdArgs = append(cmdArgs, "--"+useNbdNetlink)

View File

@ -2071,17 +2071,6 @@ func getCephClientLogFileName(id, logDir, prefix string) string {
return fmt.Sprintf("%s/%s-%s.log", logDir, prefix, id)
}
// CheckSliceContains checks the slice for string.
func CheckSliceContains(options []string, opt string) bool {
for _, o := range options {
if o == opt {
return true
}
}
return false
}
// strategicActionOnLogFile act on log file based on cephLogStrategy.
func strategicActionOnLogFile(ctx context.Context, logStrategy, logFile string) {
var err error

View File

@ -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
}

View File

@ -27,6 +27,7 @@ import (
"strings"
"time"
"github.com/ceph/ceph-csi/internal/util/k8s"
"github.com/ceph/ceph-csi/internal/util/log"
"golang.org/x/sys/unix"
@ -381,3 +382,34 @@ func CallStack() string {
return string(stack)
}
// CheckSliceContains checks the slice for string.
func CheckSliceContains(options []string, opt string) bool {
for _, o := range options {
if o == opt {
return true
}
}
return false
}
// GetVolumeContext filters out parameters that are not required in volume context.
func GetVolumeContext(parameters map[string]string) map[string]string {
volumeContext := map[string]string{}
// parameters that are not required in the volume context
notRequiredParams := []string{
topologyPoolsParam,
}
for k, v := range parameters {
if !CheckSliceContains(notRequiredParams, k) {
volumeContext[k] = v
}
}
// remove kubernetes csi prefixed parameters.
volumeContext = k8s.RemoveCSIPrefixedParameters(volumeContext)
return volumeContext
}