namespace: add name spec in cephBlockPoolRadosNamespace CRD

instead of use metadata name as the backend resource name
we need to add a new name in the spec which can be the
actual backend name

Closes: https://github.com/rook/rook/issues/13220

Signed-off-by: parth-gr <paarora@redhat.com>
This commit is contained in:
parth-gr committed 2023-11-29 22:35:21 +05:30
1 parent a19860bab0
commit 5bf3847b13
6 files changed
+47 -5

No files matched your search

+24
View File
@@ -206,6 +206,18 @@ CephBlockPoolRadosNamespaceSpec
<table>
<tr>
<td>
<code>name</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>The name of the CephBlockPoolRadosNamespaceSpec namespace. If not set, the default is the name of the CR.</p>
</td>
</tr>
<tr>
<td>
<code>blockPoolName</code><br/>
<em>
string
@@ -2972,6 +2984,18 @@ string
<tbody>
<tr>
<td>
<code>name</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>The name of the CephBlockPoolRadosNamespaceSpec namespace. If not set, the default is the name of the CR.</p>
</td>
</tr>
<tr>
<td>
<code>blockPoolName</code><br/>
<em>
string
@@ -36,6 +36,9 @@ spec:
blockPoolName:
description: BlockPoolName is the name of Ceph BlockPool. Typically it's the name of the CephBlockPool CR.
type: string
name:
description: The name of the CephBlockPoolRadosNamespaceSpec namespace. If not set, the default is the name of the CR.
type: string
required:
- blockPoolName
type: object
+3
View File
@@ -39,6 +39,9 @@ spec:
blockPoolName:
description: BlockPoolName is the name of Ceph BlockPool. Typically it's the name of the CephBlockPool CR.
type: string
name:
description: The name of the CephBlockPoolRadosNamespaceSpec namespace. If not set, the default is the name of the CR.
type: string
required:
- blockPoolName
type: object
+2
View File
@@ -5,5 +5,7 @@ metadata:
name: namespace-a
namespace: rook-ceph # namespace:cluster
spec:
# The name of the RADOS namespace. If not set, the default is the name of the CR.
# name: namespace-a
# blockPoolName is the name of the CephBlockPool CR where the namespace will be created.
blockPoolName: replicapool
+3
View File
@@ -2960,6 +2960,9 @@ type CephBlockPoolRadosNamespaceList struct {
// CephBlockPoolRadosNamespaceSpec represents the specification of a CephBlockPool Rados Namespace
type CephBlockPoolRadosNamespaceSpec struct {
// The name of the CephBlockPoolRadosNamespaceSpec namespace. If not set, the default is the name of the CR.
// +optional
Name string `json:"name,omitempty"`
// BlockPoolName is the name of Ceph BlockPool. Typically it's the name of
// the CephBlockPool CR.
BlockPoolName string `json:"blockPoolName"`
@@ -253,6 +253,13 @@ func (r *ReconcileCephBlockPoolRadosNamespace) reconcile(request reconcile.Reque
return reconcile.Result{}, nil
}
func getRadosNamespaceName(cephBlockPoolRadosNamespace *cephv1.CephBlockPoolRadosNamespace) string {
if cephBlockPoolRadosNamespace.Spec.Name != "" {
return cephBlockPoolRadosNamespace.Spec.Name
}
return cephBlockPoolRadosNamespace.Name
}
func (r *ReconcileCephBlockPoolRadosNamespace) updateClusterConfig(cephBlockPoolRadosNamespace *cephv1.CephBlockPoolRadosNamespace, cephCluster cephv1.CephCluster) error {
// Update CSI config map
// If the mon endpoints change, the mon health check go routine will take care of updating the
@@ -261,9 +268,9 @@ func (r *ReconcileCephBlockPoolRadosNamespace) updateClusterConfig(cephBlockPool
Namespace: r.clusterInfo.Namespace,
Monitors: csi.MonEndpoints(r.clusterInfo.Monitors, cephCluster.Spec.RequireMsgr2()),
RBD: &csi.CsiRBDSpec{
RadosNamespace: cephBlockPoolRadosNamespace.Name,
RadosNamespace: getRadosNamespaceName(cephBlockPoolRadosNamespace),
},
RadosNamespace: cephBlockPoolRadosNamespace.Name,
RadosNamespace: getRadosNamespaceName(cephBlockPoolRadosNamespace),
CephFS: &csi.CsiCephFSSpec{
KernelMountOptions: r.clusterInfo.CSIDriverSpec.CephFS.KernelMountOptions,
FuseMountOptions: r.clusterInfo.CSIDriverSpec.CephFS.FuseMountOptions,
@@ -294,7 +301,7 @@ func (r *ReconcileCephBlockPoolRadosNamespace) createOrUpdateRadosNamespace(ceph
namespacedName := fmt.Sprintf("%s/%s", cephBlockPoolRadosNamespace.Namespace, cephBlockPoolRadosNamespace.Name)
logger.Infof("creating ceph blockpool rados namespace %q", namespacedName)
err := cephclient.CreateRadosNamespace(r.context, r.clusterInfo, cephBlockPoolRadosNamespace.Spec.BlockPoolName, cephBlockPoolRadosNamespace.Name)
err := cephclient.CreateRadosNamespace(r.context, r.clusterInfo, cephBlockPoolRadosNamespace.Spec.BlockPoolName, getRadosNamespaceName(cephBlockPoolRadosNamespace))
if err != nil {
return errors.Wrapf(err, "failed to create ceph blockpool rados namespace %q", cephBlockPoolRadosNamespace.Name)
}
@@ -307,7 +314,7 @@ func (r *ReconcileCephBlockPoolRadosNamespace) deleteRadosNamespace(cephBlockPoo
namespacedName := fmt.Sprintf("%s/%s", cephBlockPoolRadosNamespace.Namespace, cephBlockPoolRadosNamespace.Name)
logger.Infof("deleting ceph blockpool rados namespace object %q", namespacedName)
if err := cephclient.DeleteRadosNamespace(r.context, r.clusterInfo, cephBlockPoolRadosNamespace.Spec.BlockPoolName, cephBlockPoolRadosNamespace.Name); err != nil {
if err := cephclient.DeleteRadosNamespace(r.context, r.clusterInfo, cephBlockPoolRadosNamespace.Spec.BlockPoolName, getRadosNamespaceName(cephBlockPoolRadosNamespace)); err != nil {
return errors.Wrapf(err, "failed to delete ceph blockpool rados namespace %q", cephBlockPoolRadosNamespace.Name)
}
@@ -340,6 +347,6 @@ func (r *ReconcileCephBlockPoolRadosNamespace) updateStatus(client client.Client
}
func buildClusterID(cephBlockPoolRadosNamespace *cephv1.CephBlockPoolRadosNamespace) string {
clusterID := fmt.Sprintf("%s-%s-block-%s", cephBlockPoolRadosNamespace.Namespace, cephBlockPoolRadosNamespace.Spec.BlockPoolName, cephBlockPoolRadosNamespace.Name)
clusterID := fmt.Sprintf("%s-%s-block-%s", cephBlockPoolRadosNamespace.Namespace, cephBlockPoolRadosNamespace.Spec.BlockPoolName, getRadosNamespaceName(cephBlockPoolRadosNamespace))
return k8sutil.Hash(clusterID)
}