From 2b8b0bebeb3862de269a4f7b16b089acc4a487e5 Mon Sep 17 00:00:00 2001 From: AmitRoushan Date: Tue, 24 Aug 2021 22:30:22 +0530 Subject: [PATCH] bug fix --- src/csi/backend/backend.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/csi/backend/backend.go b/src/csi/backend/backend.go index 2283a780..a870ea30 100644 --- a/src/csi/backend/backend.go +++ b/src/csi/backend/backend.go @@ -39,8 +39,6 @@ var ( } ) -type FilterFunction func(interface{}, []*StoragePool) []*StoragePool - type AccessibleTopology struct { RequisiteTopologies []map[string]string PreferredTopologies []map[string]string @@ -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) @@ -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) @@ -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)