Skip to content

Commit

Permalink
Adding CSI Spec v1.6.0 support for Powerflex (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
KshitijaKakde authored Oct 31, 2023
1 parent a40c67f commit f73a260
Show file tree
Hide file tree
Showing 8 changed files with 475 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## Description
CSI Driver for PowerFlex is part of the [CSM (Container Storage Modules)](https://github.com/dell/csm) open-source suite of Kubernetes storage enablers for Dell products. CSI Driver for PowerFlex is a Container Storage Interface (CSI) driver that provides support for provisioning persistent storage using Dell PowerFlex storage array.

It supports CSI specification version 1.5.
It supports CSI specification version 1.6.

This project may be compiled as a stand-alone binary using Golang that, when run, provides a valid CSI endpoint. It also can be used as a precompiled container image.

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ go 1.21

require (
github.com/akutz/memconn v0.1.0
github.com/container-storage-interface/spec v1.5.0
github.com/container-storage-interface/spec v1.6.0
github.com/cucumber/godog v0.12.1
github.com/dell/dell-csi-extensions/common v1.2.0
github.com/dell/dell-csi-extensions/podmon v1.2.0
github.com/dell/dell-csi-extensions/replication v1.5.0
github.com/dell/dell-csi-extensions/volumeGroupSnapshot v1.3.0
github.com/dell/gocsi v1.8.0
github.com/dell/gofsutil v1.13.1
github.com/dell/goscaleio v1.12.0
github.com/dell/goscaleio v1.12.1-0.20231017093409-11580d24020f
github.com/fsnotify/fsnotify v1.5.1
github.com/golang/protobuf v1.5.3
github.com/google/uuid v1.3.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/container-storage-interface/spec v1.2.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
github.com/container-storage-interface/spec v1.5.0 h1:lvKxe3uLgqQeVQcrnL2CPQKISoKjTJxojEs9cBk+HXo=
github.com/container-storage-interface/spec v1.5.0/go.mod h1:8K96oQNkJ7pFcC2R9Z1ynGGBB1I93kcS6PGg3SsOk8s=
github.com/container-storage-interface/spec v1.6.0 h1:vwN9uCciKygX/a0toYryoYD5+qI9ZFeAMuhEEKO+JBA=
github.com/container-storage-interface/spec v1.6.0/go.mod h1:8K96oQNkJ7pFcC2R9Z1ynGGBB1I93kcS6PGg3SsOk8s=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
Expand Down Expand Up @@ -114,8 +114,8 @@ github.com/dell/gocsi v1.8.0 h1:0qsC/Ts6QeAWBBVaQvFrZYBXdoR7bmjrDUb3QpcMfHM=
github.com/dell/gocsi v1.8.0/go.mod h1:X/8Ll8qqKAKCenmd1gPJMUvUmgY8cK0LiS8Pck12UaU=
github.com/dell/gofsutil v1.13.1 h1:hu26rfykH0gvpSxPe5lTBVCHZA3m896/iO+2Ekz0U7A=
github.com/dell/gofsutil v1.13.1/go.mod h1:UPRuS1blrPnfT2K3nWRrLHIosZsBznDglovA6DRMmUI=
github.com/dell/goscaleio v1.12.0 h1:9KbctTsxqgVG+9Lj9NDwb4wvjzO7YMZ7uDzps4LlX2E=
github.com/dell/goscaleio v1.12.0/go.mod h1:dt4Xy5Pnx8MEBza+ODOKiwNFBipcnzEXWgTnFy0+jTw=
github.com/dell/goscaleio v1.12.1-0.20231017093409-11580d24020f h1:FKJw+2Ouz0n2zenyeUo3tuLIjhFopCrUWyS8BC3NvsU=
github.com/dell/goscaleio v1.12.1-0.20231017093409-11580d24020f/go.mod h1:dt4Xy5Pnx8MEBza+ODOKiwNFBipcnzEXWgTnFy0+jTw=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
Expand Down
79 changes: 77 additions & 2 deletions service/controller.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2019-2022 Dell Inc. or its subsidiaries. All Rights Reserved.
// Copyright © 2019-2023 Dell Inc. or its subsidiaries. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -20,12 +20,14 @@ import (
"net/http"
"strconv"
"strings"
"sync"
"time"

"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/wrapperspb"

csi "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/dell/goscaleio"
Expand Down Expand Up @@ -2091,6 +2093,11 @@ func (s *service) getCapacityForAllSystems(ctx context.Context, protectionDomain
return capacity, nil
}

// maxVolumesSizeForArray - store the maxVolumesSizeForArray
var maxVolumesSizeForArray = make(map[string]int64)

var mutex = &sync.Mutex{}

func (s *service) GetCapacity(
ctx context.Context,
req *csi.GetCapacityRequest) (
Expand All @@ -2101,6 +2108,7 @@ func (s *service) GetCapacity(
err error
)

systemID := ""
params := req.GetParameters()
if params == nil || len(params) == 0 {
// Get capacity of all systems
Expand All @@ -2111,7 +2119,6 @@ func (s *service) GetCapacity(
if !ok {
Log.Printf("Protection Domain name not provided; there could be conflicts if two storage pools share a name")
}
systemID := ""
for key, value := range params {
if strings.EqualFold(key, KeySystemID) {
systemID = value
Expand All @@ -2132,11 +2139,79 @@ func (s *service) GetCapacity(
"Unable to get capacity: %s", err.Error())
}

if systemID == "" && s.opts.defaultSystemID != "" {
systemID = s.opts.defaultSystemID
}

if systemID == "" {
return &csi.GetCapacityResponse{
AvailableCapacity: capacity,
}, nil
}

maxVolSize, err := s.getMaximumVolumeSize(systemID)
if err != nil {
Log.Debug("GetMaxVolumeSize returning error ", err)
}

if maxVolSize < 0 {
return &csi.GetCapacityResponse{
AvailableCapacity: capacity,
}, nil
}

maxVolSizeinBytes := maxVolSize * bytesInGiB
maxVol := wrapperspb.Int64(maxVolSizeinBytes)
return &csi.GetCapacityResponse{
AvailableCapacity: capacity,
MaximumVolumeSize: maxVol,
}, nil
}

func (s *service) getMaximumVolumeSize(systemID string) (int64, error) {
valueInCache, found := getCachedMaximumVolumeSize(systemID)
if !found || valueInCache < 0 {
adminClient := s.adminClients[systemID]
if adminClient == nil {
return 0, status.Errorf(codes.InvalidArgument, "can't find adminClient by id %s", systemID)
}

vol1, err := adminClient.GetMaxVol()
if err != nil {
Log.Debug("GetMaxVolumeSize returning error ", err)
return 0, err
}

value, err := strconv.ParseInt(vol1, 10, 64)
if err != nil {
Log.Debug("error converting str to int ", err)
return 0, err

}

cacheMaximumVolumeSize(systemID, value)
valueInCache = value

}
return valueInCache, nil

}

func getCachedMaximumVolumeSize(key string) (int64, bool) {
mutex.Lock()
defer mutex.Unlock()

value, found := maxVolumesSizeForArray[key]
return value, found
}

func cacheMaximumVolumeSize(key string, value int64) {
mutex.Lock()
defer mutex.Unlock()

maxVolumesSizeForArray[key] = value
}

func (s *service) ControllerGetCapabilities(
ctx context.Context,

Check warning on line 2216 in service/controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
req *csi.ControllerGetCapabilitiesRequest) (

Check warning on line 2217 in service/controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unused-parameter: parameter 'req' seems to be unused, consider removing or renaming it as _ (revive)
Expand Down
Loading

0 comments on commit f73a260

Please sign in to comment.