mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-24 23:30:20 +00:00
rbd: handle when krbdFeatures is zero
krbdFeatures is set to zero when kernel version < 3.8, i.e. in case where /sys/bus/rbd/supported_features is absent and we are unable to prepare the krbd attributes based on kernel version. When krbdFeatures is set to zero fallback to NBD only when autofallback is turned ON. Fixes: #2678 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
parent
e53fd87154
commit
83cc1b0e58
@ -144,6 +144,7 @@ func healerStageTransaction(ctx context.Context, cr *util.Credentials, volOps *r
|
|||||||
// this function also receive the credentials and secrets args as it differs in its data.
|
// this function also receive the credentials and secrets args as it differs in its data.
|
||||||
// The credentials are used directly by functions like voljournal.Connect() and other functions
|
// The credentials are used directly by functions like voljournal.Connect() and other functions
|
||||||
// like genVolFromVolumeOptions() make use of secrets.
|
// like genVolFromVolumeOptions() make use of secrets.
|
||||||
|
// nolint:gocyclo,cyclop // reduce complexity
|
||||||
func populateRbdVol(
|
func populateRbdVol(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *csi.NodeStageVolumeRequest,
|
req *csi.NodeStageVolumeRequest,
|
||||||
@ -241,8 +242,15 @@ func populateRbdVol(
|
|||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if rv.Mounter == rbdDefaultMounter &&
|
features := strings.Join(rv.ImageFeatureSet.Names(), ",")
|
||||||
!isKrbdFeatureSupported(ctx, strings.Join(rv.ImageFeatureSet.Names(), ",")) {
|
isFeatureExist, err := isKrbdFeatureSupported(ctx, features)
|
||||||
|
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||||
|
log.ErrorLog(ctx, "failed checking krbd features %q: %v", features, err)
|
||||||
|
|
||||||
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if rv.Mounter == rbdDefaultMounter && !isFeatureExist {
|
||||||
if !parseBoolOption(ctx, req.GetVolumeContext(), tryOtherMounters, false) {
|
if !parseBoolOption(ctx, req.GetVolumeContext(), tryOtherMounters, false) {
|
||||||
log.ErrorLog(ctx, "unsupported krbd Feature, set `tryOtherMounters:true` or fix krbd driver")
|
log.ErrorLog(ctx, "unsupported krbd Feature, set `tryOtherMounters:true` or fix krbd driver")
|
||||||
err = errors.New("unsupported krbd Feature")
|
err = errors.New("unsupported krbd Feature")
|
||||||
|
@ -328,7 +328,12 @@ func HexStringToInteger(hexString string) (uint, error) {
|
|||||||
|
|
||||||
// isKrbdFeatureSupported checks if a given Image Feature is supported by krbd
|
// isKrbdFeatureSupported checks if a given Image Feature is supported by krbd
|
||||||
// driver or not.
|
// driver or not.
|
||||||
func isKrbdFeatureSupported(ctx context.Context, imageFeatures string) bool {
|
func isKrbdFeatureSupported(ctx context.Context, imageFeatures string) (bool, error) {
|
||||||
|
// return false when /sys/bus/rbd/supported_features is absent and we are
|
||||||
|
// not in a position to prepare krbd feature attributes, i.e. if kernel <= 3.8
|
||||||
|
if krbdFeatures == 0 {
|
||||||
|
return false, os.ErrNotExist
|
||||||
|
}
|
||||||
arr := strings.Split(imageFeatures, ",")
|
arr := strings.Split(imageFeatures, ",")
|
||||||
log.UsefulLog(ctx, "checking for ImageFeatures: %v", arr)
|
log.UsefulLog(ctx, "checking for ImageFeatures: %v", arr)
|
||||||
imageFeatureSet := librbd.FeatureSetFromNames(arr)
|
imageFeatureSet := librbd.FeatureSetFromNames(arr)
|
||||||
@ -343,7 +348,7 @@ func isKrbdFeatureSupported(ctx context.Context, imageFeatures string) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return supported
|
return supported, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect an rbdVolume to the Ceph cluster.
|
// Connect an rbdVolume to the Ceph cluster.
|
||||||
|
@ -18,6 +18,7 @@ package rbd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@ -346,8 +347,13 @@ func TestIsKrbdFeatureSupported(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("HexStringToInteger(%s) failed", krbdSupportedFeaturesAttr)
|
t.Errorf("HexStringToInteger(%s) failed", krbdSupportedFeaturesAttr)
|
||||||
}
|
}
|
||||||
supported := isKrbdFeatureSupported(ctx, tc.featureName)
|
// In case /sys/bus/rbd/supported_features is absent and we are
|
||||||
if supported != tc.isSupported {
|
// not in a position to prepare krbd feature attributes,
|
||||||
|
// isKrbdFeatureSupported returns error ErrNotExist
|
||||||
|
supported, err := isKrbdFeatureSupported(ctx, tc.featureName)
|
||||||
|
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||||
|
t.Errorf("isKrbdFeatureSupported(%s) returned error: %v", tc.featureName, err)
|
||||||
|
} else if supported != tc.isSupported {
|
||||||
t.Errorf("isKrbdFeatureSupported(%s) returned supported status, expected: %t, got: %t",
|
t.Errorf("isKrbdFeatureSupported(%s) returned supported status, expected: %t, got: %t",
|
||||||
tc.featureName, tc.isSupported, supported)
|
tc.featureName, tc.isSupported, supported)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user