From ab5ee9add8e41c184be291155835d3695875cb74 Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Mon, 23 Feb 2026 11:27:10 +0100 Subject: [PATCH] SDC schema init improvements - reset retry attempts for each normative element group instead of globally increasing counter when importing them - do not fail silently when schema import fails Issue-ID: SDC-4788 Change-Id: I1382189e8653fd36db83f7cd98171210e31f0167 Signed-off-by: Fiete Ostkamp --- .../scripts/importconformance.sh | 28 +++++++++++++++------- .../custom-scripts/import_normatives.sh | 4 ++-- catalog-be/sdc-backend-init/startup.sh | 7 ++++-- .../scripts/sdcBePy/common/normative/main.py | 4 ++-- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/asdctool/sdc-cassandra-init/scripts/importconformance.sh b/asdctool/sdc-cassandra-init/scripts/importconformance.sh index 23d403940e..c0cea65376 100644 --- a/asdctool/sdc-cassandra-init/scripts/importconformance.sh +++ b/asdctool/sdc-cassandra-init/scripts/importconformance.sh @@ -1,20 +1,30 @@ #!/bin/sh -# Set the working directory -working_directory="/home/sdc" +# Accept sdctool base directory as optional first argument, +# defaulting to /home/sdc/sdctool (the path inside the Docker image). +sdctool_base="${1:-/home/sdc/sdctool}" + +# Extract the cl_release version dynamically from the asdctool jar filename +# The jar is named asdctool--jar-with-dependencies.jar +version=$(ls "$sdctool_base"/asdctool-*-jar-with-dependencies.jar 2>/dev/null \ + | sed 's|.*/asdctool-||;s|-jar-with-dependencies.jar||' \ + | head -1) + +if [ -z "$version" ]; then + echo "ERROR: Could not determine SDC version from asdctool jar in $sdctool_base" >&2 + exit 1 +fi -# Extract the cl_release version -version="1.14.5" cl_release=$(echo $version | cut -d. -f1-3 | cut -d- -f1) -echo -e "\033[33mcl_release=[$cl_release]\033[0m" +printf "\033[33mcl_release=[$cl_release]\033[0m\n" # Execute the import-Conformance command -conf_dir="/home/sdc/sdctool/config" -tosca_dir="/home/sdc/sdctool/tosca" +conf_dir="$sdctool_base/config" +tosca_dir="$sdctool_base/tosca" cl_version=$(grep 'toscaConformanceLevel:' $conf_dir/configuration.yaml | awk '{print $2}') -cd /home/sdc/sdctool/scripts +cd "$sdctool_base/scripts" chmod +x sdcSchemaFileImport.sh -echo "execute /home/sdc/sdctool/scripts/sdcSchemaFileImport.sh ${tosca_dir} ${cl_release} ${cl_version} ${conf_dir} onap" +echo "execute $sdctool_base/scripts/sdcSchemaFileImport.sh ${tosca_dir} ${cl_release} ${cl_version} ${conf_dir} onap" ./sdcSchemaFileImport.sh ${tosca_dir} ${cl_release} ${cl_version} ${conf_dir} onap diff --git a/catalog-be/sdc-backend-init/custom-scripts/import_normatives.sh b/catalog-be/sdc-backend-init/custom-scripts/import_normatives.sh index e21e1b01b0..12da11d64d 100644 --- a/catalog-be/sdc-backend-init/custom-scripts/import_normatives.sh +++ b/catalog-be/sdc-backend-init/custom-scripts/import_normatives.sh @@ -51,7 +51,7 @@ echo "[$start_time] Starting sdcinit..." # Run sdcinit command with the constructed parameters cd /var/tmp/normatives/import/tosca || exit 1 -sdcinit $param $basic_auth_config $tls_cert $tls_key $tls_key_pw $ca_cert > "/home/onap/logs/init.log" 2>&1 +sdcinit $param $basic_auth_config $tls_cert $tls_key $tls_key_pw $ca_cert end_time=$(date +"%Y-%m-%d %H:%M:%S") echo "[$end_time] Done sdcinit." @@ -61,5 +61,5 @@ end_ts=$(date -d "$end_time" +%s) elapsed=$((end_ts - start_ts)) echo "Elapsed time: $elapsed seconds" -echo "SDC initialization Done. Logs can be found at ${ONAP_LOG}/init.log" +echo "SDC initialization Done." diff --git a/catalog-be/sdc-backend-init/startup.sh b/catalog-be/sdc-backend-init/startup.sh index e35bab3aad..42b88f36e1 100644 --- a/catalog-be/sdc-backend-init/startup.sh +++ b/catalog-be/sdc-backend-init/startup.sh @@ -5,8 +5,11 @@ set -e log_script() { script_name=$1 - sh "$script_name" 2>&1 | sed "s|^|[$script_name] |" || \ - echo "$script_name failed. Continuing with other scripts..." >&2 + echo "Running $script_name..." + sh "$script_name" || { + echo "$script_name failed." >&2 + exit 1 + } } log_script "/home/onap/create_consumer_and_user.sh" diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/main.py b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/main.py index 805f0b0167..d4fc5ad717 100644 --- a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/main.py +++ b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/main.py @@ -12,10 +12,10 @@ colors = BColors() def process_element_list(normative_elements_list, sdc_be_proxy, model=None): - attempt = 0 for normative_element in normative_elements_list: if normative_element is None: continue + attempt = 0 while True: attempt += 1 try: @@ -29,8 +29,8 @@ def process_element_list(normative_elements_list, sdc_be_proxy, model=None): def process_type_list(normative_type_list, sdc_be_proxy, update_version): - attempt = 0 for normative_type in normative_type_list: + attempt = 0 while True: attempt += 1 try: -- 2.16.6