Skip to content

Commit 17b98da

Browse files
csi: add 'CSIMetadataRadosNamespace' parameter to CephFilesystemSubVolumeGroup
This parameter is written to .spec.cephFS.radosNamespace of the generated ClientProfile. The parameter is called 'CSIMetadataRadosNamespace' to clarify that it is used for CSI metadata and unrelated to the actual CephFS (meta)data. Context: The ceph-csi CephFS plugin stores additional metadata related to PV(C)s in RADOS objects in the metadata pool of the CephFS. By default those objects are stored in the 'csi' RADOS namespace. For a multi-tenant CephFS setup (that is used by multiple K8s Clusters/ ceph-csi drivers) segregating those additional objects into separate RADOS namespaces is desireable so the clusters can not modify the metadata of other clusters (enforced by appropriate ceph client capabilities). 'ceph-csi' implemented this via the `cephFS.radosNamespace` config option for cluster entries in the `ceph-csi-config` ConfigMap with ceph/ceph-csi#4661. The `ceph-csi-operator` added support for that config entry by adding 'radosNamespace' to the 'CephFsConfigSpec' of the 'ClientProfile' with ceph/ceph-csi-operator#165. Signed-off-by: Alexander Degenhart <degenhart@fim.uni-passau.de>
1 parent 7ba58b6 commit 17b98da

7 files changed

Lines changed: 62 additions & 6 deletions

File tree

Documentation/CRDs/specification.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,19 @@ It must be unique among all Ceph clusters managed by Rook.
15751575
If not specified, the clusterID will be generated and can be found in the CR status.</p>
15761576
</td>
15771577
</tr>
1578+
<tr>
1579+
<td>
1580+
<code>csiMetadataRadosNamespace</code><br/>
1581+
<em>
1582+
string
1583+
</em>
1584+
</td>
1585+
<td>
1586+
<em>(Optional)</em>
1587+
<p>The RADOS namespace ceph-csi uses for additional metadata it stores in the metadata pool of the CephFS.
1588+
If not specified the default of the ceph-csi driver is used.</p>
1589+
</td>
1590+
</tr>
15781591
</table>
15791592
</td>
15801593
</tr>
@@ -4318,6 +4331,19 @@ It must be unique among all Ceph clusters managed by Rook.
43184331
If not specified, the clusterID will be generated and can be found in the CR status.</p>
43194332
</td>
43204333
</tr>
4334+
<tr>
4335+
<td>
4336+
<code>csiMetadataRadosNamespace</code><br/>
4337+
<em>
4338+
string
4339+
</em>
4340+
</td>
4341+
<td>
4342+
<em>(Optional)</em>
4343+
<p>The RADOS namespace ceph-csi uses for additional metadata it stores in the metadata pool of the CephFS.
4344+
If not specified the default of the ceph-csi driver is used.</p>
4345+
</td>
4346+
</tr>
43214347
</tbody>
43224348
</table>
43234349
<h3 id="ceph.rook.io/v1.CephFilesystemSubVolumeGroupSpecPinning">CephFilesystemSubVolumeGroupSpecPinning

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9367,6 +9367,16 @@ spec:
93679367
x-kubernetes-validations:
93689368
- message: ClusterID is immutable
93699369
rule: self == oldSelf
9370+
csiMetadataRadosNamespace:
9371+
description: |-
9372+
The RADOS namespace ceph-csi uses for additional metadata it stores in the metadata pool of the CephFS.
9373+
If not specified the default of the ceph-csi driver is used.
9374+
maxLength: 1024
9375+
minLength: 1
9376+
type: string
9377+
x-kubernetes-validations:
9378+
- message: CSIMetadataRadosNamespace is immutable
9379+
rule: self == oldSelf
93709380
dataPoolName:
93719381
description: The data pool name for the Ceph Filesystem subvolume group layout, if the default CephFS pool is not desired.
93729382
type: string

