Skip to content

Commit

Permalink
Correct check for drivers existence in the map. (#940)
Browse files Browse the repository at this point in the history
Return default only if requested driver does
not exist in the map. Always returns the driver
 requested.

Signed-off-by: Jose Rivera <[email protected]>
  • Loading branch information
jrivera-px authored Mar 18, 2019
1 parent a1f1699 commit fd7e099
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions api/server/sdk/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@ import (
"os"
"sync"

"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/auth"

"github.com/libopenstorage/openstorage/alerts"
"github.com/libopenstorage/openstorage/api"
"github.com/libopenstorage/openstorage/api/spec"
Expand All @@ -40,6 +35,9 @@ import (
policy "github.com/libopenstorage/openstorage/pkg/storagepolicy"
"github.com/libopenstorage/openstorage/volume"
volumedrivers "github.com/libopenstorage/openstorage/volume/drivers"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)

const (
Expand Down Expand Up @@ -481,10 +479,11 @@ func (s *sdkGrpcServer) useAlert(a alerts.FilterDeleter) {
// Accessors
func (s *sdkGrpcServer) driver(ctx context.Context) volume.VolumeDriver {
driverName := grpcserver.GetMetadataValueFromKey(ctx, ContextDriverKey)
if driverName == "" {
driverName = DefaultDriverName
if handler, ok := s.driverHandlers[driverName]; ok {
return handler
} else {
return s.driverHandlers[DefaultDriverName]
}
return s.driverHandlers[driverName]
}

func (s *sdkGrpcServer) cluster() cluster.Cluster {
Expand Down

0 comments on commit fd7e099

Please sign in to comment.