This is an automated email from the ASF dual-hosted git repository. yasith pushed a commit to branch worktree-reliability+server-hardening in repository https://gitbox.apache.org/repos/asf/airavata.git
commit e1985f23f94a4e3f5f51220b2aef1cf51d6782be Author: yasithdev <[email protected]> AuthorDate: Mon Mar 30 11:59:21 2026 -0400 refactor: bridge Spring datasource into legacy JDBC config, remove duplicate airavata.jdbc.* properties Spring's datasource is now the single source of truth. SpringSettingsBridge (@PostConstruct) injects spring.datasource.* values into ApplicationSettings overrides so legacy code reading airavata.jdbc.* transparently receives the correct values without any duplicate configuration. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --- .../common/config/ApplicationSettings.java | 12 ++++- .../airavata/common/db/SpringSettingsBridge.java | 55 ++++++++++++++++++++++ .../src/main/resources/airavata-server.properties | 7 --- .../src/test/resources/airavata-server.properties | 11 ----- .../inventories/dev/group_vars/all/vars.yml | 3 -- .../inventories/staging/group_vars/all/vars.yml | 3 -- .../roles/airavata_services/defaults/main.yml | 3 -- .../templates/airavata-server.properties.j2 | 9 ---- .../templates/airavata-server.properties.j2 | 9 ---- .../templates/airavata-server.properties.j2 | 9 ---- .../deployment-scripts/airavata-server.properties | 9 ---- 11 files changed, 66 insertions(+), 64 deletions(-) diff --git a/airavata-api/src/main/java/org/apache/airavata/common/config/ApplicationSettings.java b/airavata-api/src/main/java/org/apache/airavata/common/config/ApplicationSettings.java index 892c5627d7..2cf9d7d20c 100644 --- a/airavata-api/src/main/java/org/apache/airavata/common/config/ApplicationSettings.java +++ b/airavata-api/src/main/java/org/apache/airavata/common/config/ApplicationSettings.java @@ -26,6 +26,7 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Pattern; import org.apache.airavata.common.exception.ApplicationSettingsException; import org.apache.airavata.common.util.StringUtil; @@ -39,6 +40,8 @@ public class ApplicationSettings { public static String ADDITIONAL_SETTINGS_FILES = "external.settings"; + private static final Map<String, String> overrides = new ConcurrentHashMap<>(); + protected Properties properties = new Properties(); private Exception propertyLoadException; @@ -132,7 +135,10 @@ public class ApplicationSettings { public String getSettingImpl(String key) throws ApplicationSettingsException { String rawValue; - if (System.getProperties().containsKey(key)) { + if (overrides.containsKey(key)) { + rawValue = overrides.get(key); + + } else if (System.getProperties().containsKey(key)) { rawValue = System.getProperties().getProperty(key); } else if (System.getenv().containsKey(key)) { @@ -207,6 +213,10 @@ public class ApplicationSettings { return getInstance().getSettingImpl(key, defaultValue); } + public static void setOverride(String key, String value) { + overrides.put(key, value); + } + public static void setSetting(String key, String value) throws ApplicationSettingsException { getInstance().properties.setProperty(key, value); getInstance().saveProperties(); diff --git a/airavata-api/src/main/java/org/apache/airavata/common/db/SpringSettingsBridge.java b/airavata-api/src/main/java/org/apache/airavata/common/db/SpringSettingsBridge.java new file mode 100644 index 0000000000..1c7964ea46 --- /dev/null +++ b/airavata-api/src/main/java/org/apache/airavata/common/db/SpringSettingsBridge.java @@ -0,0 +1,55 @@ +/** +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +package org.apache.airavata.common.db; + +import jakarta.annotation.PostConstruct; +import org.apache.airavata.common.config.ApplicationSettings; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * Bridges Spring datasource configuration into {@link ApplicationSettings} so that legacy code + * reading {@code airavata.jdbc.*} transparently receives the same values as + * {@code spring.datasource.*}. This eliminates the need to duplicate JDBC credentials in + * {@code airavata-server.properties}. + */ +@Component +public class SpringSettingsBridge { + + @Value("${spring.datasource.url}") + private String url; + + @Value("${spring.datasource.username}") + private String username; + + @Value("${spring.datasource.password}") + private String password; + + @Value("${spring.datasource.driver-class-name}") + private String driverClassName; + + @PostConstruct + public void bridge() { + ApplicationSettings.setOverride("airavata.jdbc.url", url); + ApplicationSettings.setOverride("airavata.jdbc.user", username); + ApplicationSettings.setOverride("airavata.jdbc.password", password); + ApplicationSettings.setOverride("airavata.jdbc.driver", driverClassName); + } +} diff --git a/airavata-api/src/main/resources/airavata-server.properties b/airavata-api/src/main/resources/airavata-server.properties index 976f3dc606..5f63fe8f4c 100644 --- a/airavata-api/src/main/resources/airavata-server.properties +++ b/airavata-api/src/main/resources/airavata-server.properties @@ -32,13 +32,6 @@ credential.store.server.port=8930 profile.service.server.host=localhost profile.service.server.port=8930 -# Database Configuration -airavata.jdbc.driver=org.mariadb.jdbc.Driver -airavata.jdbc.url=jdbc:mariadb://localhost:13306/airavata -airavata.jdbc.user=airavata -airavata.jdbc.password=123456 -airavata.jdbc.validationQuery=SELECT 1 - cluster.status.monitoring.enable=false cluster.status.monitoring.repeat.time=18000 diff --git a/airavata-api/src/test/resources/airavata-server.properties b/airavata-api/src/test/resources/airavata-server.properties index 0c00542576..929b73a644 100644 --- a/airavata-api/src/test/resources/airavata-server.properties +++ b/airavata-api/src/test/resources/airavata-server.properties @@ -24,17 +24,6 @@ # ########################################################################### -########################################################################### -# Unified Database Configuration -########################################################################### - -# Unified JDBC configuration for all catalogs -airavata.jdbc.driver=org.mariadb.jdbc.Driver -airavata.jdbc.url=jdbc:mariadb://localhost:3306/airavata -airavata.jdbc.user=airavata -airavata.jdbc.password=airavata -airavata.jdbc.validationQuery=SELECT 1 - # Properties for default user mode default.registry.user=admin default.registry.gateway=php_reference_gateway diff --git a/dev-tools/ansible/inventories/dev/group_vars/all/vars.yml b/dev-tools/ansible/inventories/dev/group_vars/all/vars.yml index ce7dd0d8ed..5e3b1ed174 100644 --- a/dev-tools/ansible/inventories/dev/group_vars/all/vars.yml +++ b/dev-tools/ansible/inventories/dev/group_vars/all/vars.yml @@ -38,9 +38,6 @@ credential_store: "{{ db_name }}" profile_service: "{{ db_name }}" research_catalog: "{{ db_name }}" -# Database driver (unified) -airavata_jdbc_driver: "org.mariadb.jdbc.Driver" - # Paths local_data_location: "/home/{{ deploy_user }}/temp-storage" file_server_storage_location: "/home/{{ deploy_user }}/temp-storage" diff --git a/dev-tools/ansible/inventories/staging/group_vars/all/vars.yml b/dev-tools/ansible/inventories/staging/group_vars/all/vars.yml index 1f7bf7f748..ff14cc6989 100644 --- a/dev-tools/ansible/inventories/staging/group_vars/all/vars.yml +++ b/dev-tools/ansible/inventories/staging/group_vars/all/vars.yml @@ -38,9 +38,6 @@ credential_store: "{{ db_name }}" profile_service: "{{ db_name }}" research_catalog: "{{ db_name }}" -# Database driver (unified) -airavata_jdbc_driver: "org.mariadb.jdbc.Driver" - # Paths local_data_location: "/home/{{ deploy_user }}/temp-storage" file_server_storage_location: "/home/{{ deploy_user }}/temp-storage" diff --git a/dev-tools/ansible/roles/airavata_services/defaults/main.yml b/dev-tools/ansible/roles/airavata_services/defaults/main.yml index 1aebdffdc3..ef086c7b83 100644 --- a/dev-tools/ansible/roles/airavata_services/defaults/main.yml +++ b/dev-tools/ansible/roles/airavata_services/defaults/main.yml @@ -49,9 +49,6 @@ default_registry_gateway: "default" default_registry_oauth_client_id: "pga" super_tenant_gatewayId: "default" -# JDBC driver (unified) -airavata_jdbc_driver: "org.mariadb.jdbc.Driver" - # Security configuration security_manager_class: "org.apache.airavata.security.service.KeyCloakSecurityManager" TLS_enabled: false diff --git a/dev-tools/ansible/roles/airavata_services/templates/airavata-server.properties.j2 b/dev-tools/ansible/roles/airavata_services/templates/airavata-server.properties.j2 index a53258e31a..ed3eca9750 100644 --- a/dev-tools/ansible/roles/airavata_services/templates/airavata-server.properties.j2 +++ b/dev-tools/ansible/roles/airavata_services/templates/airavata-server.properties.j2 @@ -24,15 +24,6 @@ # ########################################################################### -########################################################################### -# Database Configuration -########################################################################### -airavata.jdbc.driver={{ airavata_jdbc_driver | default('org.mariadb.jdbc.Driver') }} -airavata.jdbc.url={{ airavata_jdbc_url }} -airavata.jdbc.user={{ airavata_jdbc_user }} -airavata.jdbc.password={{ airavata_jdbc_password }} -airavata.jdbc.validationQuery=SELECT 1 - ########################################################################### # Generic Server Configurations ########################################################################### diff --git a/dev-tools/ansible/roles/api-orch/templates/airavata-server.properties.j2 b/dev-tools/ansible/roles/api-orch/templates/airavata-server.properties.j2 index 989558674e..a1d67e847e 100644 --- a/dev-tools/ansible/roles/api-orch/templates/airavata-server.properties.j2 +++ b/dev-tools/ansible/roles/api-orch/templates/airavata-server.properties.j2 @@ -25,15 +25,6 @@ # ########################################################################### -########################################################################### -# Database Configuration -########################################################################### -airavata.jdbc.driver={{ airavata_jdbc_driver | default('org.mariadb.jdbc.Driver') }} -airavata.jdbc.url={{ airavata_jdbc_url }} -airavata.jdbc.user={{ airavata_jdbc_user }} -airavata.jdbc.password={{ airavata_jdbc_password }} -airavata.jdbc.validationQuery=SELECT 1 - enable.sharing={{enable_sharing}} # Properties for default user mode diff --git a/dev-tools/ansible/roles/registry/templates/airavata-server.properties.j2 b/dev-tools/ansible/roles/registry/templates/airavata-server.properties.j2 index 3ddefd25fd..64dab9aed2 100644 --- a/dev-tools/ansible/roles/registry/templates/airavata-server.properties.j2 +++ b/dev-tools/ansible/roles/registry/templates/airavata-server.properties.j2 @@ -25,15 +25,6 @@ # ########################################################################### -########################################################################### -# Database Configuration -########################################################################### -airavata.jdbc.driver={{ airavata_jdbc_driver | default('org.mariadb.jdbc.Driver') }} -airavata.jdbc.url={{ airavata_jdbc_url }} -airavata.jdbc.user={{ airavata_jdbc_user }} -airavata.jdbc.password={{ airavata_jdbc_password }} -airavata.jdbc.validationQuery=SELECT 1 - enable.sharing={{enable_sharing}} # Properties for default user mode diff --git a/dev-tools/deployment-scripts/airavata-server.properties b/dev-tools/deployment-scripts/airavata-server.properties index ef74232812..ca18ec5273 100644 --- a/dev-tools/deployment-scripts/airavata-server.properties +++ b/dev-tools/deployment-scripts/airavata-server.properties @@ -22,15 +22,6 @@ # This file provides working defaults for Docker development environment ############################ -############################ -# Database Configuration -############################ -airavata.jdbc.driver=org.mariadb.jdbc.Driver -airavata.jdbc.url=jdbc:mariadb://mysql:3306/airavata -airavata.jdbc.user=airavata -airavata.jdbc.password=123456 -airavata.jdbc.validationQuery=SELECT 1 - ############################ # AMQP (RabbitMQ) Configuration ############################
