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 ed046fd
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 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 := util.GetVolumeContext(req.GetParameters())
volumeContext["pool"] = rbdVol.Pool
volumeContext["journalPool"] = rbdVol.JournalPool
volumeContext["imageName"] = rbdVol.RbdImageName
Expand Down
2 changes: 1 addition & 1 deletion internal/rbd/rbd_attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func attachRBDImage(ctx context.Context, volOptions *rbdVolume, device string, c
func appendNbdDeviceTypeAndOptions(cmdArgs []string, userOptions, cookie string) []string {
cmdArgs = append(cmdArgs, "--device-type", accessTypeNbd)

isUnmap := CheckSliceContains(cmdArgs, "unmap")
isUnmap := util.CheckSliceContains(cmdArgs, "unmap")
if !isUnmap {
if !strings.Contains(userOptions, useNbdNetlink) {
cmdArgs = append(cmdArgs, "--options", useNbdNetlink)
Expand Down
11 changes: 0 additions & 11 deletions internal/rbd/rbd_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2064,17 +2064,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
Expand Down
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
32 changes: 32 additions & 0 deletions internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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"
Expand Down Expand Up @@ -392,3 +393,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
}

0 comments on commit ed046fd

Please sign in to comment.