Merge pull request #10262 from rook/mergify/bp/release-1.9/pr-10232

rgw: support FQDN for RGW endpoint (backport #10232)
This commit is contained in:
mergify[bot] authored and GitHub committed 2022-05-12 18:30:20 +00:00
commit fd13e4ac39
2 files changed
+26 -6

No files matched your search

@@ -163,7 +163,7 @@ class TestRadosJSON(unittest.TestCase):
self.fail("An Exception was expected to be thrown")
except ext.ExecutionFailureException as err:
print("Successfully thrown error: {}".format(err))
# mal formatted IP
# malformatted IP
try:
self.rjObj._invalid_endpoint("10.103..212.133:8000")
self.fail("An Exception was expected to be thrown")
@@ -179,7 +179,14 @@ class TestRadosJSON(unittest.TestCase):
self.fail("An Exception was expected to be thrown")
except ext.ExecutionFailureException as err:
print("Successfully thrown error: {}".format(err))
def test_convert_fqdn_rgw_endpoint_to_ip(self):
try:
rgw_endpoint_ip = self.rjObj.convert_fqdn_rgw_endpoint_to_ip("www.redhat.com:80")
print("Successfully Converted www.redhat.com to it's IP {}".format(rgw_endpoint_ip))
except ext.ExecutionFailureException as err:
print("Successfully thrown error: {}".format(err))
def test_upgrade_user_permissions(self):
self.rjObj = ext.RadosJSON(
['--upgrade', '--run-as-user=client.csi-cephfs-provisioner', '--format=json'])
@@ -195,9 +195,9 @@ class RadosJSON:
output_group.add_argument("--rbd-data-pool-name", default="", required=False,
help="Provides the name of the RBD datapool")
output_group.add_argument("--rgw-endpoint", default="", required=False,
help="Rados GateWay endpoint (in <IP>:<PORT> format)")
help="RADOS Gateway endpoint (in <IP>:<PORT> format). Note: FQDN is also supported(in <FQDN>:<PORT> format)")
output_group.add_argument("--rgw-tls-cert-path", default="", required=False,
help="Rados GateWay endpoint TLS certificate")
help="RADOS Gateway endpoint TLS certificate")
output_group.add_argument("--rgw-skip-tls", required=False, default=False,
help="Ignore TLS certification validation when a self-signed certificate is provided (NOT RECOMMENDED")
output_group.add_argument("--monitoring-endpoint", default="", required=False,
@@ -795,12 +795,25 @@ class RadosJSON:
jsonoutput = json.loads(output)
return jsonoutput["keys"][0]['access_key'], jsonoutput["keys"][0]['secret_key']
def convert_fqdn_rgw_endpoint_to_ip(self,fqdn_rgw_endpoint):
try:
fqdn, port = fqdn_rgw_endpoint.split(':')
except ValueError:
raise ExecutionFailureException(
"Not a proper endpoint: {}, <FQDN>:<PORT>, format is expected".format(fqdn_rgw_endpoint))
rgw_endpoint_ip = self._convert_hostname_to_ip(fqdn)
rgw_endpoint_port = port
rgw_endpoint = self._join_host_port(
rgw_endpoint_ip, rgw_endpoint_port)
return rgw_endpoint
def validate_pool(self):
pools_to_validate = [self._arg_parser.rbd_data_pool_name]
# if rgw_endpoint is provided, validate it
if self._arg_parser.rgw_endpoint:
self._invalid_endpoint(self._arg_parser.rgw_endpoint)
self.endpoint_dial(self._arg_parser.rgw_endpoint,
rgw_endpoint = self.convert_fqdn_rgw_endpoint_to_ip(self._arg_parser.rgw_endpoint)
self._invalid_endpoint(rgw_endpoint)
self.endpoint_dial(rgw_endpoint,
cert=self.validate_rgw_endpoint_tls_cert())
rgw_pool_to_validate = ["{0}.rgw.meta".format(self._arg_parser.rgw_pool_prefix),
".rgw.root",