Skip to content

Commit a156f27

Browse files
authored
Merge pull request rook#16115 from sp98/clusterCephxStatus-uninitialized
core: init cephxStatus on cephCluster
2 parents 7be445d + a07f247 commit a156f27

7 files changed

Lines changed: 159 additions & 8 deletions

File tree

Documentation/CRDs/specification.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4547,7 +4547,7 @@ are not rotated.</p>
45474547
<h3 id="ceph.rook.io/v1.CephxStatus">CephxStatus
45484548
</h3>
45494549
<p>
4550-
(<em>Appears on:</em><a href="#ceph.rook.io/v1.LocalCephxStatus">LocalCephxStatus</a>)
4550+
(<em>Appears on:</em><a href="#ceph.rook.io/v1.ClusterCephxStatus">ClusterCephxStatus</a>, <a href="#ceph.rook.io/v1.LocalCephxStatus">LocalCephxStatus</a>)
45514551
</p>
45524552
<div>
45534553
</div>
@@ -4779,6 +4779,37 @@ Ceph cluster. Daemon CephX keys can be rotated without affecting client connecti
47794779
</tr>
47804780
</tbody>
47814781
</table>
4782+
<h3 id="ceph.rook.io/v1.ClusterCephxStatus">ClusterCephxStatus
4783+
</h3>
4784+
<p>
4785+
(<em>Appears on:</em><a href="#ceph.rook.io/v1.ClusterStatus">ClusterStatus</a>)
4786+
</p>
4787+
<div>
4788+
<p>ClusterCephxStatus defines the cephx key rotation status of various daemons on the cephCluster resource</p>
4789+
</div>
4790+
<table>
4791+
<thead>
4792+
<tr>
4793+
<th>Field</th>
4794+
<th>Description</th>
4795+
</tr>
4796+
</thead>
4797+
<tbody>
4798+
<tr>
4799+
<td>
4800+
<code>rbdMirrorPeer</code><br/>
4801+
<em>
4802+
<a href="#ceph.rook.io/v1.CephxStatus">
4803+
CephxStatus
4804+
</a>
4805+
</em>
4806+
</td>
4807+
<td>
4808+
<p>RBDMirrorPeer show the cephx key rotation status of the <code>rbd-mirror-peer</code> user</p>
4809+
</td>
4810+
</tr>
4811+
</tbody>
4812+
</table>
47824813
<h3 id="ceph.rook.io/v1.ClusterSecuritySpec">ClusterSecuritySpec
47834814
</h3>
47844815
<p>
@@ -5352,6 +5383,18 @@ CephStatus
53525383
</tr>
53535384
<tr>
53545385
<td>
5386+
<code>cephx</code><br/>
5387+
<em>
5388+
<a href="#ceph.rook.io/v1.ClusterCephxStatus">
5389+
ClusterCephxStatus
5390+
</a>
5391+
</em>
5392+
</td>
5393+
<td>
5394+
</td>
5395+
</tr>
5396+
<tr>
5397+
<td>
53555398
<code>storage</code><br/>
53565399
<em>
53575400
<a href="#ceph.rook.io/v1.CephStorage">

deploy/charts/rook-ceph/templates/resources.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5815,6 +5815,32 @@ spec:
58155815
type: object
58165816
type: object
58175817
type: object
5818+
cephx:
5819+
description: ClusterCephxStatus defines the cephx key rotation status of various daemons on the cephCluster resource
5820+
properties:
5821+
rbdMirrorPeer:
5822+
description: RBDMirrorPeer show the cephx key rotation status of the `rbd-mirror-peer` user
5823+
properties:
5824+
keyCephVersion:
5825+
description: |-
5826+
KeyCephVersion reports the Ceph version that created the current generation's keys. This is
5827+
same string format as reported by `CephCluster.status.version.version` to allow them to be
5828+
compared. E.g., `20.2.0-0`.
5829+
For all newly-created resources, this field set to the version of Ceph that created the key.
5830+
The special value "Uninitialized" indicates that keys are being created for the first time.
5831+
An empty string indicates that the version is unknown, as expected in brownfield deployments.
5832+
type: string
5833+
keyGeneration:
5834+
description: |-
5835+
KeyGeneration represents the CephX key generation for the last successful reconcile.
5836+
For all newly-created resources, this field is set to `1`.
5837+
When keys are rotated due to any rotation policy, the generation is incremented or updated to
5838+
the configured policy generation.
5839+
Generation `0` indicates that keys existed prior to the implementation of key tracking.
5840+
format: int32
5841+
type: integer
5842+
type: object
5843+
type: object
58185844
conditions:
58195845
items:
58205846
description: Condition represents a status condition on any Rook-Ceph Custom Resource.

