Skip to content

Commit

Permalink
add max volume size feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mdutka-dell committed Oct 23, 2023
1 parent a2e2d77 commit 2007ba8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
## Description
CSI Driver for Unity XT 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 Unity XT is a Container Storage Interface (CSI) driver that provides support for provisioning persistent storage using Dell Unity XT 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
28 changes: 25 additions & 3 deletions service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/wrapperspb"
)

const (
Expand Down Expand Up @@ -523,20 +524,41 @@ func (s *service) GetCapacity(

metricsAPI := gounity.NewMetrics(unity)

resp, err := metricsAPI.GetCapacity(ctx)
capacity, err := metricsAPI.GetCapacity(ctx)

if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

log.Infof("Available capacity from the Array: %d", resp.Entries[0].Content.SizeFree)
log.Infof("Available capacity from the Array: %d", capacity.Entries[0].Content.SizeFree)

maxVolSize := s.getMaximumVolumeSize(ctx, arrayID)

if maxVolSize == 0 {
return &csi.GetCapacityResponse{
AvailableCapacity: int64(capacity.Entries[0].Content.SizeFree),
}, nil
}

return &csi.GetCapacityResponse{
AvailableCapacity: int64(resp.Entries[0].Content.SizeFree),
AvailableCapacity: int64(capacity.Entries[0].Content.SizeFree),
MaximumVolumeSize: wrapperspb.Int64(maxVolSize),
}, nil

}

func (s *service) getMaximumVolumeSize(ctx context.Context, arrayID string) int64 {
ctx, log, _ := GetRunidLog(ctx)
unity, err := s.getUnityClient(ctx, arrayID)
volumeAPI := gounity.NewVolume(unity)
maxVolumeSize, err := volumeAPI.GetMaxVolumeSize(ctx, "Limit_MaxLUNSize")

Check failure on line 554 in service/controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

volumeAPI.GetMaxVolumeSize undefined (type *gounity.Volume has no field or method GetMaxVolumeSize)) (typecheck)

Check failure on line 554 in service/controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

volumeAPI.GetMaxVolumeSize undefined (type *gounity.Volume has no field or method GetMaxVolumeSize)) (typecheck)

Check failure on line 554 in service/controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

volumeAPI.GetMaxVolumeSize undefined (type *gounity.Volume has no field or method GetMaxVolumeSize)) (typecheck)

Check failure on line 554 in service/controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

volumeAPI.GetMaxVolumeSize undefined (type *gounity.Volume has no field or method GetMaxVolumeSize)) (typecheck)

Check failure on line 554 in service/controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

volumeAPI.GetMaxVolumeSize undefined (type *gounity.Volume has no field or method GetMaxVolumeSize)) (typecheck)
if err != nil {
log.Debugf("GetMaxVolumeSize returning: %v for Array having GlobalId %s", err, arrayID)
return 0
}
return maxVolumeSize
}

func (s *service) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {
ctx, log, rid := GetRunidLog(ctx)
log.Debugf("Executing CreateSnapshot with args: %+v", *req)
Expand Down

0 comments on commit 2007ba8

Please sign in to comment.