Skip to content

Commit

Permalink
Merge pull request #955 from crombus/tune_platform
Browse files Browse the repository at this point in the history
cephcluster: tune disks according to plaftorm
  • Loading branch information
openshift-merge-robot committed Jan 15, 2021
2 parents bc3d8b5 + 4091a66 commit c14dbba
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
8 changes: 8 additions & 0 deletions controllers/storagecluster/cephcluster.go
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
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
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

0 comments on commit c14dbba

Please sign in to comment.