Skip to content

Commit

Permalink
Use capacity of one byte as 'no quota'
Browse files Browse the repository at this point in the history
  • Loading branch information
kvaster authored and chrislusf committed Mar 29, 2024
1 parent ea12719 commit f657740
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/driver/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
}
return nil, status.Error(codes.Internal, err.Error())
}
//k8s api get Capacity

// In seaweedfs quota is not configured on seaweedfs servers.
// Quota is applied only per mount.
// Previously we used to cmdline parameter to apply it, but such way does not allow dynamic resizing.
if capacity, err := k8s.GetVolumeCapacity(volumeID); err == nil {
if err := volume.Quota(capacity); err != nil {
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions pkg/driver/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ func (vol *Volume) Quota(sizeByte int64) error {
}
defer clientConn.Close()

// We can't create PV of zero size, so we're using quota of 1 byte to define no quota.
if sizeByte == 1 {
sizeByte = 0
}

client := mount_pb.NewSeaweedMountClient(clientConn)
_, err = client.Configure(context.Background(), &mount_pb.ConfigureRequest{
CollectionCapacity: sizeByte,
Expand Down

0 comments on commit f657740

Please sign in to comment.