Skip to content

Commit

Permalink
add new property TuneFastDeviceClass
Browse files Browse the repository at this point in the history
move throttleStorageDevices func in
cephcluster.go and add managed-premium
as fastdeviceclass

Signed-off-by: crombus <pkundra@redhat.com>
  • Loading branch information
crombus committed Oct 23, 2020
1 parent 9440fde commit 76d77ba
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 30 deletions.
6 changes: 5 additions & 1 deletion pkg/apis/ocs/v1/storagecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type StorageClusterSpec struct {
// If enabled, sets the failureDomain to host, allowing devices to be
// distributed evenly across all nodes, regardless of distribution in zones
// or racks.
FlexibleScaling bool `json:"flexibleScaling,omitempty"`
FlexibleScaling bool `json:"flexibleScaling,omitempty"`
}

// ManagedResourcesSpec defines how to reconcile auxiliary resources
Expand Down Expand Up @@ -132,6 +132,10 @@ type StorageDeviceSetConfig struct {
// TuneSlowDeviceClass tunes the OSD when running on a slow Device Class
// +optional
TuneSlowDeviceClass bool `json:"tuneSlowDeviceClass,omitempty"`

// TuneFastDeviceClass tunes the OSD when running on a fast Device Class
// +optional
TuneFastDeviceClass bool `json:"tuneSlowDeviceClass,omitempty"`
}

// MultiCloudGatewaySpec defines specific multi-cloud gateway configuration options
Expand Down
47 changes: 41 additions & 6 deletions pkg/controller/storagecluster/cephcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)

// StorageClassProvisionerType is a string representing StorageClass Provisioner. E.g: aws-ebs
type StorageClassProvisionerType string

// EBS represents AWS EBS provisioner for StorageClass
EBS StorageClassProvisionerType = "kubernetes.io/aws-ebs"

// Premium represents Azure Premium Managed Disks provisioner for StorageClass
Premium StorageClassProvisionerType = "kubernetes.io/azure-disk"

var throttleDiskTypes = []string{"gp2", "io1"}

var throttleFastDiskTypes =[]string{"managed-permium"}

const (
// Hardcoding networkProvider to multus and this can be changed later to accomodate other providers
networkProvider = "multus"
Expand All @@ -41,15 +54,10 @@ func (r *ReconcileStorageCluster) ensureCephCluster(sc *ocsv1.StorageCluster, re
// this is for performance optimization of slow device class
//TODO: If for a StorageDeviceSet there is a separate metadata pvc template, check for StorageClass of data pvc template only
for i, ds := range sc.Spec.StorageDeviceSets {
throttle, err := r.throttleStorageDevices(*ds.DataPVCTemplate.Spec.StorageClassName)
err := r.throttleStorageDevices(*ds.DataPVCTemplate.Spec.StorageClassName)
if err != nil {
return fmt.Errorf("Failed to verify StorageClass provisioner. %+v", err)
}
if throttle {
sc.Spec.StorageDeviceSets[i].Config.TuneSlowDeviceClass = true
} else {
sc.Spec.StorageDeviceSets[i].Config.TuneSlowDeviceClass = false
}
}

if isMultus(sc.Spec.Network) {
Expand Down Expand Up @@ -446,6 +454,7 @@ func newStorageClassDeviceSets(sc *ocsv1.StorageCluster, serverVersion *version.
VolumeClaimTemplates: []corev1.PersistentVolumeClaim{ds.DataPVCTemplate},
Portable: portable,
TuneSlowDeviceClass: ds.Config.TuneSlowDeviceClass,
TuneFastDeviceClass: ds.Config.TuneFastDeviceClass,
Encrypted: sc.Spec.Encryption.Enable,
}

Expand Down Expand Up @@ -475,3 +484,29 @@ func newCephDaemonResources(custom map[string]corev1.ResourceRequirements) map[s

return resources
}

func (r *ReconcileStorageCluster) throttleStorageDevices(storageClassName string) (bool, error) {
storageClass := &storagev1.StorageClass{}
err := r.client.Get(context.TODO(), types.NamespacedName{Namespace: "", Name: storageClassName}, storageClass)
if err != nil {
return false, fmt.Errorf("failed to retrieve StorageClass %q. %+v", storageClassName, err)
}
bool flag := false
switch storageClass.Provisioner {
case string(EBS):
if contains(throttleDiskTypes, storageClass.Parameters["type"]) {
flag = true
sc.Spec.StorageDeviceSets[i].Config.TuneDeviceClass = true
}
}
case string(Premium):
if contains(throttleFastDiskTypes, storageClass.Parameters["type"]) {
flag = true
sc.Spec.StorageDeviceSets[i].Config.TuneFastDeviceClass = true
}
if flag {
sc.Spec.StorageDeviceSets[i].Config.TuneFastDeviceClass = false
sc.Spec.StorageDeviceSets[i].Config.TuneDeviceClass = false
}
return nil
}
24 changes: 1 addition & 23 deletions pkg/controller/storagecluster/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/operator-framework/operator-sdk/pkg/ready"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -30,9 +29,6 @@ import (
// (or not) a particular resource
type ReconcileStrategy string

// StorageClassProvisionerType is a string representing StorageClass Provisioner. E.g: aws-ebs
type StorageClassProvisionerType string

// ensureFunc which encapsulate all the 'ensure*' type functions
type ensureFunc func(*ocsv1.StorageCluster, logr.Logger) error

Expand All @@ -47,8 +43,7 @@ mon_osd_nearfull_ratio = .75
osd_memory_target_cgroup_limit_ratio = 0.5
`
monCountOverrideEnvVar = "MON_COUNT_OVERRIDE"
// EBS represents AWS EBS provisioner for StorageClass
EBS StorageClassProvisionerType = "kubernetes.io/aws-ebs"

//Name of MetadataPVCTemplate
metadataPVCName = "metadata"

Expand All @@ -73,8 +68,6 @@ var validTopologyLabelKeys = []string{
"topology.rook.io",
}

var throttleDiskTypes = []string{"gp2", "io1"}

// Reconcile reads that state of the cluster for a StorageCluster object and makes changes based on the state read
// and what is in the StorageCluster.Spec
// Note:
Expand Down Expand Up @@ -458,21 +451,6 @@ func (r *ReconcileStorageCluster) ensureCephConfig(sc *ocsv1.StorageCluster, req
return nil
}

func (r *ReconcileStorageCluster) throttleStorageDevices(storageClassName string) (bool, error) {
storageClass := &storagev1.StorageClass{}
err := r.client.Get(context.TODO(), types.NamespacedName{Namespace: "", Name: storageClassName}, storageClass)
if err != nil {
return false, fmt.Errorf("failed to retrieve StorageClass %q. %+v", storageClassName, err)
}
switch storageClass.Provisioner {
case string(EBS):
if contains(throttleDiskTypes, storageClass.Parameters["type"]) {
return true, nil
}
}
return false, nil
}

func (r *ReconcileStorageCluster) isActiveStorageCluster(instance *ocsv1.StorageCluster) (bool, error) {
storageClusterList := ocsv1.StorageClusterList{}

Expand Down

0 comments on commit 76d77ba

Please sign in to comment.