From 05cba7318264691cbfec492fa26f8045aa340752 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 13 Mar 2024 15:27:04 -0700 Subject: [PATCH] RANGER-4747: Add exception handling in docker based service creation (#300) RANGER-4747: added exception handling in service creation during docker setup Co-authored-by: abhishek-kumar --- .../scripts/create-ranger-services.py | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/dev-support/ranger-docker/scripts/create-ranger-services.py b/dev-support/ranger-docker/scripts/create-ranger-services.py index 07ca40bb3e..057b067dc9 100644 --- a/dev-support/ranger-docker/scripts/create-ranger-services.py +++ b/dev-support/ranger-docker/scripts/create-ranger-services.py @@ -58,27 +58,12 @@ def service_not_exists(service): 'jdbc.url': 'jdbc:trino://ranger-trino:8080', }}) -if service_not_exists(hdfs): - ranger_client.create_service(hdfs) - print('HDFS service created!') -if service_not_exists(yarn): - ranger_client.create_service(yarn) - print('Yarn service created!') -if service_not_exists(hive): - ranger_client.create_service(hive) - print('Hive service created!') -if service_not_exists(hbase): - ranger_client.create_service(hbase) - print('HBase service created!') -if service_not_exists(kafka): - ranger_client.create_service(kafka) - print('Kafka service created!') -if service_not_exists(knox): - ranger_client.create_service(knox) - print('Knox service created!') -if service_not_exists(kms): - ranger_client.create_service(kms) - print('KMS service created!') -if service_not_exists(trino): - ranger_client.create_service(trino) - print('Trino service created!') +services = [hdfs, yarn, hive, hbase, kafka, knox, kms, trino] +for service in services: + try: + if service_not_exists(service): + ranger_client.create_service(service) + print(f" {service.name} service created!") + except Exception as e: + print(f"An exception occured: {e}") +