From 44c44d637ec7dd0c3991210a82df8dd39ea42e46 Mon Sep 17 00:00:00 2001 From: parth-gr Date: Mon, 10 Apr 2023 21:00:35 +0530 Subject: [PATCH] external: add alias rbd pool name to support . pools name if restricted permission was on the . was appended to k8s secret and failed to create the secret so added a alias name is user wan't to suuport pool with . in name Signed-off-by: parth-gr (cherry picked from commit 6c3dabcf5fe9fc131a736072da725727b9108914) --- .../CRDs/Cluster/external-cluster.md | 1 + .../create-external-cluster-resources.py | 44 ++++++++++++++++--- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/Documentation/CRDs/Cluster/external-cluster.md b/Documentation/CRDs/Cluster/external-cluster.md index 4532771e5..4c2ed4d41 100644 --- a/Documentation/CRDs/Cluster/external-cluster.md +++ b/Documentation/CRDs/Cluster/external-cluster.md @@ -39,6 +39,7 @@ python3 create-external-cluster-resources.py --rbd-data-pool-name -- - `--namespace`: Namespace where CephCluster will run, for example `rook-ceph-external` - `--format bash`: The format of the output - `--rbd-data-pool-name`: The name of the RBD data pool +- `--alias-rbd-data-pool-name`: Provides an alias for the RBD data pool name, necessary if a special character is present in the pool name such as a period or underscore - `--rgw-endpoint`: (optional) The RADOS Gateway endpoint in the format `:` - `--rgw-pool-prefix`: (optional) The prefix of the RGW pools. If not specified, the default prefix is `default` - `--rgw-tls-cert-path`: (optional) RADOS Gateway endpoint TLS certificate file path diff --git a/deploy/examples/create-external-cluster-resources.py b/deploy/examples/create-external-cluster-resources.py index 39472cd8f..730fd5072 100644 --- a/deploy/examples/create-external-cluster-resources.py +++ b/deploy/examples/create-external-cluster-resources.py @@ -369,6 +369,12 @@ class RadosJSON: required=False, help="Provides the name of the RBD datapool", ) + output_group.add_argument( + "--alias-rbd-data-pool-name", + default="", + required=False, + help="Provides an alias for the RBD data pool name, necessary if a special character is present in the pool name such as a period or underscore", + ) output_group.add_argument( "--rgw-endpoint", default="", @@ -816,6 +822,30 @@ class RadosJSON: return caps, entity + def get_entity(self, entity, rbd_pool_name, alias_rbd_pool_name, cluster_name): + if ( + rbd_pool_name.count(".") != 0 + or rbd_pool_name.count("_") != 0 + or alias_rbd_pool_name != "" + # checking alias_rbd_pool_name is not empty as there maybe a special character used other than . or _ + ): + if alias_rbd_pool_name == "": + raise ExecutionFailureException( + "please set the '--alias-rbd-data-pool-name' flag as the rbd data pool name contains '.' or '_'" + ) + if ( + alias_rbd_pool_name.count(".") != 0 + or alias_rbd_pool_name.count("_") != 0 + ): + raise ExecutionFailureException( + "'--alias-rbd-data-pool-name' flag value should not contain '.' or '_'" + ) + entity = f"{entity}-{cluster_name}-{alias_rbd_pool_name}" + else: + entity = f"{entity}-{cluster_name}-{rbd_pool_name}" + + return entity + def get_rbd_provisioner_caps_and_entity(self): entity = "client.csi-rbd-provisioner" caps = { @@ -825,12 +855,15 @@ class RadosJSON: } if self._arg_parser.restricted_auth_permission: rbd_pool_name = self._arg_parser.rbd_data_pool_name + alias_rbd_pool_name = self._arg_parser.alias_rbd_data_pool_name cluster_name = self._arg_parser.cluster_name if rbd_pool_name == "" or cluster_name == "": raise ExecutionFailureException( "mandatory flags not found, please set the '--rbd-data-pool-name', '--cluster-name' flags" ) - entity = f"{entity}-{cluster_name}-{rbd_pool_name}" + entity = self.get_entity( + entity, rbd_pool_name, alias_rbd_pool_name, cluster_name + ) caps["osd"] = f"profile rbd pool={rbd_pool_name}" return caps, entity @@ -843,12 +876,11 @@ class RadosJSON: } if self._arg_parser.restricted_auth_permission: rbd_pool_name = self._arg_parser.rbd_data_pool_name + alias_rbd_pool_name = self._arg_parser.alias_rbd_data_pool_name cluster_name = self._arg_parser.cluster_name - if rbd_pool_name == "" or cluster_name == "": - raise ExecutionFailureException( - "mandatory flags not found, please set the '--rbd-data-pool-name', '--cluster-name' flags" - ) - entity = f"{entity}-{cluster_name}-{rbd_pool_name}" + entity = self.get_entity( + entity, rbd_pool_name, alias_rbd_pool_name, cluster_name + ) caps["osd"] = f"profile rbd pool={rbd_pool_name}" return caps, entity