diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2022-04-12 07:07:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-12 07:07:46 -0700 |
| commit | 5cffc070f9d3f009de526f10ac38dde80d55e644 (patch) | |
| tree | 4ef9f2120b6a5fe185c91943b95d525fa95c29ac | |
| parent | 909a9ce4fac5a04a4de4ee1f83c556dd90d8f1bc (diff) | |
| parent | 83c16cd58b2c252eebded20c3b910cefcab1fb4b (diff) | |
| download | seaweedfs-csi-driver-5cffc070f9d3f009de526f10ac38dde80d55e644.tar.xz seaweedfs-csi-driver-5cffc070f9d3f009de526f10ac38dde80d55e644.zip | |
Merge pull request #56 from joy717/fix/collection-quota-not-work
| -rw-r--r-- | pkg/driver/controllerserver.go | 16 | ||||
| -rw-r--r-- | pkg/driver/nodeserver.go | 15 |
2 files changed, 26 insertions, 5 deletions
diff --git a/pkg/driver/controllerserver.go b/pkg/driver/controllerserver.go index 6f57359..535759d 100644 --- a/pkg/driver/controllerserver.go +++ b/pkg/driver/controllerserver.go @@ -5,6 +5,10 @@ import ( "crypto/sha1" "encoding/hex" "fmt" + "io" + "strconv" + "strings" + "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/pb/mount_pb" @@ -14,8 +18,6 @@ import ( "google.golang.org/grpc/credentials/insecure" _ "google.golang.org/grpc/resolver/passthrough" "google.golang.org/grpc/status" - "io" - "strings" ) type ControllerServer struct { @@ -42,11 +44,19 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol } params := req.GetParameters() + if params == nil { + params = make(map[string]string) + } glog.V(4).Infof("params:%v", params) - capacity := req.GetCapacityRange().GetLimitBytes() + capacity := req.GetCapacityRange().GetRequiredBytes() cs.Driver.Capacity = capacity cs.Driver.DiskType = params["diskType"] + if capacity > 0 { + glog.V(4).Infof("volume capacity: %d", capacity) + params["volumeCapacity"] = strconv.FormatInt(capacity, 10) + } + if err := filer_pb.Mkdir(cs.Driver, "/buckets", volumeId, nil); err != nil { return nil, fmt.Errorf("Error setting bucket metadata: %v", err) } diff --git a/pkg/driver/nodeserver.go b/pkg/driver/nodeserver.go index 365fb4c..1f3ce20 100644 --- a/pkg/driver/nodeserver.go +++ b/pkg/driver/nodeserver.go @@ -3,6 +3,10 @@ package driver import ( "context" "fmt" + "os" + "strconv" + "strings" + "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/pb/mount_pb" "github.com/container-storage-interface/spec/lib/go/csi" @@ -12,8 +16,6 @@ import ( _ "google.golang.org/grpc/resolver/passthrough" "google.golang.org/grpc/status" "k8s.io/utils/mount" - "os" - "strings" ) type NodeServer struct { @@ -69,6 +71,15 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis ns.Driver.DiskType = diskType } + if volumeCapacity, ok := volContext["volumeCapacity"]; ok { + vCap, err := strconv.ParseInt(volumeCapacity, 10, 64) + if err != nil { + glog.Errorf("volumeCapacity %s can not be parsed to Int64, err is: %v", volumeCapacity, err) + } else { + ns.Driver.Capacity = vCap + } + } + mounter, err := newMounter(path, collection, req.GetReadonly(), ns.Driver, volContext) if err != nil { return nil, err |
