Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitRoushan committed Aug 24, 2021
1 parent 605caf2 commit 2b8b0be
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/csi/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ var (
}
)

type FilterFunction func(interface{}, []*StoragePool) []*StoragePool

type AccessibleTopology struct {
RequisiteTopologies []map[string]string
PreferredTopologies []map[string]string
Expand Down Expand Up @@ -124,9 +122,13 @@ func newBackend(backendName string, config map[string]interface{}) (*Backend, er
return nil, errors.New("parameters must be configured for backend")
}

supportedTopologies, exists := config[SupportedTopologies].([]map[string]string)
if !exists {
supportedTopologies = make([]map[string]string, 0)
supportedTopologies := make([]map[string]string, 0)
if _, exist = config[SupportedTopologies]; exist {
topologies, ok := config[SupportedTopologies].([]map[string]string)
if !ok {
return nil, errors.New("invalid supported topologies configuration")
}
supportedTopologies = topologies
}

plugin := plugin.GetPlugin(storage)
Expand Down Expand Up @@ -290,7 +292,7 @@ func selectOnePool(requestSize int64,
}

for _, i := range filterFuncs {
key, filter := i[0].(string), i[1].(FilterFunction)
key, filter := i[0].(string), i[1].(func(interface{}, []*StoragePool) []*StoragePool)
value, exists := parameters[key]
if exists {
filterPools = filter(value, filterPools)
Expand Down Expand Up @@ -599,7 +601,6 @@ func sortPoolsByPreferredTopologies(candidatePools []*StoragePool, preferredTopo
orderedPools := make([]*StoragePool, 0)

for _, preferred := range preferredTopologies {

newRemainingPools := make([]*StoragePool, 0)
poolBucket := make([]*StoragePool, 0)

Expand Down

0 comments on commit 2b8b0be

Please sign in to comment.