Skip to content

Commit

Permalink
fix collectionQuotaMB=0 always
Browse files Browse the repository at this point in the history
  • Loading branch information
joy717 committed Apr 12, 2022
1 parent 909a9ce commit 83c16cd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
16 changes: 13 additions & 3 deletions pkg/driver/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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)
}
Expand Down
15 changes: 13 additions & 2 deletions pkg/driver/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 83c16cd

Please sign in to comment.