deploy/examples/crds.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5813,6 +5813,32 @@ spec:
58135813
type: object
58145814
type: object
58155815
type: object
5816+
cephx:
5817+
description: ClusterCephxStatus defines the cephx key rotation status of various daemons on the cephCluster resource
5818+
properties:
5819+
rbdMirrorPeer:
5820+
description: RBDMirrorPeer show the cephx key rotation status of the `rbd-mirror-peer` user
5821+
properties:
5822+
keyCephVersion:
5823+
description: |-
5824+
KeyCephVersion reports the Ceph version that created the current generation's keys. This is
5825+
same string format as reported by `CephCluster.status.version.version` to allow them to be
5826+
compared. E.g., `20.2.0-0`.
5827+
For all newly-created resources, this field set to the version of Ceph that created the key.
5828+
The special value "Uninitialized" indicates that keys are being created for the first time.
5829+
An empty string indicates that the version is unknown, as expected in brownfield deployments.
5830+
type: string
5831+
keyGeneration:
5832+
description: |-
5833+
KeyGeneration represents the CephX key generation for the last successful reconcile.
5834+
For all newly-created resources, this field is set to `1`.
5835+
When keys are rotated due to any rotation policy, the generation is incremented or updated to
5836+
the configured policy generation.
5837+
Generation `0` indicates that keys existed prior to the implementation of key tracking.
5838+
format: int32
5839+
type: integer
5840+
type: object
5841+
type: object
58165842
conditions:
58175843
items:
58185844
description: Condition represents a status condition on any Rook-Ceph Custom Resource.

pkg/apis/ceph.rook.io/v1/types.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,14 @@ type CephExporterSpec struct {
490490

491491
// ClusterStatus represents the status of a Ceph cluster
492492
type ClusterStatus struct {
493-
State ClusterState `json:"state,omitempty"`
494-
Phase ConditionType `json:"phase,omitempty"`
495-
Message string `json:"message,omitempty"`
496-
Conditions []Condition `json:"conditions,omitempty"`
497-
CephStatus *CephStatus `json:"ceph,omitempty"`
498-
CephStorage *CephStorage `json:"storage,omitempty"`
499-
CephVersion *ClusterVersion `json:"version,omitempty"`
493+
State ClusterState `json:"state,omitempty"`
494+
Phase ConditionType `json:"phase,omitempty"`
495+
Message string `json:"message,omitempty"`
496+
Conditions []Condition `json:"conditions,omitempty"`
497+
CephStatus *CephStatus `json:"ceph,omitempty"`
498+
Cephx *ClusterCephxStatus `json:"cephx,omitempty"`
499+
CephStorage *CephStorage `json:"storage,omitempty"`
500+
CephVersion *ClusterVersion `json:"version,omitempty"`
500501
// ObservedGeneration is the latest generation observed by the controller.
501502
// +optional
502503
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
@@ -712,6 +713,12 @@ type LocalCephxStatus struct {
712713
Daemon CephxStatus `json:"daemon,omitempty"`
713714
}
714715

716+
// ClusterCephxStatus defines the cephx key rotation status of various daemons on the cephCluster resource
717+
type ClusterCephxStatus struct {
718+
// RBDMirrorPeer show the cephx key rotation status of the `rbd-mirror-peer` user
719+
RBDMirrorPeer *CephxStatus `json:"rbdMirrorPeer,omitempty"`
720+
}
721+
715722
// MonSpec represents the specification of the monitor
716723
// +kubebuilder:validation:XValidation:message="zones must be less than or equal to count",rule="!has(self.zones) || (has(self.zones) && (size(self.zones) <= self.count))"
717724
// +kubebuilder:validation:XValidation:message="stretchCluster zones must be equal to 3",rule="!has(self.stretchCluster) || (has(self.stretchCluster) && (size(self.stretchCluster.zones) > 0) && (size(self.stretchCluster.zones) == 3))"

pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/operator/ceph/cluster/cluster.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ import (
4040
"github.com/rook/rook/pkg/operator/ceph/cluster/osd"
4141
"github.com/rook/rook/pkg/operator/ceph/cluster/telemetry"
4242
"github.com/rook/rook/pkg/operator/ceph/config"
43+
"github.com/rook/rook/pkg/operator/ceph/config/keyring"
4344
"github.com/rook/rook/pkg/operator/ceph/controller"
4445
"github.com/rook/rook/pkg/operator/ceph/csi"
46+
"github.com/rook/rook/pkg/operator/ceph/reporting"
4547
cephver "github.com/rook/rook/pkg/operator/ceph/version"
4648
"github.com/rook/rook/pkg/operator/k8sutil"
4749
rookversion "github.com/rook/rook/pkg/version"
@@ -791,3 +793,17 @@ func (c *cluster) fetchSecretValue(selector v1.SecretKeySelector) (string, error
791793

792794
return string(val), nil
793795
}
796+
797+
// initClusterCephxStatus set `Uninitialized` state for the cephXstatus for new clusters.
798+
func initClusterCephxStatus(c *clusterd.Context, cluster *cephv1.CephCluster) error {
799+
uninitializedStatus := keyring.UninitializedCephxStatus()
800+
cluster.Status.Cephx = &cephv1.ClusterCephxStatus{
801+
RBDMirrorPeer: &uninitializedStatus,
802+
}
803+
804+
if err := reporting.UpdateStatus(c.Client, cluster); err != nil {
805+
return errors.Wrapf(err, "failed to update cluster cephx status")
806+
}
807+
808+
return nil
809+
}

pkg/operator/ceph/cluster/controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,13 @@ func (c *ClusterController) reconcileCephCluster(clusterObj *cephv1.CephCluster,
384384
return nil
385385
}
386386

387+
if clusterObj.Status.Cephx == nil {
388+
err := initClusterCephxStatus(c.context, clusterObj)
389+
if err != nil {
390+
return errors.Wrap(err, "failed to initialized cluster cephx status")
391+
}
392+
}
393+
387394
cluster, ok := c.clusterMap[clusterObj.Namespace]
388395
if !ok {
389396
// It's a new cluster so let's populate the struct

0 commit comments

Comments
 (0)