Skip to content

Commit 0ecadf6

Browse files
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>
1 parent 063319f commit 0ecadf6

File tree

5 files changed

+38
-16
lines changed

5 files changed

+38
-16
lines changed

internal/rbd/controllerserver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ func (cs *ControllerServer) parseVolCreateRequest(
232232
}
233233

234234
func buildCreateVolumeResponse(req *csi.CreateVolumeRequest, rbdVol *rbdVolume) *csi.CreateVolumeResponse {
235-
// remove kubernetes csi prefixed parameters.
236-
volumeContext := k8s.RemoveCSIPrefixedParameters(req.GetParameters())
235+
volumeContext := util.GetVolumeContext(req.GetParameters())
237236
volumeContext["pool"] = rbdVol.Pool
238237
volumeContext["journalPool"] = rbdVol.JournalPool
239238
volumeContext["imageName"] = rbdVol.RbdImageName

internal/rbd/rbd_attach.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ func attachRBDImage(ctx context.Context, volOptions *rbdVolume, device string, c
353353
}
354354

355355
err = waitForrbdImage(ctx, backoff, volOptions)
356-
357356
if err != nil {
358357
return "", err
359358
}
@@ -364,7 +363,7 @@ func attachRBDImage(ctx context.Context, volOptions *rbdVolume, device string, c
364363
}
365364

366365
func appendNbdDeviceTypeAndOptions(cmdArgs []string, userOptions, cookie string) []string {
367-
isUnmap := CheckSliceContains(cmdArgs, "unmap")
366+
isUnmap := util.CheckSliceContains(cmdArgs, "unmap")
368367
if !isUnmap {
369368
if !strings.Contains(userOptions, useNbdNetlink) {
370369
cmdArgs = append(cmdArgs, "--"+useNbdNetlink)

internal/rbd/rbd_util.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,17 +2067,6 @@ func getCephClientLogFileName(id, logDir, prefix string) string {
20672067
return fmt.Sprintf("%s/%s-%s.log", logDir, prefix, id)
20682068
}
20692069

2070-
// CheckSliceContains checks the slice for string.
2071-
func CheckSliceContains(options []string, opt string) bool {
2072-
for _, o := range options {
2073-
if o == opt {
2074-
return true
2075-
}
2076-
}
2077-
2078-
return false
2079-
}
2080-
20812070
// strategicActionOnLogFile act on log file based on cephLogStrategy.
20822071
func strategicActionOnLogFile(ctx context.Context, logStrategy, logFile string) {
20832072
var err error

internal/util/topology.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ import (
3030
const (
3131
keySeparator rune = '/'
3232
labelSeparator string = ","
33+
34+
// topologyPoolsParam is the parameter name used to pass topology constrained pools.
35+
topologyPoolsParam = "topologyConstrainedPools"
3336
)
3437

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

131134
// check if parameters have pool configuration pertaining to topology
132-
topologyPoolsStr := req.GetParameters()["topologyConstrainedPools"]
135+
topologyPoolsStr := req.GetParameters()[topologyPoolsParam]
133136
if topologyPoolsStr == "" {
134137
return nil, nil, nil
135138
}

internal/util/util.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"strings"
2727
"time"
2828

29+
"github.com/ceph/ceph-csi/internal/util/k8s"
2930
"github.com/ceph/ceph-csi/internal/util/log"
3031

3132
"golang.org/x/sys/unix"
@@ -390,3 +391,34 @@ func CallStack() string {
390391

391392
return string(stack)
392393
}
394+
395+
// CheckSliceContains checks the slice for string.
396+
func CheckSliceContains(options []string, opt string) bool {
397+
for _, o := range options {
398+
if o == opt {
399+
return true
400+
}
401+
}
402+
403+
return false
404+
}
405+
406+
// GetVolumeContext filters out parameters that are not required in volume context.
407+
func GetVolumeContext(parameters map[string]string) map[string]string {
408+
volumeContext := map[string]string{}
409+
410+
// parameters that are not required in the volume context
411+
notRequiredParams := []string{
412+
topologyPoolsParam,
413+
}
414+
for k, v := range parameters {
415+
if !CheckSliceContains(notRequiredParams, k) {
416+
volumeContext[k] = v
417+
}
418+
}
419+
420+
// remove kubernetes csi prefixed parameters.
421+
volumeContext = k8s.RemoveCSIPrefixedParameters(volumeContext)
422+
423+
return volumeContext
424+
}

0 commit comments

Comments
 (0)