Skip to content

Commit

Permalink
quota: override volume attributes by PV.Spec.Capacity (#733)
Browse files Browse the repository at this point in the history
* quota: override volume attributes by PV.Spec.Capacity

Signed-off-by: xixi <[email protected]>
  • Loading branch information
Hexilee authored Aug 30, 2023
1 parent 4a5b74f commit 42b2fe6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/container-storage-interface/spec/lib/go/csi"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/klog"
k8sexec "k8s.io/utils/exec"
"k8s.io/utils/mount"
Expand Down Expand Up @@ -138,6 +139,15 @@ func (d *nodeService) NodePublishVolume(ctx context.Context, req *csi.NodePublis
if err != nil {
return nil, status.Errorf(codes.Internal, "invalid capacity %s: %v", cap, err)
}
if d.k8sClient != nil {
pv, err := d.k8sClient.GetPersistentVolume(ctx, volumeID)
if err != nil && !k8serrors.IsNotFound(err) {
return nil, status.Errorf(codes.Internal, "get pv %s: %v", volumeID, err)
}
if err == nil && pv != nil {
capacity = pv.Spec.Capacity.Storage().Value()
}
}
settings, err := d.juicefs.Settings(ctx, volumeID, secrets, volCtx, options)
if err != nil {
return nil, status.Errorf(codes.Internal, "get settings: %v", err)
Expand Down

0 comments on commit 42b2fe6

Please sign in to comment.