Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cephcluster: tune disks according to plaftorm #955

Merged
merged 2 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions controllers/storagecluster/cephcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,14 @@ func (r *StorageClusterReconciler) checkTuneStorageDevices(ds ocsv1.StorageDevic
return dt.speed, nil
}

tuneFastDevices, err := r.DevicesDefaultToFastForThisPlatform()
if err != nil {
return diskSpeedUnknown, err
}
if tuneFastDevices {
return diskSpeedFast, nil
}

// not a known disk type, don't tune
return diskSpeedUnknown, nil
}
Expand Down
23 changes: 23 additions & 0 deletions controllers/storagecluster/platform_detection.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ var AvoidObjectStorePlatforms = []configv1.PlatformType{
configv1.AzurePlatformType,
}

// TuneFastPlatforms is a list of all PlatformTypes where TuneFastDeviceClass has to be set True.
var TuneFastPlatforms = []configv1.PlatformType{
configv1.OvirtPlatformType,
configv1.IBMCloudPlatformType,
configv1.AzurePlatformType,
}

// Platform is used to get the CloudPlatformType of the running cluster in a thread-safe manner
type Platform struct {
platform configv1.PlatformType
Expand Down Expand Up @@ -55,3 +62,19 @@ func avoidObjectStore(p configv1.PlatformType) bool {
}
return false
}

func (r *StorageClusterReconciler) DevicesDefaultToFastForThisPlatform() (bool, error) {
c := r.Client
platform, err := r.platform.GetPlatform(c)
if err != nil {
return false, err
}

for _, tfplatform := range TuneFastPlatforms {
if platform == tfplatform {
return true, nil
}
}

return false, nil
}
33 changes: 32 additions & 1 deletion controllers/storagecluster/storagecluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ func TestThrottleStorageDevices(t *testing.T) {
deviceSets []api.StorageDeviceSet
storageCluster *api.StorageCluster
expectedSpeed diskSpeed
platform *Platform
}{
{
label: "Case 1", // storageclass is gp2 or io1
Expand Down Expand Up @@ -424,10 +425,40 @@ func TestThrottleStorageDevices(t *testing.T) {
storageCluster: &api.StorageCluster{},
expectedSpeed: diskSpeedFast,
},
{
label: "Case 7", // storageclass is neither gp2 nor io1 but platform is Azure
storageClass: &storagev1.StorageClass{
ObjectMeta: metav1.ObjectMeta{
Name: "st1",
},
Provisioner: string(EBS),
Parameters: map[string]string{
"type": "st1",
},
},
deviceSets: []api.StorageDeviceSet{
{
Name: "mock-sds",
Count: 3,
DataPVCTemplate: corev1.PersistentVolumeClaim{
Spec: corev1.PersistentVolumeClaimSpec{
StorageClassName: &fakestorageClassName,
},
},
Portable: true,
},
},
platform: &Platform{platform: configv1.AzurePlatformType},
storageCluster: &api.StorageCluster{},
expectedSpeed: diskSpeedFast,
},
}

for _, tc := range testcases {
reconciler := createFakeStorageClusterReconciler(t, tc.storageCluster, tc.storageClass)
if tc.platform != nil {
reconciler.platform = tc.platform
}
for _, ds := range tc.deviceSets {
actualSpeed, err := reconciler.checkTuneStorageDevices(ds)
assert.NoError(t, err)
Expand Down Expand Up @@ -852,7 +883,7 @@ func createFakeStorageClusterReconciler(t *testing.T, obj ...runtime.Object) Sto
Scheme: scheme,
serverVersion: &k8sVersion.Info{},
Log: logf.Log.WithName("controller_storagecluster_test"),
platform: &Platform{},
platform: &Platform{platform: configv1.NonePlatformType},
}
}

Expand Down