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 <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-11-05 15:29:30 +01:00 committed by mergify[bot]
parent 8a41cd03a5
commit 565038fdfd

View File

@ -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)