rbd: detect krbd features in runtime and fallback to nbd

Currently, we recognize and warn for the provided image features based on
our prior intelligence at ceph-csi (i.e based on supportedFeatures map
and validateImageFeatures) at image/PV creation time. It might be very
much possible that the cluster is heterogeneous i.e. the PV creation and
application container might both be on different nodes with different
kernel versions (krbd driver versions).

This PR adds a mechanism to check for the supported krbd features during
mount time, if the krbd driver doesn't have the specified image feature
then it will fall back to rbd-nbd mounter.

Fixes: #478
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
Prasanna Kumar Kalever
2021-10-05 14:59:07 +05:30
committed by mergify[bot]
parent af752dd38f
commit 84ec797dda
4 changed files with 145 additions and 14 deletions

View File

@ -283,3 +283,42 @@ func TestStrategicActionOnLogFile(t *testing.T) {
})
}
}
func TestIsKrbdFeatureSupported(t *testing.T) {
t.Parallel()
ctx := context.TODO()
tests := []struct {
name string
featureName string
isSupported bool
}{
{
name: "supported feature",
featureName: "layering",
isSupported: true,
},
{
name: "not supported feature",
featureName: "journaling",
isSupported: false,
},
}
for _, tt := range tests {
tc := tt
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
var err error
krbdSupportedFeaturesAttr := "0x1"
krbdFeatures, err = hexStringToInteger(krbdSupportedFeaturesAttr) // initialize krbdFeatures
if err != nil {
t.Errorf("hexStringToInteger(%s) failed", krbdSupportedFeaturesAttr)
}
supported := isKrbdFeatureSupported(ctx, tc.featureName)
if supported != tc.isSupported {
t.Errorf("isKrbdFeatureSupported(%s) returned supported status, expected: %t, got: %t",
tc.featureName, tc.isSupported, supported)
}
})
}
}