Merge pull request #12061 from neoaggelos/feat/external

external: do not enforce need for monitoring endpoint
This commit is contained in:
Travis Nielsen
2023-04-12 16:08:54 -06:00
committed by GitHub
4 changed files with 65 additions and 15 deletions
@@ -111,6 +111,11 @@ jobs:
echo "script failed because wrong subvolumegroup name was passed"
fi
- name: dry run test skip monitoring endpoint
run: |
toolbox=$(kubectl get pod -l app=rook-ceph-tools -n rook-ceph -o jsonpath='{.items[*].metadata.name}')
kubectl -n rook-ceph exec $toolbox -- python3 /etc/ceph/create-external-cluster-resources.py --rbd-data-pool-name=replicapool --dry-run --skip-monitoring-endpoint
- name: test of rados namespace
run: |
kubectl create -f deploy/examples/radosnamespace.yaml
@@ -47,6 +47,7 @@ python3 create-external-cluster-resources.py --rbd-data-pool-name <pool_name> --
- `--rbd-metadata-ec-pool-name`: (optional) Provides the name of erasure coded RBD metadata pool, used for creating ECRBDStorageClass.
- `--monitoring-endpoint`: (optional) Ceph Manager prometheus exporter endpoints (comma separated list of <IP> entries of active and standby mgrs)
- `--monitoring-endpoint-port`: (optional) Ceph Manager prometheus exporter port
- `--skip-monitoring-endpoint`: (optional) Skip prometheus exporter endpoints, even if they are available. Useful if the prometheus module is not enabled
- `--ceph-conf`: (optional) Provide a Ceph conf file
- `--cluster-name`: (optional) Ceph cluster name
- `--output`: (optional) Output will be stored into the provided file
@@ -263,3 +263,32 @@ class TestRadosJSON(unittest.TestCase):
self.fail("An exception was expected")
except ext.ExecutionFailureException as err:
print(f"Exception thrown successfully: {err}")
def test_skip_monitoring_endpoint_no_prometheus(self):
cmd_key = '{"format": "json", "prefix": "status"}'
cmd_out = self.rjObj.cluster.cmd_output_map[cmd_key]
cmd_json_out = json.loads(cmd_out)
del cmd_json_out["mgrmap"]["services"]["prometheus"]
self.rjObj.cluster.cmd_output_map[cmd_key] = json.dumps(cmd_json_out)
endpoint, port = self.rjObj.get_active_and_standby_mgrs()
if endpoint != "" or port != "":
self.fail("Expected monitoring endpoint and port to be empty")
self.rjObj.main()
if self.rjObj.out_map["MONITORING_ENDPOINT"] != "":
self.fail("MONITORING_ENDPOINT should be empty")
if self.rjObj.out_map["MONITORING_ENDPOINT_PORT"] != "":
self.fail("MONITORING_ENDPOINT_PORT should be empty")
def test_skip_monitoring_endpoint(self):
self.rjObj._arg_parser.skip_monitoring_endpoint = True
self.rjObj.main()
if self.rjObj.out_map["MONITORING_ENDPOINT"] != "":
self.fail("MONITORING_ENDPOINT should be empty")
if self.rjObj.out_map["MONITORING_ENDPOINT_PORT"] != "":
self.fail("MONITORING_ENDPOINT_PORT should be empty")
@@ -405,6 +405,12 @@ class RadosJSON:
required=False,
help="Ceph Manager prometheus exporter port",
)
output_group.add_argument(
"--skip-monitoring-endpoint",
default=False,
action="store_true",
help="Do not check for a monitoring endpoint for the Ceph cluster",
)
output_group.add_argument(
"--rbd-metadata-ec-pool-name",
default="",
@@ -710,9 +716,7 @@ class RadosJSON:
json_out.get("mgrmap", {}).get("services", {}).get("prometheus", "")
)
if not monitoring_endpoint:
raise ExecutionFailureException(
"'prometheus' service not found, is the exporter enabled?.\n"
)
return "", ""
# now check the stand-by mgr-s
standby_arr = json_out.get("mgrmap", {}).get("standbys", [])
for each_standby in standby_arr:
@@ -1388,10 +1392,13 @@ class RadosJSON:
self.out_map["CSI_CEPHFS_PROVISIONER_SECRET_NAME"],
) = self.create_cephCSIKeyring_user("client.csi-cephfs-provisioner")
self.out_map["RGW_TLS_CERT"] = ""
(
self.out_map["MONITORING_ENDPOINT"],
self.out_map["MONITORING_ENDPOINT_PORT"],
) = self.get_active_and_standby_mgrs()
self.out_map["MONITORING_ENDPOINT"] = ""
self.out_map["MONITORING_ENDPOINT_PORT"] = ""
if not self._arg_parser.skip_monitoring_endpoint:
(
self.out_map["MONITORING_ENDPOINT"],
self.out_map["MONITORING_ENDPOINT_PORT"],
) = self.get_active_and_standby_mgrs()
self.out_map["RBD_POOL_NAME"] = self._arg_parser.rbd_data_pool_name
self.out_map[
"RBD_METADATA_EC_POOL_NAME"
@@ -1458,16 +1465,24 @@ class RadosJSON:
"userKey": self.out_map["ROOK_EXTERNAL_USER_SECRET"],
},
},
{
"name": "monitoring-endpoint",
"kind": "CephCluster",
"data": {
"MonitoringEndpoint": self.out_map["MONITORING_ENDPOINT"],
"MonitoringPort": self.out_map["MONITORING_ENDPOINT_PORT"],
},
},
]
# if 'MONITORING_ENDPOINT' exists, then only add 'monitoring-endpoint' to Cluster
if (
self.out_map["MONITORING_ENDPOINT"]
and self.out_map["MONITORING_ENDPOINT_PORT"]
):
json_out.append(
{
"name": "monitoring-endpoint",
"kind": "CephCluster",
"data": {
"MonitoringEndpoint": self.out_map["MONITORING_ENDPOINT"],
"MonitoringPort": self.out_map["MONITORING_ENDPOINT_PORT"],
},
}
)
# if 'CSI_RBD_NODE_SECRET' exists, then only add 'rook-csi-rbd-provisioner' Secret
if (
self.out_map["CSI_RBD_NODE_SECRET"]