From 6b836953b11cfe903ffdd84db887f26d4e1ae5c4 Mon Sep 17 00:00:00 2001 From: Viktor Kuzmin Date: Fri, 29 Mar 2024 20:22:21 +0200 Subject: [PATCH] Use capacity of one byte as 'no quota' --- pkg/driver/nodeserver.go | 5 ++++- pkg/driver/volume.go | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/driver/nodeserver.go b/pkg/driver/nodeserver.go index 616c79b..2b0463c 100644 --- a/pkg/driver/nodeserver.go +++ b/pkg/driver/nodeserver.go @@ -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 diff --git a/pkg/driver/volume.go b/pkg/driver/volume.go index ac0a80a..ab0dcd4 100644 --- a/pkg/driver/volume.go +++ b/pkg/driver/volume.go @@ -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,