From 5f1acdb1414c166f7d52df7d3c0adb230a6483d6 Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Mon, 27 Mar 2023 20:35:46 +0530 Subject: [PATCH] Avoid autosetup failure on connector test failed --- .../manager/TestConnectorServiceManager.java | 6 ++++-- .../service/EDCConnectorWorkFlow.java | 21 ++++++++++++++----- .../resources/flyway/V1__auto-setup-table.sql | 4 ++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/TestConnectorServiceManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/TestConnectorServiceManager.java index 89979a0c..32ff3272 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/TestConnectorServiceManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/TestConnectorServiceManager.java @@ -46,6 +46,8 @@ public Map verifyConnectorTestingThroughTestService(Customer cus .apiKeyHeader(inputData.get("edcApiKey")).apiKeyValue(inputData.get("edcApiKeyValue")) .connectorHost(inputData.get("controlPlaneEndpoint")).build(); + inputData.put("testServiceURL", connectorTestServiceURL); + waitingTime(); ConnectorTestServiceResponse testResult = connectorTestServiceProxy @@ -55,12 +57,12 @@ public Map verifyConnectorTestingThroughTestService(Customer cus inputData.put("connectorTestResult", testResult.getMessage()); - inputData.put("testServiceURL", connectorTestServiceURL); - autoSetupTriggerDetails.setStatus(TriggerStatusEnum.SUCCESS.name()); } catch (Exception ex) { + inputData.put("connectorTestResult", "The automatic test wasn't successfully completed"); + log.error("ConnectorTestService failed retry attempt: : {}", RetrySynchronizationManager.getContext().getRetryCount() + 1); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java b/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java index 38b11c58..892f2f51 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java @@ -29,6 +29,7 @@ import org.eclipse.tractusx.autosetup.constant.AppActions; import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry; +import org.eclipse.tractusx.autosetup.exception.ServiceException; import org.eclipse.tractusx.autosetup.manager.AppDeleteManager; import org.eclipse.tractusx.autosetup.manager.CertificateManager; import org.eclipse.tractusx.autosetup.manager.ConnectorRegistrationManager; @@ -43,9 +44,11 @@ import org.springframework.stereotype.Component; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; @Component @RequiredArgsConstructor +@Slf4j public class EDCConnectorWorkFlow { private final CertificateManager certificateManager; @@ -72,8 +75,12 @@ public Map getWorkFlow(Customer customerDetails, SelectedTools t inputConfiguration.putAll( connectorRegistrationManager.registerConnector(customerDetails, tool, inputConfiguration, triger)); - inputConfiguration.putAll(testConnectorServiceManager.verifyConnectorTestingThroughTestService(customerDetails, - inputConfiguration, triger)); + try { + inputConfiguration.putAll(testConnectorServiceManager + .verifyConnectorTestingThroughTestService(customerDetails, inputConfiguration, triger)); + } catch (ServiceException ex) { + log.warn(ex.getMessage()); + } return inputConfiguration; } @@ -99,9 +106,13 @@ public Map getWorkFlowSeparateCPandDP(Customer customerDetails, edcDataplaneManager.managePackage(customerDetails, workflowAction, tool, inputConfiguration, triger)); inputConfiguration.putAll( connectorRegistrationManager.registerConnector(customerDetails, tool, inputConfiguration, triger)); - - inputConfiguration.putAll(testConnectorServiceManager.verifyConnectorTestingThroughTestService(customerDetails, - inputConfiguration, triger)); + + try { + inputConfiguration.putAll(testConnectorServiceManager + .verifyConnectorTestingThroughTestService(customerDetails, inputConfiguration, triger)); + } catch (ServiceException ex) { + log.warn(ex.getMessage()); + } return inputConfiguration; } diff --git a/src/main/resources/flyway/V1__auto-setup-table.sql b/src/main/resources/flyway/V1__auto-setup-table.sql index 2c26c246..73490e53 100644 --- a/src/main/resources/flyway/V1__auto-setup-table.sql +++ b/src/main/resources/flyway/V1__auto-setup-table.sql @@ -112,7 +112,7 @@ connector.discovery.token-url=$\{sde.connector.discovery.token-url\} connector.discovery.clientId=$\{sde.connector.discovery.clientId\} -connector.discovery.clientSecret=$\{sde.connector.discovery.clientSecret\}', NULL, 'sde-backend/dftbackend', '1.9.0', 'helm.packages', 'v1alpha1', '{"dftpostgresql": {"enabled": true, "auth" : {"secretKeys":{"password":"$\{postgresPassword}"\},"username":"$\{username\}","database":"$\{database\}"}},"ingresses":[{"enabled": true, "hostname":"$\{dnsName\}", "annotations": {}, "className": "nginx", "endpoints":["default"], "tls":{"enabled":true, "secretName":"dftbackend"}, "certManager":{"clusterIssuer":"letsencrypt-prod"}}], "configuration": {"properties": "$\{yamlValues\}"}}', 'PROPERTY'); +connector.discovery.clientSecret=$\{sde.connector.discovery.clientSecret\}', NULL, 'sde-backend/dftbackend', '2.0.0', 'helm.packages', 'v1alpha1', '{"dftpostgresql": {"enabled": true, "primary":{"persistence":{"size" :"1Gi"}},"persistence":{"size" :"1Gi"}, "auth" : {"secretKeys":{"password":"$\{postgresPassword}"\},"username":"$\{username\}","database":"$\{database\}"}},"ingresses":[{"enabled": true, "hostname":"$\{dnsName\}", "annotations": {}, "className": "nginx", "endpoints":["default"], "tls":{"enabled":true, "secretName":"dftbackend"}, "certManager":{"clusterIssuer":"letsencrypt-prod"}}], "configuration": {"properties": "$\{yamlValues\}"}}', 'PROPERTY'); INSERT INTO app_tbl (app_name, context_cluster, context_namespace, expected_input_data, output_data, package_identifier, package_version, plugin_name, plugin_version, required_yaml_configuration, yaml_value_field_type) VALUES('DFT_FRONTEND', 'default', 'kubeapps', 'REACT_APP_API_URL=$\{dftBackEndUrl\} @@ -125,7 +125,7 @@ REACT_APP_CLIENT_ID=$\{dftfrontendkeycloakclientid\} REACT_APP_DEFAULT_COMPANY_BPN=$\{bpnNumber\} -REACT_APP_FILESIZE=268435456', NULL, 'sde-frontend/dftfrontend', '1.9.0', 'helm.packages', 'v1alpha1', '{"ingresses":[{"enabled": true, "hostname":"$\{dnsName\}", "annotations": {}, "className": "nginx", "endpoints":["default"], "tls":{"enabled":true, "secretName":"dftfrontend"}, "certManager":{"clusterIssuer":"letsencrypt-prod"}}], "configuration": {"properties": "$\{yamlValues\}"}}', 'PROPERTY'); +REACT_APP_FILESIZE=268435456', NULL, 'sde-frontend/dftfrontend', '2.0.0', 'helm.packages', 'v1alpha1', '{"ingresses":[{"enabled": true, "hostname":"$\{dnsName\}", "annotations": {}, "className": "nginx", "endpoints":["default"], "tls":{"enabled":true, "secretName":"dftfrontend"}, "certManager":{"clusterIssuer":"letsencrypt-prod"}}], "configuration": {"properties": "$\{yamlValues\}"}}', 'PROPERTY'); INSERT INTO app_tbl (app_name, context_cluster, context_namespace, expected_input_data, output_data, package_identifier, package_version, plugin_name, plugin_version, required_yaml_configuration, yaml_value_field_type) VALUES('EDC_CONTROLPLANE', 'default', 'kubeapps', 'edc.receiver.http.endpoint=$\{dftAddress\}