ceph: add the ability to set any pool property

We can now explicitly set any property on a given pool by using the new
Property field in the CephBlockPool Spec.

Also, this fixes the case where both `CephBlockPool` and `CephCluster`
are created at the same time. When Rook creates the pool, the cluster is
still being bootstrapped and the global option
`osd_pool_default_pg_autoscale_mode` has not bee set yet. So the pool
gets created but its `pg_autoscale_mode` property is set to `warn`
instead of `on`.

Closes: https://github.com/rook/rook/issues/5608V
Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han committed 2020-06-17 10:08:00 +02:00
1 parent c143bdb68d
commit c7f255a0e8
23 files changed
+185 -74

No files matched your search

+23 -3
View File
@@ -70,8 +70,6 @@ When creating an erasure-coded pool, it is highly recommended to create the pool
* `replicated`: Settings for a replicated pool. If specified, `erasureCoded` settings must not be specified.
* `size`: The desired number of copies to make of the data in the pool.
* `targetSizeRatio:` gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity of a given pool, for more info see the [ceph documentation](https://docs.ceph.com/docs/master/rados/operations/placement-groups/#specifying-expected-pool-size)
* `requireSafeReplicaSize`: set to false if you want to create a pool with size 1, setting pool size 1 could lead to data loss without recovery. Make sure you are *ABSOLUTELY CERTAIN* that is what you want.
* `erasureCoded`: Settings for an erasure-coded pool. If specified, `replicated` settings must not be specified. See below for more details on [erasure coding](#erasure-coding).
* `dataChunks`: Number of chunks to divide the original object into
* `codingChunks`: Number of coding chunks to generate
@@ -83,7 +81,29 @@ When creating an erasure-coded pool, it is highly recommended to create the pool
> **NOTE**: Neither Rook, nor Ceph, prevent the creation of a cluster where the replicated data (or Erasure Coded chunks) can be written safely. By design, Ceph will delay checking for suitable OSDs until a write request is made and this write can hang if there are not sufficient OSDs to satisfy the request.
* `deviceClass`: Sets up the CRUSH rule for the pool to distribute data only on the specified device class. If left empty or unspecified, the pool will use the cluster's default CRUSH root, which usually distributes data over all OSDs, regardless of their class.
* `crushRoot`: The root in the crush map to be used by the pool. If left empty or unspecified, the default root will be used. Creating a crush hierarchy for the OSDs currently requires the Rook toolbox to run the Ceph tools described [here](http://docs.ceph.com/docs/master/rados/operations/crush-map/#modifying-the-crush-map).
* `compressionMode`: Sets up the pool for inline compression when using a Bluestore OSD. If left unspecified does not setup any compression mode for the pool. Values supported are the same as Bluestore inline compression [modes](https://docs.ceph.com/docs/master/rados/configuration/bluestore-config-ref/#inline-compression), such as `none`, `passive`, `aggressive`, and `force`.
* `parameters`: Sets any [parameters](https://docs.ceph.com/docs/master/rados/operations/pools/#set-pool-values) listed to the given pool
* `target_size_ratio:` gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity of a given pool, for more info see the [ceph documentation](https://docs.ceph.com/docs/master/rados/operations/placement-groups/#specifying-expected-pool-size)
* `requireSafeReplicaSize`: set to false if you want to create a pool with size 1, setting pool size 1 could lead to data loss without recovery. Make sure you are *ABSOLUTELY CERTAIN* that is what you want.
* `compression_mode`: Sets up the pool for inline compression when using a Bluestore OSD. If left unspecified does not setup any compression mode for the pool. Values supported are the same as Bluestore inline compression [modes](https://docs.ceph.com/docs/master/rados/configuration/bluestore-config-ref/#inline-compression), such as `none`, `passive`, `aggressive`, and `force`.
### Add specific pool properties
With `poolProperties` you can set any pool property:
```yaml
spec:
parameters:
<name of the parameter>: <parameter value>
```
For instance:
```yaml
spec:
parameters:
min_size: 1
```
### Erasure Coding
+1
View File
@@ -9,6 +9,7 @@
- Added a [toolbox job](Documentation/ceph-toolbox.md#toolbox-job) for running a script with Ceph commands, similar to running commands in the Rook toolbox.
- Ceph RBD Mirror daemon has been extracted to its own CRD, it has been removed from the `CephCluster` CRD, see the [rbd-mirror crd](Documentation/ceph-rbd-mirror-crd.html).
- CephCluster CRD has been converted to use the controller-runtime framework.
- CephBlockPool CRD has a new field called `parameters` which allows to set any property on a given [pool](Documentation/ceph-pool-crd.html#add-specific-pool-properties)
### EdgeFS
@@ -528,6 +528,8 @@ spec:
- passive
- aggressive
- force
parameters:
type: object
subresources:
status: {}
---
@@ -612,6 +612,8 @@ spec:
- passive
- aggressive
- force
parameters:
type: object
subresources:
status: {}
# OLM: END CEPH BLOCK POOL CRD
@@ -15,6 +15,13 @@ spec:
replicated:
size: 3
requireSafeReplicaSize: true
parameters:
# Inline compression mode for the data pool
# Further reference: https://docs.ceph.com/docs/nautilus/rados/configuration/bluestore-config-ref/#inline-compression
compression_mode: none
# gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity of a given pool
# for more info: https://docs.ceph.com/docs/master/rados/operations/placement-groups/#specifying-expected-pool-size
#target_size_ratio: .5
# The list of data pool specs. Can use replication or erasure coding.
dataPools:
- failureDomain: host
@@ -26,9 +33,13 @@ spec:
# gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity of a given pool
# for more info: https://docs.ceph.com/docs/master/rados/operations/placement-groups/#specifying-expected-pool-size
#targetSizeRatio: .5
# Inline compression mode for the data pool
# Further reference: https://docs.ceph.com/docs/nautilus/rados/configuration/bluestore-config-ref/#inline-compression
compressionMode: none
parameters:
# Inline compression mode for the data pool
# Further reference: https://docs.ceph.com/docs/nautilus/rados/configuration/bluestore-config-ref/#inline-compression
compression_mode: none
# gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity of a given pool
# for more info: https://docs.ceph.com/docs/master/rados/operations/placement-groups/#specifying-expected-pool-size
#target_size_ratio: .5
# Whether to preserve metadata and data pools on filesystem deletion
preservePoolsOnDelete: true
# The metadata service (mds) configuration
+10 -5
View File
@@ -18,9 +18,13 @@ spec:
# Disallow setting pool with replica 1, this could lead to data loss without recovery.
# Make sure you're *ABSOLUTELY CERTAIN* that is what you want
requireSafeReplicaSize: true
parameters:
# Inline compression mode for the data pool
# Further reference: https://docs.ceph.com/docs/nautilus/rados/configuration/bluestore-config-ref/#inline-compression
compression_mode: none
# gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity of a given pool
# for more info: https://docs.ceph.com/docs/master/rados/operations/placement-groups/#specifying-expected-pool-size
#targetSizeRatio: .5
#target_size_ratio: .5
# The pool spec used to create the data pool. Can use replication or erasure coding.
dataPool:
failureDomain: host
@@ -29,12 +33,13 @@ spec:
# Disallow setting pool with replica 1, this could lead to data loss without recovery.
# Make sure you're *ABSOLUTELY CERTAIN* that is what you want
requireSafeReplicaSize: true
parameters:
# Inline compression mode for the data pool
# Further reference: https://docs.ceph.com/docs/nautilus/rados/configuration/bluestore-config-ref/#inline-compression
compression_mode: none
# gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity of a given pool
# for more info: https://docs.ceph.com/docs/master/rados/operations/placement-groups/#specifying-expected-pool-size
#targetSizeRatio: .5
# Inline compression mode for the data pool
# Further reference: https://docs.ceph.com/docs/nautilus/rados/configuration/bluestore-config-ref/#inline-compression
compressionMode: none
#target_size_ratio: .5
# Whether to preserve metadata and data pools on object store deletion
preservePoolsOnDelete: false
# The gateway service configuration
@@ -16,8 +16,11 @@ spec:
erasureCoded:
dataChunks: 2
codingChunks: 1
# Inline compression mode for the data pool
compressionMode: none
# Set any property on a given pool
# see https://docs.ceph.com/docs/master/rados/operations/pools/#set-pool-values
parameters:
# Inline compression mode for the data pool
compression_mode: none
# A key/value list of annotations
annotations:
# key: value
+9 -6
View File
@@ -18,18 +18,21 @@ spec:
# Disallow setting pool with replica 1, this could lead to data loss without recovery.
# Make sure you're *ABSOLUTELY CERTAIN* that is what you want
requireSafeReplicaSize: true
# gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity of a given pool
# for more info: https://docs.ceph.com/docs/master/rados/operations/placement-groups/#specifying-expected-pool-size
#targetSizeRatio: .5
# Ceph CRUSH root location of the rule
# For reference: https://docs.ceph.com/docs/nautilus/rados/operations/crush-map/#types-and-buckets
#crushRoot: my-root
# The Ceph CRUSH device class associated with the CRUSH replicated rule
# For reference: https://docs.ceph.com/docs/nautilus/rados/operations/crush-map/#device-classes
#deviceClass: my-class
# Inline compression mode for the data pool
# Further reference: https://docs.ceph.com/docs/nautilus/rados/configuration/bluestore-config-ref/#inline-compression
compressionMode: none
# Set any property on a given pool
# see https://docs.ceph.com/docs/master/rados/operations/pools/#set-pool-values
parameters:
# Inline compression mode for the data pool
# Further reference: https://docs.ceph.com/docs/nautilus/rados/configuration/bluestore-config-ref/#inline-compression
compression_mode: none
# gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity of a given pool
# for more info: https://docs.ceph.com/docs/master/rados/operations/placement-groups/#specifying-expected-pool-size
#target_size_ratio: .5
# A key/value list of annotations
annotations:
# key: value
+8
View File
@@ -23,3 +23,11 @@ func (p *PoolSpec) IsReplicated() bool {
func (p *PoolSpec) IsErasureCoded() bool {
return p.ErasureCoded.CodingChunks > 0 || p.ErasureCoded.DataChunks > 0
}
func (p *PoolSpec) IsCompressionEnabled() bool {
return p.CompressionMode != ""
}
func (p *ReplicatedSpec) IsTargetRatioEnabled() bool {
return p.TargetSizeRatio != 0
}
+3
View File
@@ -269,6 +269,9 @@ type PoolSpec struct {
// The erasure code settings
ErasureCoded ErasureCodedSpec `json:"erasureCoded"`
// Parameters is a list of properties to enable on a given pool
Parameters map[string]string `json:"parameters,omitempty"`
}
type Status struct {
@@ -31,7 +31,7 @@ func (in *CephBlockPool) DeepCopyInto(out *CephBlockPool) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
in.Spec.DeepCopyInto(&out.Spec)
if in.Status != nil {
in, out := &in.Status, &out.Status
*out = new(Status)
@@ -1041,11 +1041,13 @@ func (in *ExternalSpec) DeepCopy() *ExternalSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FilesystemSpec) DeepCopyInto(out *FilesystemSpec) {
*out = *in
out.MetadataPool = in.MetadataPool
in.MetadataPool.DeepCopyInto(&out.MetadataPool)
if in.DataPools != nil {
in, out := &in.DataPools, &out.DataPools
*out = make([]PoolSpec, len(*in))
copy(*out, *in)
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
in.MetadataServer.DeepCopyInto(&out.MetadataServer)
return
@@ -1280,8 +1282,8 @@ func (in *ObjectRealmSpec) DeepCopy() *ObjectRealmSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ObjectStoreSpec) DeepCopyInto(out *ObjectStoreSpec) {
*out = *in
out.MetadataPool = in.MetadataPool
out.DataPool = in.DataPool
in.MetadataPool.DeepCopyInto(&out.MetadataPool)
in.DataPool.DeepCopyInto(&out.DataPool)
in.Gateway.DeepCopyInto(&out.Gateway)
out.Zone = in.Zone
return
@@ -1350,6 +1352,13 @@ func (in *PoolSpec) DeepCopyInto(out *PoolSpec) {
*out = *in
out.Replicated = in.Replicated
out.ErasureCoded = in.ErasureCoded
if in.Parameters != nil {
in, out := &in.Parameters, &out.Parameters
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
return
}
+25 -16
View File
@@ -28,8 +28,12 @@ import (
)
const (
confirmFlag = "--yes-i-really-mean-it"
reallyConfirmFlag = "--yes-i-really-really-mean-it"
confirmFlag = "--yes-i-really-mean-it"
reallyConfirmFlag = "--yes-i-really-really-mean-it"
targetSizeRatioProperty = "target_size_ratio"
compressionModeProperty = "compression_mode"
PgAutoscaleModeProperty = "pg_autoscale_mode"
PgAutoscaleModeOn = "on"
)
type CephStoragePoolSummary struct {
@@ -232,11 +236,23 @@ func givePoolAppTag(context *clusterd.Context, namespace string, poolName string
}
func setCommonPoolProperties(context *clusterd.Context, pool cephv1.PoolSpec, namespace, poolName, appName string) error {
compressionModeProperty := "compression_mode"
if pool.CompressionMode != "" {
err := SetPoolProperty(context, namespace, poolName, compressionModeProperty, pool.CompressionMode)
if len(pool.Parameters) == 0 {
pool.Parameters = make(map[string]string)
}
if pool.Replicated.IsTargetRatioEnabled() {
pool.Parameters[targetSizeRatioProperty] = strconv.FormatFloat(pool.Replicated.TargetSizeRatio, 'f', -1, 32)
}
if pool.IsCompressionEnabled() {
pool.Parameters[compressionModeProperty] = pool.CompressionMode
}
// Apply properties
for propName, propValue := range pool.Parameters {
err := SetPoolProperty(context, namespace, poolName, propName, propValue)
if err != nil {
return errors.Wrapf(err, "failed to set property %q on pool %q to %q", compressionModeProperty, poolName, pool.CompressionMode)
logger.Errorf("failed to set property %q to pool %q to %q. %v", propName, poolName, propValue, err)
}
}
@@ -289,18 +305,10 @@ func CreateReplicatedPoolForApp(context *clusterd.Context, namespace, poolName s
}
// the pool is type replicated, set the size for the pool now that it's been created
if err = SetPoolReplicatedSizeProperty(context, namespace, poolName, strconv.FormatUint(uint64(pool.Replicated.Size), 10)); err != nil {
if err := SetPoolReplicatedSizeProperty(context, namespace, poolName, strconv.FormatUint(uint64(pool.Replicated.Size), 10)); err != nil {
return errors.Wrapf(err, "failed to set size property to replicated pool %q to %d", poolName, pool.Replicated.Size)
}
targetSizeRatioProperty := "target_size_ratio"
if pool.Replicated.TargetSizeRatio != 0 {
err = SetPoolProperty(context, namespace, poolName, targetSizeRatioProperty, strconv.FormatFloat(pool.Replicated.TargetSizeRatio, 'f', -1, 32))
if err != nil {
return errors.Wrapf(err, "failed to set property %q to replicated pool %q to %.2f", targetSizeRatioProperty, poolName, pool.Replicated.TargetSizeRatio)
}
}
if err = setCommonPoolProperties(context, pool, namespace, poolName, appName); err != nil {
return err
}
@@ -339,9 +347,10 @@ func createReplicationCrushRule(context *clusterd.Context, namespace, ruleName s
// SetPoolProperty sets a property to a given pool
func SetPoolProperty(context *clusterd.Context, namespace, name, propName, propVal string) error {
args := []string{"osd", "pool", "set", name, propName, propVal}
logger.Infof("setting pool property %q to %q on pool %q", propName, propVal, name)
_, err := NewCephCommand(context, namespace, args).Run()
if err != nil {
return errors.Wrapf(err, "failed to set pool property %s on pool %s", propName, name)
return errors.Wrapf(err, "failed to set pool property %q on pool %q", propName, name)
}
return nil
}
+2 -15
View File
@@ -26,10 +26,8 @@ import (
appsv1 "k8s.io/api/apps/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
"github.com/rook/rook/pkg/operator/ceph/controller"
"github.com/rook/rook/pkg/operator/ceph/file/mds"
"github.com/rook/rook/pkg/operator/ceph/object"
"github.com/rook/rook/pkg/operator/ceph/version"
"github.com/coreos/pkg/capnslog"
@@ -41,6 +39,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
"github.com/rook/rook/pkg/operator/ceph/disruption/controllerconfig"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -163,7 +162,7 @@ func (r *ReconcileNode) reconcile(request reconcile.Request) (reconcile.Result,
}
clusterImage := cephCluster.Spec.CephVersion.Image
cephVersion, err := getImageVersion(cephCluster)
cephVersion, err := opcontroller.GetImageVersion(cephCluster)
if err != nil {
logger.Errorf("ceph version not found for image %q used by cluster %q. %v", clusterImage, cephCluster.Name, err)
return reconcile.Result{}, nil
@@ -212,18 +211,6 @@ func (r *ReconcileNode) cephPodList() ([]corev1.Pod, error) {
return cephPods, nil
}
// getImageVersion returns the CephVersion registered for a specified image (if any) and whether any image was found.
func getImageVersion(cephCluster cephv1.CephCluster) (*version.CephVersion, error) {
// If the Ceph cluster has not yet recorded the image and version for the current image in its spec, then the Crash
// controller should wait for the version to be detected.
if cephCluster.Status.CephVersion != nil && cephCluster.Spec.CephVersion.Image == cephCluster.Status.CephVersion.Image {
logger.Debugf("ceph version found %q", cephCluster.Status.CephVersion.Version)
return controller.ExtractCephVersionFromLabel(cephCluster.Status.CephVersion.Version)
}
return nil, errors.New("attempt to determine ceph version for the current cluster image timed out")
}
func (r *ReconcileNode) deleteCrashCollector(deployment appsv1.Deployment) error {
deploymentName := deployment.ObjectMeta.Name
namespace := deployment.ObjectMeta.Namespace
+13 -2
View File
@@ -52,7 +52,7 @@ const (
serviceAccountName = "rook-ceph-mgr"
prometheusModuleName = "prometheus"
crashModuleName = "crash"
pgautoscalerModuleName = "pg_autoscaler"
PgautoscalerModuleName = "pg_autoscaler"
balancerModuleName = "balancer"
balancerModuleMode = "upmap"
metricsPort = 9283
@@ -322,7 +322,7 @@ func (c *Cluster) configureMgrModules() error {
}
// Configure special settings for individual modules that are enabled
if module.Name == pgautoscalerModuleName {
if module.Name == PgautoscalerModuleName {
monStore := config.GetMonStore(c.context, c.Namespace)
// Ceph Octopus will have that option enabled
err := monStore.Set("global", "osd_pool_default_pg_autoscale_mode", "on")
@@ -406,3 +406,14 @@ func (c *Cluster) deployPrometheusRule(name, namespace string) error {
}
return nil
}
// IsModuleInSpec returns whether a module is present in the CephCluster manager spec
func IsModuleInSpec(modules []cephv1.Module, moduleName string) bool {
for _, v := range modules {
if v.Name == moduleName {
return true
}
}
return false
}
+2 -2
View File
@@ -155,12 +155,12 @@ func (r *ReconcileCephRBDMirror) reconcile(request reconcile.Request) (reconcile
}
// Make sure a CephCluster is present otherwise do nothing
cephClusterSpec, isReadyToReconcile, _, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName)
cephCluster, isReadyToReconcile, _, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName)
if !isReadyToReconcile {
logger.Debugf("CephCluster resource not ready in namespace %q, retrying in %q.", request.NamespacedName.Namespace, reconcileResponse.RequeueAfter.String())
return reconcileResponse, nil
}
r.cephClusterSpec = &cephClusterSpec
r.cephClusterSpec = &cephCluster.Spec
// Populate clusterInfo
// Always populate it during each reconcile
@@ -46,7 +46,7 @@ var (
)
// IsReadyToReconcile determines if a controller is ready to reconcile or not
func IsReadyToReconcile(c client.Client, clustercontext *clusterd.Context, namespacedName types.NamespacedName, controllerName string) (cephv1.ClusterSpec, bool, bool, reconcile.Result) {
func IsReadyToReconcile(c client.Client, clustercontext *clusterd.Context, namespacedName types.NamespacedName, controllerName string) (cephv1.CephCluster, bool, bool, reconcile.Result) {
cephClusterExists := false
// Running ceph commands won't work and the controller will keep re-queuing so I believe it's fine not to check
@@ -56,11 +56,11 @@ func IsReadyToReconcile(c client.Client, clustercontext *clusterd.Context, names
err := c.List(context.TODO(), clusterList, client.InNamespace(namespacedName.Namespace))
if err != nil {
logger.Errorf("%q:failed to fetch CephCluster %v", controllerName, err)
return cephv1.ClusterSpec{}, false, cephClusterExists, ImmediateRetryResult
return cephCluster, false, cephClusterExists, ImmediateRetryResult
}
if len(clusterList.Items) == 0 {
logger.Errorf("%q: no CephCluster resource found in namespace %q", controllerName, namespacedName.Namespace)
return cephv1.ClusterSpec{}, false, cephClusterExists, WaitForRequeueIfCephClusterNotReady
return cephCluster, false, cephClusterExists, WaitForRequeueIfCephClusterNotReady
}
cephClusterExists = true
cephCluster = clusterList.Items[0]
@@ -74,21 +74,21 @@ func IsReadyToReconcile(c client.Client, clustercontext *clusterd.Context, names
if err != nil {
if strings.Contains(err.Error(), "error calling conf_read_file") {
logger.Infof("%q: operator is not ready to run ceph command, cannot reconcile yet.", controllerName)
return cephCluster.Spec, false, cephClusterExists, WaitForRequeueIfCephClusterNotReady
return cephCluster, false, cephClusterExists, WaitForRequeueIfCephClusterNotReady
}
// We should not arrive there
logger.Errorf("%q: ceph command error %v", controllerName, err)
return cephCluster.Spec, false, cephClusterExists, ImmediateRetryResult
return cephCluster, false, cephClusterExists, ImmediateRetryResult
}
// If Ceph status is ok we can reconcile
if status.Health.Status == "HEALTH_OK" || status.Health.Status == "HEALTH_WARN" {
logger.Debugf("%q: ceph status is %q, operator is ready to run ceph command, reconciling", controllerName, status.Health.Status)
return cephCluster.Spec, true, cephClusterExists, reconcile.Result{}
return cephCluster, true, cephClusterExists, reconcile.Result{}
}
logger.Infof("%s: CephCluster %q found but skipping reconcile since Ceph health is %q", controllerName, cephCluster.Name, status.Health.Status)
return cephCluster.Spec, false, cephClusterExists, WaitForRequeueIfCephClusterNotReady
return cephCluster, false, cephClusterExists, WaitForRequeueIfCephClusterNotReady
}
// ClusterOwnerRef represents the owner reference of the CephCluster CR
+13
View File
@@ -18,6 +18,7 @@ package controller
import (
"github.com/pkg/errors"
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
"github.com/rook/rook/pkg/clusterd"
"github.com/rook/rook/pkg/daemon/ceph/client"
cephver "github.com/rook/rook/pkg/operator/ceph/version"
@@ -34,3 +35,15 @@ func ValidateCephVersionsBetweenLocalAndExternalClusters(context *clusterd.Conte
return *externalVersion, cephver.ValidateCephVersionsBetweenLocalAndExternalClusters(localVersion, *externalVersion)
}
// GetImageVersion returns the CephVersion registered for a specified image (if any) and whether any image was found.
func GetImageVersion(cephCluster cephv1.CephCluster) (*cephver.CephVersion, error) {
// If the Ceph cluster has not yet recorded the image and version for the current image in its spec, then the Crash
// controller should wait for the version to be detected.
if cephCluster.Status.CephVersion != nil && cephCluster.Spec.CephVersion.Image == cephCluster.Status.CephVersion.Image {
logger.Debugf("ceph version found %q", cephCluster.Status.CephVersion.Version)
return ExtractCephVersionFromLabel(cephCluster.Status.CephVersion.Version)
}
return nil, errors.New("attempt to determine ceph version for the current cluster image timed out")
}
+2 -2
View File
@@ -156,7 +156,7 @@ func (r *ReconcileCephFilesystem) reconcile(request reconcile.Request) (reconcil
}
// Make sure a CephCluster is present otherwise do nothing
cephClusterSpec, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName)
cephCluster, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName)
if !isReadyToReconcile {
// This handles the case where the Ceph Cluster is gone and we want to delete that CR
// We skip the deleteFilesystem() function since everything is gone already
@@ -176,7 +176,7 @@ func (r *ReconcileCephFilesystem) reconcile(request reconcile.Request) (reconcil
}
return reconcileResponse, nil
}
r.cephClusterSpec = &cephClusterSpec
r.cephClusterSpec = &cephCluster.Spec
// Populate clusterInfo
// Always populate it during each reconcile
+2 -2
View File
@@ -155,7 +155,7 @@ func (r *ReconcileCephNFS) reconcile(request reconcile.Request) (reconcile.Resul
}
// Make sure a CephCluster is present otherwise do nothing
cephClusterSpec, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName)
cephCluster, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName)
if !isReadyToReconcile {
// This handles the case where the Ceph Cluster is gone and we want to delete that CR
// We skip the deleteStore() function since everything is gone already
@@ -175,7 +175,7 @@ func (r *ReconcileCephNFS) reconcile(request reconcile.Request) (reconcile.Resul
}
return reconcileResponse, nil
}
r.cephClusterSpec = &cephClusterSpec
r.cephClusterSpec = &cephCluster.Spec
// Populate clusterInfo
// Always populate it during each reconcile
+2 -2
View File
@@ -165,7 +165,7 @@ func (r *ReconcileCephObjectStore) reconcile(request reconcile.Request) (reconci
}
// Make sure a CephCluster is present otherwise do nothing
cephClusterSpec, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName)
cephCluster, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName)
if !isReadyToReconcile {
// This handles the case where the Ceph Cluster is gone and we want to delete that CR
// We skip the deleteStore() function since everything is gone already
@@ -186,7 +186,7 @@ func (r *ReconcileCephObjectStore) reconcile(request reconcile.Request) (reconci
return reconcileResponse, nil
}
r.cephClusterSpec = &cephClusterSpec
r.cephClusterSpec = &cephCluster.Spec
// Populate clusterInfo
// Always populate it during each reconcile
+20 -1
View File
@@ -28,6 +28,7 @@ import (
"github.com/pkg/errors"
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
"github.com/rook/rook/pkg/clusterd"
"github.com/rook/rook/pkg/operator/ceph/cluster/mgr"
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
"github.com/rook/rook/pkg/operator/k8sutil"
kerrors "k8s.io/apimachinery/pkg/api/errors"
@@ -137,7 +138,7 @@ func (r *ReconcileCephBlockPool) reconcile(request reconcile.Request) (reconcile
}
// Make sure a CephCluster is present otherwise do nothing
_, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName)
cephCluster, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName)
if !isReadyToReconcile {
// This handles the case where the Ceph Cluster is gone and we want to delete that CR
// We skip the deletePool() function since everything is gone already
@@ -189,6 +190,24 @@ func (r *ReconcileCephBlockPool) reconcile(request reconcile.Request) (reconcile
updateStatus(r.client, request.NamespacedName, k8sutil.ReconcilingStatus)
// Get CephCluster version
cephVersion, err := opcontroller.GetImageVersion(cephCluster)
if err != nil {
return reconcile.Result{}, errors.Wrapf(err, "failed to fetch ceph version from cephcluster %q", cephCluster.Name)
}
// If the CephCluster has enabled the "pg_autoscaler" module and is running Nautilus
// we force the pg_autoscale_mode to "on"
_, propertyExists := cephBlockPool.Spec.Parameters[cephclient.PgAutoscaleModeProperty]
if mgr.IsModuleInSpec(cephCluster.Spec.Mgr.Modules, mgr.PgautoscalerModuleName) &&
!cephVersion.IsAtLeastOctopus() &&
!propertyExists {
if len(cephBlockPool.Spec.Parameters) == 0 {
cephBlockPool.Spec.Parameters = make(map[string]string)
}
cephBlockPool.Spec.Parameters[cephclient.PgAutoscaleModeProperty] = cephclient.PgAutoscaleModeOn
}
// CREATE/UPDATE
reconcileResponse, err = r.reconcileCreatePool(cephBlockPool)
if err != nil {
@@ -320,6 +320,9 @@ func TestCephBlockPoolController(t *testing.T) {
},
Status: cephv1.ClusterStatus{
Phase: "",
CephVersion: &cephv1.ClusterVersion{
Version: "14.2.9-0",
},
},
}
@@ -1747,7 +1747,9 @@ spec:
size: ` + replicaSize + `
targetSizeRatio: .5
requireSafeReplicaSize: false
compressionMode: aggressive`
compressionMode: aggressive
poolProperties:
pg_autoscale_mode: on`
}
func (m *CephManifestsV1_2) GetBlockStorageClassDef(csi bool, poolName, storageClassName, reclaimPolicy, namespace, systemNamespace string) string {