deploy/examples/crds.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9361,6 +9361,16 @@ spec:
93619361
x-kubernetes-validations:
93629362
- message: ClusterID is immutable
93639363
rule: self == oldSelf
9364+
csiMetadataRadosNamespace:
9365+
description: |-
9366+
The RADOS namespace ceph-csi uses for additional metadata it stores in the metadata pool of the CephFS.
9367+
If not specified the default of the ceph-csi driver is used.
9368+
maxLength: 1024
9369+
minLength: 1
9370+
type: string
9371+
x-kubernetes-validations:
9372+
- message: CSIMetadataRadosNamespace is immutable
9373+
rule: self == oldSelf
93649374
dataPoolName:
93659375
description: The data pool name for the Ceph Filesystem subvolume group layout, if the default CephFS pool is not desired.
93669376
type: string

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,6 +3885,13 @@ type CephFilesystemSubVolumeGroupSpec struct {
38853885
// +kubebuilder:validation:MaxLength=36
38863886
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
38873887
ClusterID string `json:"clusterID,omitempty"`
3888+
// The RADOS namespace ceph-csi uses for additional metadata it stores in the metadata pool of the CephFS.
3889+
// If not specified the default of the ceph-csi driver is used.
3890+
// +optional
3891+
// +kubebuilder:validation:XValidation:message="CSIMetadataRadosNamespace is immutable",rule="self == oldSelf"
3892+
// +kubebuilder:validation:MinLength=1
3893+
// +kubebuilder:validation:MaxLength=1024
3894+
CSIMetadataRadosNamespace string `json:"csiMetadataRadosNamespace,omitempty"`
38883895
}
38893896

38903897
// CephFilesystemSubVolumeGroupSpecPinning represents the pinning configuration of SubVolumeGroup

pkg/operator/ceph/csi/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ func CreateUpdateClientProfileRadosNamespace(ctx context.Context, c client.Clien
5858
return createUpdateClientProfile(c, clusterInfo, csiOpClientProfile)
5959
}
6060

