From 565038fdfd54443bd08f4bac39dee0f8ba4ee901 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 5 Nov 2020 15:29:30 +0100 Subject: [PATCH] cephfs: ignore quota when SubVolumeInfo() returns Infinite There is a type-check on BytesQuota after calling SubVolumeInfo() to see if the value is supported. In case no quota is configured, the value Infinite is returned. This can not be converted to an int64, so the original code returned an error. It seems that attaching/mounting sometimes fails with the following error: FailedMount: MountVolume.MountDevice failed for volume "pvc-0e8fdd18-873b-4420-bd27-fa6c02a49496" : rpc error: code = Internal desc = subvolume csi-vol-0d68d71a-1f5f-11eb-96d2-0242ac110012 has unsupported quota: infinite By ignoring the quota of Infinite, and not setting a quota in the Subvolume object, this problem should not happen again. Signed-off-by: Niels de Vos --- internal/cephfs/volume.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/internal/cephfs/volume.go b/internal/cephfs/volume.go index fac80bf9b..8a50e8e5b 100644 --- a/internal/cephfs/volume.go +++ b/internal/cephfs/volume.go @@ -104,16 +104,20 @@ func (vo *volumeOptions) getSubVolumeInfo(ctx context.Context, volID volumeID) ( return nil, err } + subvol := Subvolume{ + // only set BytesQuota when it is of type ByteCount + Path: info.Path, + Features: make([]string, len(info.Features)), + } bc, ok := info.BytesQuota.(fsAdmin.ByteCount) if !ok { - // info.BytesQuota == Infinite - return nil, fmt.Errorf("subvolume %s has unsupported quota: %v", string(volID), info.BytesQuota) - } - - subvol := Subvolume{ - BytesQuota: int64(bc), - Path: info.Path, - Features: make([]string, len(info.Features)), + // we ignore info.BytesQuota == Infinite and just continue + // without returning quota information + if info.BytesQuota != fsAdmin.Infinite { + return nil, fmt.Errorf("subvolume %s has unsupported quota: %v", string(volID), info.BytesQuota) + } + } else { + subvol.BytesQuota = int64(bc) } for i, feature := range info.Features { subvol.Features[i] = string(feature)