Skip to content

Commit

Permalink
Merge pull request #2795 from rewantsoni/blockpools
Browse files Browse the repository at this point in the history
update the cephblockpool reonciler to disable mirroring
  • Loading branch information
openshift-merge-bot[bot] committed Sep 13, 2024
2 parents b82b171 + bdbcb58 commit 6cbff2c
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 22 deletions.
2 changes: 1 addition & 1 deletion api/v1/storagecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type StorageClusterSpec struct {
Arbiter ArbiterSpec `json:"arbiter,omitempty"`
// Mirroring specifies data mirroring configuration for the storage cluster.
// This configuration will only be applied to resources managed by the operator.
Mirroring MirroringSpec `json:"mirroring,omitempty"`
Mirroring *MirroringSpec `json:"mirroring,omitempty"`
// OverprovisionControl specifies the allowed hard-limit PVs overprovisioning relative to
// the effective usable storage capacity.
OverprovisionControl []OverprovisionControlSpec `json:"overprovisionControl,omitempty"`
Expand Down
6 changes: 5 additions & 1 deletion api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions controllers/storagecluster/cephblockpools.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ func (o *ocsCephBlockPools) reconcileCephBlockPool(r *StorageClusterReconciler,
cephBlockPool.Spec.PoolSpec.Replicated = generateCephReplicatedSpec(storageCluster, "data")
cephBlockPool.Spec.PoolSpec.EnableRBDStats = true

if storageCluster.Spec.Mirroring.Enabled {
cephBlockPool.Spec.PoolSpec.Mirroring.Enabled = true
cephBlockPool.Spec.PoolSpec.Mirroring.Mode = "image"
cephBlockPool.Spec.PoolSpec.Mirroring.Peers = o.addPeerSecretsToCephBlockPool(r, storageCluster, cephBlockPool.Name, cephBlockPool.Namespace)
if storageCluster.Spec.Mirroring != nil {
if storageCluster.Spec.Mirroring.Enabled {
cephBlockPool.Spec.PoolSpec.Mirroring.Enabled = true
cephBlockPool.Spec.PoolSpec.Mirroring.Mode = "image"
cephBlockPool.Spec.PoolSpec.Mirroring.Peers = o.addPeerSecretsToCephBlockPool(r, storageCluster, cephBlockPool.Name, cephBlockPool.Namespace)
} else {
cephBlockPool.Spec.PoolSpec.Mirroring = cephv1.MirroringSpec{Enabled: false}
}
}
return controllerutil.SetControllerReference(storageCluster, cephBlockPool, r.Scheme)
})
Expand Down Expand Up @@ -249,10 +253,14 @@ func (o *ocsCephBlockPools) reconcileNonResilientCephBlockPool(r *StorageCluster
}
cephBlockPool.Spec.PoolSpec.EnableRBDStats = true

if storageCluster.Spec.Mirroring.Enabled {
cephBlockPool.Spec.PoolSpec.Mirroring.Enabled = true
cephBlockPool.Spec.PoolSpec.Mirroring.Mode = "image"
cephBlockPool.Spec.PoolSpec.Mirroring.Peers = o.addPeerSecretsToCephBlockPool(r, storageCluster, cephBlockPool.Name, cephBlockPool.Namespace)
if storageCluster.Spec.Mirroring != nil {
if storageCluster.Spec.Mirroring.Enabled {
cephBlockPool.Spec.PoolSpec.Mirroring.Enabled = true
cephBlockPool.Spec.PoolSpec.Mirroring.Mode = "image"
cephBlockPool.Spec.PoolSpec.Mirroring.Peers = o.addPeerSecretsToCephBlockPool(r, storageCluster, cephBlockPool.Name, cephBlockPool.Namespace)
} else {
cephBlockPool.Spec.PoolSpec.Mirroring = cephv1.MirroringSpec{Enabled: false}
}
}
return controllerutil.SetControllerReference(storageCluster, cephBlockPool, r.Scheme)
})
Expand Down
6 changes: 3 additions & 3 deletions controllers/storagecluster/cephblockpools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestInjectingPeerTokenToCephBlockPool(t *testing.T) {
label: "test-injecting-peer-token-to-cephblockpool",
createRuntimeObjects: false,
spec: &api.StorageClusterSpec{
Mirroring: api.MirroringSpec{
Mirroring: &api.MirroringSpec{
Enabled: true,
PeerSecretNames: []string{testPeerSecretName},
},
Expand All @@ -65,7 +65,7 @@ func TestInjectingPeerTokenToCephBlockPool(t *testing.T) {
label: "test-injecting-empty-peer-token-to-cephblockpool",
createRuntimeObjects: false,
spec: &api.StorageClusterSpec{
Mirroring: api.MirroringSpec{
Mirroring: &api.MirroringSpec{
Enabled: true,
PeerSecretNames: []string{},
},
Expand All @@ -75,7 +75,7 @@ func TestInjectingPeerTokenToCephBlockPool(t *testing.T) {
label: "test-injecting-invalid-peer-token-cephblockpool",
createRuntimeObjects: false,
spec: &api.StorageClusterSpec{
Mirroring: api.MirroringSpec{
Mirroring: &api.MirroringSpec{
Enabled: true,
PeerSecretNames: []string{"wrong-secret-name"},
},
Expand Down
6 changes: 3 additions & 3 deletions controllers/storagecluster/cephrbdmirrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (obj *ocsCephRbdMirrors) ensureCreated(r *StorageClusterReconciler, instanc
return reconcile.Result{}, err
}

if !instance.Spec.Mirroring.Enabled {
if instance.Spec.Mirroring == nil || !instance.Spec.Mirroring.Enabled {
return reconcile.Result{}, r.deleteCephRbdMirrorInstance(cephRbdMirrors)
}

Expand Down Expand Up @@ -168,7 +168,7 @@ ceph config rm mgr mgr/rbd_support/log_level
echo "completed"`

// Mirroring is enabled but the debug logging is disabled
if sc.Spec.Mirroring.Enabled && !rbdMirrorDebugLoggingEnabled {
if sc.Spec.Mirroring != nil && sc.Spec.Mirroring.Enabled && !rbdMirrorDebugLoggingEnabled {

err := r.Client.Create(r.ctx, getRbdMirrorDebugLoggingJob(sc, enableRbdMirrorDebugLoggingJobName, enableRbdMirrorDebugLoggingCommands))
if err != nil && !errors.IsAlreadyExists(err) {
Expand All @@ -190,7 +190,7 @@ ceph config rm mgr mgr/rbd_support/log_level
rbdMirrorDebugLoggingEnabled = true
}
// Mirroring is disabled but the debug logging is enabled
if !sc.Spec.Mirroring.Enabled && rbdMirrorDebugLoggingEnabled {
if (sc.Spec.Mirroring == nil || !sc.Spec.Mirroring.Enabled) && rbdMirrorDebugLoggingEnabled {
err := r.Client.Create(r.ctx, getRbdMirrorDebugLoggingJob(sc, disableRbdMirrorDebugLoggingJobName, disableRbdMirrorDebugLoggingCommands))
if err != nil && !errors.IsAlreadyExists(err) {
return reconcile.Result{}, err
Expand Down
4 changes: 2 additions & 2 deletions controllers/storagecluster/cephrbdmirrors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestCephRbdMirror(t *testing.T) {
label: "create-ceph-rbd-mirror",
createRuntimeObjects: false,
spec: &api.StorageClusterSpec{
Mirroring: api.MirroringSpec{
Mirroring: &api.MirroringSpec{
Enabled: true,
PeerSecretNames: []string{testPeerSecretName},
},
Expand All @@ -34,7 +34,7 @@ func TestCephRbdMirror(t *testing.T) {
label: "delete-ceph-rbd-mirror",
createRuntimeObjects: false,
spec: &api.StorageClusterSpec{
Mirroring: api.MirroringSpec{
Mirroring: &api.MirroringSpec{
Enabled: false,
},
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6cbff2c

Please sign in to comment.