61-
func CreateUpdateClientProfileSubVolumeGroup(ctx context.Context, c client.Client, clusterInfo *cephclient.ClusterInfo, cephFilesystemSubVolumeGroupName, clusterID string) error {
61+
func CreateUpdateClientProfileSubVolumeGroup(ctx context.Context, c client.Client, clusterInfo *cephclient.ClusterInfo, cephFilesystemSubVolumeGroupName, clusterID string, csiMetadataRadosNamespace string) error {
6262
logger.Info("Creating ceph-csi clientProfile CR for subvolume group")
6363

64-
csiOpClientProfile := generateProfileSubVolumeGroupSpec(clusterInfo, cephFilesystemSubVolumeGroupName, clusterID)
64+
csiOpClientProfile := generateProfileSubVolumeGroupSpec(clusterInfo, cephFilesystemSubVolumeGroupName, clusterID, csiMetadataRadosNamespace)
6565

6666
return createUpdateClientProfile(c, clusterInfo, csiOpClientProfile)
6767
}
6868

69-
func generateProfileSubVolumeGroupSpec(clusterInfo *cephclient.ClusterInfo, cephFilesystemSubVolumeGroupName, clusterID string) *csiopv1.ClientProfile {
69+
func generateProfileSubVolumeGroupSpec(clusterInfo *cephclient.ClusterInfo, cephFilesystemSubVolumeGroupName, clusterID string, csiMetadataRadosNamespace string) *csiopv1.ClientProfile {
7070
csiOpClientProfile := &csiopv1.ClientProfile{}
7171
csiOpClientProfile.Name = clusterID
7272
csiOpClientProfile.Namespace = os.Getenv(k8sutil.PodNamespaceEnvVar)
@@ -76,6 +76,7 @@ func generateProfileSubVolumeGroupSpec(clusterInfo *cephclient.ClusterInfo, ceph
7676
},
7777
CephFs: &csiopv1.CephFsConfigSpec{
7878
SubVolumeGroup: cephFilesystemSubVolumeGroupName,
79+
RadosNamespace: &csiMetadataRadosNamespace,
7980
CephCsiSecrets: &csiopv1.CephCsiSecretsSpec{
8081
ControllerPublishSecret: v1.SecretReference{
8182
Name: CsiCephFSProvisionerSecret,

pkg/operator/ceph/csi/config_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func TestCreateUpdateClientProfile(t *testing.T) {
5555

5656
cephBlockPoolRadosNamespacedName := types.NamespacedName{Namespace: ns, Name: "cephBlockPoolRadosNames"}
5757
cephSubVolGrpNamespacedName := types.NamespacedName{Namespace: ns, Name: "cephSubVolumeGroupNames"}
58+
cephSubVolGrpRadosNamespaceNamespacedName := types.NamespacedName{Namespace: ns, Name: "radosNamespaceName"}
5859
csiOpClientProfile := &csiopv1.ClientProfile{}
5960

6061
// Register operator types with the runtime scheme.
@@ -69,7 +70,7 @@ func TestCreateUpdateClientProfile(t *testing.T) {
6970
err := CreateUpdateClientProfileRadosNamespace(context.TODO(), cl, c, cephBlockPoolRadosNamespacedName.Name, cephBlockPoolRadosNamespacedName.Name)
7071
assert.NoError(t, err)
7172

72-
err = CreateUpdateClientProfileSubVolumeGroup(context.TODO(), cl, c, cephSubVolGrpNamespacedName.Name, cephSubVolGrpNamespacedName.Name)
73+
err = CreateUpdateClientProfileSubVolumeGroup(context.TODO(), cl, c, cephSubVolGrpNamespacedName.Name, cephSubVolGrpNamespacedName.Name, cephSubVolGrpRadosNamespaceNamespacedName.Name)
7374
assert.NoError(t, err)
7475

7576
err = cl.Get(context.TODO(), cephBlockPoolRadosNamespacedName, csiOpClientProfile)
@@ -80,6 +81,7 @@ func TestCreateUpdateClientProfile(t *testing.T) {
8081
assert.NoError(t, err)
8182
assert.Equal(t, csiOpClientProfile.Spec.CephFs.SubVolumeGroup, cephSubVolGrpNamespacedName.Name)
8283
assert.Equal(t, csiOpClientProfile.Spec.CephFs.KernelMountOptions["ms_mode"], kernelMountKeyVal[1])
84+
assert.Equal(t, *csiOpClientProfile.Spec.CephFs.RadosNamespace, cephSubVolGrpRadosNamespaceNamespacedName.Name)
8385
}
8486

8587
func TestParseMountOptions(t *testing.T) {

pkg/operator/ceph/file/subvolumegroup/controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func (r *ReconcileCephFilesystemSubVolumeGroup) reconcile(request reconcile.Requ
281281
}
282282
r.updateStatus(observedGeneration, namespacedName, cephv1.ConditionReady)
283283
if csi.EnableCSIOperator() {
284-
err = csi.CreateUpdateClientProfileSubVolumeGroup(r.clusterInfo.Context, r.client, r.clusterInfo, cephFilesystemSubVolumeGroupName, buildClusterID(cephFilesystemSubVolumeGroup))
284+
err = csi.CreateUpdateClientProfileSubVolumeGroup(r.clusterInfo.Context, r.client, r.clusterInfo, cephFilesystemSubVolumeGroupName, buildClusterID(cephFilesystemSubVolumeGroup), cephFilesystemSubVolumeGroup.Spec.CSIMetadataRadosNamespace)
285285
if err != nil {
286286
return reconcile.Result{}, errors.Wrap(err, "failed to create ceph csi-op config CR for subvolume")
287287
}
@@ -334,7 +334,7 @@ func (r *ReconcileCephFilesystemSubVolumeGroup) reconcile(request reconcile.Requ
334334
r.updateStatus(observedGeneration, request.NamespacedName, cephv1.ConditionReady)
335335

336336
if csi.EnableCSIOperator() {
337-
err = csi.CreateUpdateClientProfileSubVolumeGroup(r.clusterInfo.Context, r.client, r.clusterInfo, cephFilesystemSubVolumeGroupName, buildClusterID(cephFilesystemSubVolumeGroup))
337+
err = csi.CreateUpdateClientProfileSubVolumeGroup(r.clusterInfo.Context, r.client, r.clusterInfo, cephFilesystemSubVolumeGroupName, buildClusterID(cephFilesystemSubVolumeGroup), cephFilesystemSubVolumeGroup.Spec.CSIMetadataRadosNamespace)
338338
if err != nil {
339339
return reconcile.Result{}, errors.Wrap(err, "failed to create ceph csi-op config CR for subvolumeGroup")
340340
}

0 commit comments

Comments
 (0)