From 27cc123fc8f1e56ea4b4d2e37264919eee111849 Mon Sep 17 00:00:00 2001 From: Shekhar Saxena Date: Tue, 6 Feb 2024 11:20:15 +0530 Subject: [PATCH 1/9] adding-support-for-default-datasource --- src/main/java/com/autotune/Autotune.java | 8 ++-- ...> DefaultDataSourceNotFoundException.java} | 6 +-- .../kruizeLayer/LayerPresenceQuery.java | 2 +- .../PerformanceProfileValidation.java | 2 +- .../analyzer/utils/ServiceHelpers.java | 2 +- .../datasource/DataSourceCollection.java | 25 +++++++++++ .../datasource/DataSourceOperatorImpl.java | 29 +------------ .../com/autotune/jobs/CreatePartition.java | 6 +-- .../com/autotune/jobs/RetentionPartition.java | 6 +-- .../operator/InitializeDeployment.java | 33 ++++++--------- .../operator/KruizeDeploymentInfo.java | 42 ++++--------------- .../com/autotune/operator/KruizeOperator.java | 10 +++-- .../com/autotune/utils/KruizeConstants.java | 8 ++-- .../autotune/utils/KruizeSupportedTypes.java | 2 +- .../java/com/autotune/utils/TrialHelpers.java | 9 ++-- 15 files changed, 79 insertions(+), 111 deletions(-) rename src/main/java/com/autotune/analyzer/exceptions/{MonitoringAgentNotFoundException.java => DefaultDataSourceNotFoundException.java} (83%) diff --git a/src/main/java/com/autotune/Autotune.java b/src/main/java/com/autotune/Autotune.java index 4cdd1f4f5..ed309a1d2 100644 --- a/src/main/java/com/autotune/Autotune.java +++ b/src/main/java/com/autotune/Autotune.java @@ -16,10 +16,10 @@ package com.autotune; import com.autotune.analyzer.Analyzer; +import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.analyzer.exceptions.K8sTypeNotSupportedException; import com.autotune.analyzer.exceptions.KruizeErrorHandler; -import com.autotune.analyzer.exceptions.MonitoringAgentNotFoundException; -import com.autotune.analyzer.exceptions.MonitoringAgentNotSupportedException; +import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.analyzer.utils.AnalyzerConstants; import com.autotune.database.helper.DBConstants; import com.autotune.database.init.KruizeHibernateUtil; @@ -102,8 +102,8 @@ public static void main(String[] args) { InitializeDeployment.setup_deployment_info(); // Read and execute the DDLs here executeDDLs(); - } catch (Exception | K8sTypeNotSupportedException | MonitoringAgentNotSupportedException | - MonitoringAgentNotFoundException e) { + } catch (Exception | K8sTypeNotSupportedException | + DefaultDataSourceNotFoundException e) { e.printStackTrace(); System.exit(1); } diff --git a/src/main/java/com/autotune/analyzer/exceptions/MonitoringAgentNotFoundException.java b/src/main/java/com/autotune/analyzer/exceptions/DefaultDataSourceNotFoundException.java similarity index 83% rename from src/main/java/com/autotune/analyzer/exceptions/MonitoringAgentNotFoundException.java rename to src/main/java/com/autotune/analyzer/exceptions/DefaultDataSourceNotFoundException.java index 8afee71f3..84d38b9c8 100644 --- a/src/main/java/com/autotune/analyzer/exceptions/MonitoringAgentNotFoundException.java +++ b/src/main/java/com/autotune/analyzer/exceptions/DefaultDataSourceNotFoundException.java @@ -15,12 +15,12 @@ *******************************************************************************/ package com.autotune.analyzer.exceptions; -public class MonitoringAgentNotFoundException extends Throwable +public class DefaultDataSourceNotFoundException extends Throwable { - public MonitoringAgentNotFoundException() { + public DefaultDataSourceNotFoundException() { } - public MonitoringAgentNotFoundException(String message) { + public DefaultDataSourceNotFoundException(String message) { super(message); } } diff --git a/src/main/java/com/autotune/analyzer/kruizeLayer/LayerPresenceQuery.java b/src/main/java/com/autotune/analyzer/kruizeLayer/LayerPresenceQuery.java index b4df72b5e..0be0be514 100644 --- a/src/main/java/com/autotune/analyzer/kruizeLayer/LayerPresenceQuery.java +++ b/src/main/java/com/autotune/analyzer/kruizeLayer/LayerPresenceQuery.java @@ -31,7 +31,7 @@ public LayerPresenceQuery(String datasource, String layerPresenceQuery, String layerPresenceKey) throws MonitoringAgentNotSupportedException { - if (KruizeSupportedTypes.MONITORING_AGENTS_SUPPORTED.contains(datasource)) { + if (KruizeSupportedTypes.DATASOURCES_SUPPORTED.contains(datasource)) { this.dataSource = datasource; } else { throw new MonitoringAgentNotSupportedException(); diff --git a/src/main/java/com/autotune/analyzer/performanceProfiles/PerformanceProfileValidation.java b/src/main/java/com/autotune/analyzer/performanceProfiles/PerformanceProfileValidation.java index 0f99f8890..894f03761 100644 --- a/src/main/java/com/autotune/analyzer/performanceProfiles/PerformanceProfileValidation.java +++ b/src/main/java/com/autotune/analyzer/performanceProfiles/PerformanceProfileValidation.java @@ -144,7 +144,7 @@ private ValidationOutputData validatePerformanceProfileData(PerformanceProfile p String expression = null; for (Metric functionVariable : sloInfo.getFunctionVariables()) { // Check if datasource is supported - if (!KruizeSupportedTypes.MONITORING_AGENTS_SUPPORTED.contains(functionVariable.getDatasource().toLowerCase())) { + if (!KruizeSupportedTypes.DATASOURCES_SUPPORTED.contains(functionVariable.getDatasource().toLowerCase())) { errorString.append(AnalyzerConstants.AutotuneObjectConstants.FUNCTION_VARIABLE) .append(functionVariable.getName()) .append(AnalyzerErrorConstants.AutotuneObjectErrors.DATASOURCE_NOT_SUPPORTED); diff --git a/src/main/java/com/autotune/analyzer/utils/ServiceHelpers.java b/src/main/java/com/autotune/analyzer/utils/ServiceHelpers.java index 1909fb83d..ce9b3c091 100644 --- a/src/main/java/com/autotune/analyzer/utils/ServiceHelpers.java +++ b/src/main/java/com/autotune/analyzer/utils/ServiceHelpers.java @@ -143,7 +143,7 @@ public static void addLayerTunableDetails(JSONArray tunablesArray, KruizeLayer k if (sloClass == null || tunable.sloClassList.contains(sloClass)) { JSONObject tunableJson = new JSONObject(); addTunable(tunableJson, tunable); - String tunableQuery = tunable.getQueries().get(KruizeDeploymentInfo.monitoring_agent); + String tunableQuery = tunable.getQueries().get(KruizeDeploymentInfo.defaultDataSource.getProvider()); String query = AnalyzerConstants.NONE; if (tunableQuery != null && !tunableQuery.isEmpty()) { query = tunableQuery; diff --git a/src/main/java/com/autotune/common/datasource/DataSourceCollection.java b/src/main/java/com/autotune/common/datasource/DataSourceCollection.java index 8d815fd94..44535489e 100644 --- a/src/main/java/com/autotune/common/datasource/DataSourceCollection.java +++ b/src/main/java/com/autotune/common/datasource/DataSourceCollection.java @@ -61,6 +61,31 @@ public HashMap getDataSourcesCollection() { return dataSourceCollection; } + /** + * Returns the object of default dataSource + * @return DataSourceInfo object + */ + public DataSourceInfo getDefaultDataSource() { + return dataSourceCollection.get(KruizeConstants.DataSourceConstants.DEFAULT_DATASOURCE_NAME); + } + + /** + * Set or update the default dataSource + * @param dataSource dataSourceInfo object containing the details of default datasource + */ + public void setDefaultDataSource(DataSourceInfo dataSource) { + if (dataSourceCollection.containsKey(KruizeConstants.DataSourceConstants.DEFAULT_DATASOURCE_NAME)) { + updateDataSource(KruizeConstants.DataSourceConstants.DEFAULT_DATASOURCE_NAME, dataSource); + } else { + if (!dataSource.getName().equalsIgnoreCase(KruizeConstants.DataSourceConstants.DEFAULT_DATASOURCE_NAME)) { + addDataSource(dataSource); + } else { + LOGGER.error(KruizeConstants.DataSourceConstants.DataSourceErrorMsgs.INVALID_DEFAULT_DATASOURCE_NAME); + } + + } + } + /** * Adds datasource to collection * @param datasource DataSourceInfo object containing details of datasource diff --git a/src/main/java/com/autotune/common/datasource/DataSourceOperatorImpl.java b/src/main/java/com/autotune/common/datasource/DataSourceOperatorImpl.java index 536c154b3..45fdd6828 100644 --- a/src/main/java/com/autotune/common/datasource/DataSourceOperatorImpl.java +++ b/src/main/java/com/autotune/common/datasource/DataSourceOperatorImpl.java @@ -1,6 +1,6 @@ package com.autotune.common.datasource; -import com.autotune.analyzer.exceptions.MonitoringAgentNotFoundException; +import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.analyzer.exceptions.TooManyRecursiveCallsException; import com.autotune.analyzer.utils.AnalyzerConstants; import com.autotune.common.datasource.prometheus.PrometheusDataOperatorImpl; @@ -149,33 +149,6 @@ public ArrayList getAppsForLayer(DataSourceInfo dataSource, String query return valuesList; } - /** - * TODO: monitoring agent will be replaced by default datasource later - * returns DataSourceInfo objects for default datasource which is currently monitoring agent - * @return DataSourceInfo objects - */ - public static DataSourceInfo getMonitoringAgent(String dataSource) throws MonitoringAgentNotFoundException, MalformedURLException { - String monitoringAgentEndpoint; - DataSourceInfo monitoringAgent = null; - - if (dataSource.toLowerCase().equals(KruizeDeploymentInfo.monitoring_agent)) { - monitoringAgentEndpoint = KruizeDeploymentInfo.monitoring_agent_endpoint; - // Monitoring agent endpoint not set in the configmap - if (monitoringAgentEndpoint == null || monitoringAgentEndpoint.isEmpty()) { - monitoringAgentEndpoint = getServiceEndpoint(KruizeDeploymentInfo.monitoring_service); - } - if (dataSource.equals(AnalyzerConstants.PROMETHEUS_DATA_SOURCE)) { - monitoringAgent = new DataSourceInfo(KruizeDeploymentInfo.monitoring_agent, AnalyzerConstants.PROMETHEUS_DATA_SOURCE, new URL(monitoringAgentEndpoint)); - } - } - - if (monitoringAgent == null) { - LOGGER.error("Datasource " + dataSource + " not supported"); - } - - return monitoringAgent; - } - /** * TODO: To find a suitable place for this function later * Gets the service endpoint for the datasource service through the cluster IP diff --git a/src/main/java/com/autotune/jobs/CreatePartition.java b/src/main/java/com/autotune/jobs/CreatePartition.java index 347d7d7a3..74389ea90 100644 --- a/src/main/java/com/autotune/jobs/CreatePartition.java +++ b/src/main/java/com/autotune/jobs/CreatePartition.java @@ -1,8 +1,7 @@ package com.autotune.jobs; import com.autotune.analyzer.exceptions.K8sTypeNotSupportedException; -import com.autotune.analyzer.exceptions.MonitoringAgentNotFoundException; -import com.autotune.analyzer.exceptions.MonitoringAgentNotSupportedException; +import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.database.dao.ExperimentDAOImpl; import com.autotune.database.helper.DBConstants; import com.autotune.database.init.KruizeHibernateUtil; @@ -47,8 +46,7 @@ public static void main(String[] args) { timerAddBulkResultsDB.stop(MetricsConfig.timerAddBulkResultsDB); } } - } catch (Exception | K8sTypeNotSupportedException | MonitoringAgentNotSupportedException | - MonitoringAgentNotFoundException e) { + } catch (Exception | K8sTypeNotSupportedException | DefaultDataSourceNotFoundException e) { e.printStackTrace(); System.exit(1); } diff --git a/src/main/java/com/autotune/jobs/RetentionPartition.java b/src/main/java/com/autotune/jobs/RetentionPartition.java index 9edaa110f..53b640b76 100644 --- a/src/main/java/com/autotune/jobs/RetentionPartition.java +++ b/src/main/java/com/autotune/jobs/RetentionPartition.java @@ -1,8 +1,7 @@ package com.autotune.jobs; import com.autotune.analyzer.exceptions.K8sTypeNotSupportedException; -import com.autotune.analyzer.exceptions.MonitoringAgentNotFoundException; -import com.autotune.analyzer.exceptions.MonitoringAgentNotSupportedException; +import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.database.init.KruizeHibernateUtil; import com.autotune.operator.InitializeDeployment; import org.hibernate.Session; @@ -18,8 +17,7 @@ public static void main(String[] args) { LOGGER.info("Checking Liveliness probe DB connection..."); try { InitializeDeployment.setup_deployment_info(); - } catch (Exception | K8sTypeNotSupportedException | MonitoringAgentNotSupportedException | - MonitoringAgentNotFoundException e) { + } catch (Exception | K8sTypeNotSupportedException | DefaultDataSourceNotFoundException e) { e.printStackTrace(); System.exit(1); } diff --git a/src/main/java/com/autotune/operator/InitializeDeployment.java b/src/main/java/com/autotune/operator/InitializeDeployment.java index 15d55dc52..605fc6ef1 100644 --- a/src/main/java/com/autotune/operator/InitializeDeployment.java +++ b/src/main/java/com/autotune/operator/InitializeDeployment.java @@ -15,9 +15,9 @@ *******************************************************************************/ package com.autotune.operator; +import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.analyzer.exceptions.K8sTypeNotSupportedException; -import com.autotune.analyzer.exceptions.MonitoringAgentNotFoundException; -import com.autotune.analyzer.exceptions.MonitoringAgentNotSupportedException; +import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.common.datasource.*; import com.autotune.utils.KruizeConstants; import org.json.JSONObject; @@ -41,36 +41,29 @@ private InitializeDeployment() { } - public static void setup_deployment_info() throws Exception, K8sTypeNotSupportedException, MonitoringAgentNotSupportedException, MonitoringAgentNotFoundException { + public static void setup_deployment_info() throws Exception, K8sTypeNotSupportedException, DefaultDataSourceNotFoundException { setConfigValues(KruizeConstants.CONFIG_FILE, KruizeConstants.KRUIZE_CONFIG_ENV_NAME.class); setConfigValues(KruizeConstants.DBConstants.CONFIG_FILE, KruizeConstants.DATABASE_ENV_NAME.class); + + DataSourceCollection dataSourceCollection = DataSourceCollection.getInstance(); + dataSourceCollection.addDataSourcesFromConfigFile(KruizeConstants.CONFIG_FILE); + KruizeDeploymentInfo.setCluster_type(KruizeDeploymentInfo.cluster_type); KruizeDeploymentInfo.setKubernetesType(KruizeDeploymentInfo.k8s_type); KruizeDeploymentInfo.setAuth_type(KruizeDeploymentInfo.auth_type); - KruizeDeploymentInfo.setMonitoring_agent(KruizeDeploymentInfo.monitoring_agent); - KruizeDeploymentInfo.setMonitoringAgentService(KruizeDeploymentInfo.monitoring_service); - String monitoring_agent_endpoint = KruizeDeploymentInfo.monitoring_agent_endpoint; - String monitoring_agent = KruizeDeploymentInfo.monitoring_agent; - String monitoring_agent_service = KruizeDeploymentInfo.monitoring_service; - //If no endpoint was specified in the configmap - if (monitoring_agent_endpoint == null || monitoring_agent_endpoint.isEmpty()) { - if (monitoring_agent == null || monitoring_agent_service == null) { - throw new MonitoringAgentNotFoundException(); - } else { - // Fetch endpoint from service cluster IP - monitoring_agent_endpoint = DataSourceOperatorImpl.getMonitoringAgent(monitoring_agent).getUrl().toString(); - } + KruizeDeploymentInfo.setDefaultDataSource(); + DataSourceInfo defaultDataSource = KruizeDeploymentInfo.defaultDataSource; + // If no default datasource was specified in the configmap + if (defaultDataSource == null) { + throw new DefaultDataSourceNotFoundException(); } - KruizeDeploymentInfo.setMonitoring_agent_endpoint(monitoring_agent_endpoint); - KruizeDeploymentInfo.setLayerTable(); KruizeDeploymentInfo.initiateEventLogging(); KruizeDeploymentInfo.logDeploymentInfo(); - DataSourceCollection dataSourceCollection = DataSourceCollection.getInstance(); - dataSourceCollection.addDataSourcesFromConfigFile(KruizeConstants.CONFIG_FILE); + LOGGER.info(KruizeConstants.DataSourceConstants.DataSourceInfoMsgs.CHECKING_AVAILABLE_DATASOURCE); HashMap dataSources = dataSourceCollection.getDataSourcesCollection(); diff --git a/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java b/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java index c13cdafba..ca5bdbc38 100644 --- a/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java +++ b/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java @@ -22,6 +22,8 @@ import com.autotune.analyzer.kruizeLayer.layers.GenericLayer; import com.autotune.analyzer.kruizeLayer.layers.HotspotLayer; import com.autotune.analyzer.kruizeLayer.layers.QuarkusLayer; +import com.autotune.common.datasource.DataSourceCollection; +import com.autotune.common.datasource.DataSourceInfo; import com.autotune.utils.KruizeSupportedTypes; import com.autotune.utils.KubeEventLogger; import org.slf4j.Logger; @@ -53,9 +55,7 @@ public class KruizeDeploymentInfo { public static String settings_hibernate_show_sql; public static String settings_hibernate_time_zone; public static String autotune_mode; - public static String monitoring_agent; - public static String monitoring_service; - public static String monitoring_agent_endpoint; + public static DataSourceInfo defaultDataSource; public static String cluster_type; public static String k8s_type; // ABC public static String auth_type; @@ -90,17 +90,6 @@ public static Class getLayer(String layerName) { return tunableLayerPair.get(layerName); } - - public static void setMonitoring_agent_endpoint(String monitoring_agent_endpoint) { - if (monitoring_agent_endpoint.endsWith("/")) { - KruizeDeploymentInfo.monitoring_agent_endpoint = - monitoring_agent_endpoint.substring(0, monitoring_agent_endpoint.length() - 1); - } else { - KruizeDeploymentInfo.monitoring_agent_endpoint = monitoring_agent_endpoint; - } - } - - public static void setCluster_type(String cluster_type) throws ClusterTypeNotSupportedException { if (cluster_type != null) cluster_type = cluster_type.toLowerCase(); @@ -144,33 +133,18 @@ public static void setAuth_type(String auth_type) { } } + public static void setDefaultDataSource() { + KruizeDeploymentInfo.defaultDataSource = DataSourceCollection.getInstance().getDefaultDataSource(); - public static void setMonitoring_agent(String monitoring_agent) throws MonitoringAgentNotSupportedException { - if (monitoring_agent != null) - monitoring_agent = monitoring_agent.toLowerCase(); - - if (KruizeSupportedTypes.MONITORING_AGENTS_SUPPORTED.contains(monitoring_agent)) { - KruizeDeploymentInfo.monitoring_agent = monitoring_agent; - } else { - LOGGER.error("Monitoring agent {} is not supported", monitoring_agent); - throw new MonitoringAgentNotSupportedException(); - } - } - - - public static void setMonitoringAgentService(String monitoringAgentService) { - if (monitoringAgentService != null) - KruizeDeploymentInfo.monitoring_service = monitoringAgentService.toLowerCase(); } public static void logDeploymentInfo() { LOGGER.info("Cluster Type: {}", KruizeDeploymentInfo.cluster_type); LOGGER.info("Kubernetes Type: {}", KruizeDeploymentInfo.k8s_type); LOGGER.info("Auth Type: {}", KruizeDeploymentInfo.auth_type); - LOGGER.info("Monitoring Agent: {}", KruizeDeploymentInfo.monitoring_agent); - LOGGER.info("Monitoring Agent URL: {}", KruizeDeploymentInfo.monitoring_agent_endpoint); - LOGGER.info("Monitoring agent service: {}\n\n", KruizeDeploymentInfo.monitoring_service); + LOGGER.info("Default Datasource: {}", KruizeDeploymentInfo.defaultDataSource.getName()); + LOGGER.info("Default Datasource URL: {}", KruizeDeploymentInfo.defaultDataSource.getUrl()); + LOGGER.info("Default Datasource Provider: {}\n\n", KruizeDeploymentInfo.defaultDataSource.getProvider()); } - } diff --git a/src/main/java/com/autotune/operator/KruizeOperator.java b/src/main/java/com/autotune/operator/KruizeOperator.java index c1a23d26a..8229452d9 100644 --- a/src/main/java/com/autotune/operator/KruizeOperator.java +++ b/src/main/java/com/autotune/operator/KruizeOperator.java @@ -32,6 +32,7 @@ import com.autotune.analyzer.utils.AnalyzerConstants.AutotuneConfigConstants; import com.autotune.analyzer.utils.AnalyzerErrorConstants; import com.autotune.common.data.ValidationOutputData; +import com.autotune.common.datasource.DataSourceCollection; import com.autotune.common.datasource.DataSourceInfo; import com.autotune.common.datasource.DataSourceOperatorImpl; import com.autotune.common.exceptions.DataSourceNotExist; @@ -495,7 +496,7 @@ private static KruizeLayer getAutotuneConfig(String autotuneConfigResource, Cust for (Object query : layerPresenceQueryJson) { JSONObject queryJson = (JSONObject) query; String datasource = queryJson.getString(AnalyzerConstants.AutotuneConfigConstants.DATASOURCE); - if (datasource.equalsIgnoreCase(KruizeDeploymentInfo.monitoring_agent)) { + if (datasource.equalsIgnoreCase(KruizeDeploymentInfo.defaultDataSource.getProvider())) { layerPresenceQueryStr = queryJson.getString(AnalyzerConstants.AutotuneConfigConstants.QUERY); layerPresenceKey = queryJson.getString(AnalyzerConstants.AutotuneConfigConstants.KEY); // Replace the queryvariables in the query @@ -668,8 +669,11 @@ private static void addQueryLayer(KruizeLayer layer, KruizeObject kruizeObject) } DataSourceInfo autotuneDataSource = null; try { - autotuneDataSource = DataSourceOperatorImpl.getMonitoringAgent(KruizeDeploymentInfo.monitoring_agent); - } catch (MonitoringAgentNotFoundException e) { + autotuneDataSource = DataSourceCollection.getInstance().getDefaultDataSource(); + if (autotuneDataSource == null){ + throw new DefaultDataSourceNotFoundException(KruizeConstants.DataSourceConstants.DataSourceErrorMsgs.DEFAULT_DATASOURCE_NOT_FOUND); + } + } catch (DefaultDataSourceNotFoundException e) { e.printStackTrace(); } ArrayList appsForAllQueries = new ArrayList<>(); diff --git a/src/main/java/com/autotune/utils/KruizeConstants.java b/src/main/java/com/autotune/utils/KruizeConstants.java index 4d7b3d7d0..ce135aa4f 100644 --- a/src/main/java/com/autotune/utils/KruizeConstants.java +++ b/src/main/java/com/autotune/utils/KruizeConstants.java @@ -331,6 +331,7 @@ private Memory() { public static class DataSourceConstants { public static final String DATASOURCE_NAME = "name"; + public static final String DEFAULT_DATASOURCE_NAME = "default"; public static final String DATASOURCE_PROVIDER = "provider"; public static final String DATASOURCE_SERVICE_NAME = "serviceName"; public static final String DATASOURCE_SERVICE_NAMESPACE = "namespace"; @@ -374,6 +375,9 @@ private DataSourceErrorMsgs() { public static final String DATASOURCE_NOT_SUPPORTED = "Datasource is not supported: "; public static final String SERVICE_NOT_FOUND = "Can not find service with specified name."; public static final String ENDPOINT_NOT_FOUND = "Service endpoint not found."; + public static final String INVALID_DEFAULT_DATASOURCE_NAME = "Invalid default datasource name."; + public static final String DEFAULT_DATASOURCE_NOT_FOUND = "Default datasource is not set."; + } private DataSourceConstants() { } @@ -461,9 +465,7 @@ public static final class KRUIZE_CONFIG_ENV_NAME { public static final String K8S_TYPE = "k8stype"; public static final String AUTH_TYPE = "authtype"; public static final String AUTH_TOKEN = "authtoken"; - public static final String MONITORING_AGENT = "monitoringagent"; - public static final String MONITORING_SERVICE = "monitoringservice"; - public static final String MONITORING_AGENT_ENDPOINT = "monitoringendpoint"; + public static final String CLUSTER_TYPE = "clustertype"; public static final String AUTOTUNE_MODE = "autotunemode"; public static final String EM_ONLY_MODE = "emonly"; diff --git a/src/main/java/com/autotune/utils/KruizeSupportedTypes.java b/src/main/java/com/autotune/utils/KruizeSupportedTypes.java index 28f3181a3..d4b3f3c93 100644 --- a/src/main/java/com/autotune/utils/KruizeSupportedTypes.java +++ b/src/main/java/com/autotune/utils/KruizeSupportedTypes.java @@ -29,7 +29,7 @@ private KruizeSupportedTypes() { } public static final Set DIRECTIONS_SUPPORTED = new HashSet<>(Arrays.asList("minimize", "maximize")); - public static final Set MONITORING_AGENTS_SUPPORTED = + public static final Set DATASOURCES_SUPPORTED = new HashSet<>(Arrays.asList("prometheus")); public static final Set MODES_SUPPORTED = diff --git a/src/main/java/com/autotune/utils/TrialHelpers.java b/src/main/java/com/autotune/utils/TrialHelpers.java index 5e922a9a0..a390d6b51 100644 --- a/src/main/java/com/autotune/utils/TrialHelpers.java +++ b/src/main/java/com/autotune/utils/TrialHelpers.java @@ -28,6 +28,7 @@ import com.autotune.common.annotations.json.KruizeJSONExclusionStrategy; import com.autotune.common.data.metrics.Metric; import com.autotune.common.data.metrics.MetricResults; +import com.autotune.common.datasource.DataSourceCollection; import com.autotune.common.datasource.DataSourceInfo; import com.autotune.common.trials.*; import com.autotune.experimentManager.exceptions.IncompatibleInputJSONException; @@ -145,9 +146,9 @@ public static ExperimentTrial createDefaultExperimentTrial(int trialNumber, trialNumber, trialResultUrl.toString()); - DataSourceInfo datasourceInfo = new DataSourceInfo(KruizeDeploymentInfo.monitoring_agent, KruizeConstants.SupportedDatasources.PROMETHEUS, new URL(KruizeDeploymentInfo.monitoring_agent_endpoint)); + DataSourceInfo datasourceInfo = KruizeDeploymentInfo.defaultDataSource; HashMap datasourceInfoHashMap = new HashMap<>(); - datasourceInfoHashMap.put(KruizeDeploymentInfo.monitoring_agent, datasourceInfo); //Change key value as per YAML input + datasourceInfoHashMap.put(KruizeConstants.DataSourceConstants.DEFAULT_DATASOURCE_NAME, datasourceInfo); //Change key value as per YAML input DeploymentTracking deploymentTracking = new DeploymentTracking(); DeploymentSettings deploymentSettings = new DeploymentSettings(deploymentPolicy, deploymentTracking); @@ -201,7 +202,7 @@ public static ExperimentTrial createDefaultExperimentTrial(int trialNumber, LOGGER.error("ERROR: tunable is null for tunableName: " + tunableName); } ApplicationServiceStack applicationServiceStack = kruizeExperiment.getApplicationDeployment().getApplicationServiceStackMap().get(tunable.getStackName()); - String tunableQuery = tunable.getQueries().get(KruizeDeploymentInfo.monitoring_agent); + String tunableQuery = tunable.getQueries().get(KruizeDeploymentInfo.defaultDataSource.getProvider()); Class classRef = KruizeDeploymentInfo.getLayer(tunable.getLayerName()); try { Object inst = classRef.getDeclaredConstructor().newInstance(); @@ -220,7 +221,7 @@ public static ExperimentTrial createDefaultExperimentTrial(int trialNumber, if (tunableQuery != null && !tunableQuery.isEmpty()) { Metric queryMetric = new Metric(tunable.getName(), tunableQuery, - KruizeDeploymentInfo.monitoring_agent, + KruizeDeploymentInfo.defaultDataSource.getProvider(), tunable.getValueType(), null); if (containerMetricsHashMap != null && !containerMetricsHashMap.isEmpty() From d9eb5e719a63f48558914f7c9fd234f809f4786d Mon Sep 17 00:00:00 2001 From: Shekhar Saxena Date: Tue, 6 Feb 2024 11:39:29 +0530 Subject: [PATCH 2/9] updating crc manifest to use default datasource --- .../minikube/kruize-crc-minikube.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml b/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml index e56607d5a..e5f1da551 100644 --- a/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml +++ b/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml @@ -123,7 +123,7 @@ data: }, "datasource": [ { - "name": "prometheus-1", + "name": "default", "provider": "prometheus", "serviceName": "prometheus-k8s", "namespace": "monitoring", From 8effc56de3eaf7a98eeec49361a35963b75f2637 Mon Sep 17 00:00:00 2001 From: Shekhar Saxena Date: Tue, 6 Feb 2024 11:40:00 +0530 Subject: [PATCH 3/9] updating crc manifest by removing monitoring agent --- .../minikube/kruize-crc-minikube.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml b/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml index e5f1da551..aaa699f40 100644 --- a/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml +++ b/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml @@ -105,9 +105,6 @@ data: "clustertype": "kubernetes", "k8stype": "minikube", "authtype": "", - "monitoringagent": "prometheus", - "monitoringservice": "prometheus-k8s", - "monitoringendpoint": "prometheus-k8s", "savetodb": "true", "dbdriver": "jdbc:postgresql://", "hibernate": { From 8031140a7cddfcbe37ffede3dbad6d230496a5c9 Mon Sep 17 00:00:00 2001 From: Shekhar Saxena Date: Mon, 19 Feb 2024 17:28:43 +0530 Subject: [PATCH 4/9] removing changes from crc yaml --- .../minikube/kruize-crc-minikube.yaml | 5 ++++- .../common/datasource/DataSourceCollection.java | 17 ----------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml b/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml index aaa699f40..e56607d5a 100644 --- a/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml +++ b/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml @@ -105,6 +105,9 @@ data: "clustertype": "kubernetes", "k8stype": "minikube", "authtype": "", + "monitoringagent": "prometheus", + "monitoringservice": "prometheus-k8s", + "monitoringendpoint": "prometheus-k8s", "savetodb": "true", "dbdriver": "jdbc:postgresql://", "hibernate": { @@ -120,7 +123,7 @@ data: }, "datasource": [ { - "name": "default", + "name": "prometheus-1", "provider": "prometheus", "serviceName": "prometheus-k8s", "namespace": "monitoring", diff --git a/src/main/java/com/autotune/common/datasource/DataSourceCollection.java b/src/main/java/com/autotune/common/datasource/DataSourceCollection.java index 44535489e..9ecbf46e9 100644 --- a/src/main/java/com/autotune/common/datasource/DataSourceCollection.java +++ b/src/main/java/com/autotune/common/datasource/DataSourceCollection.java @@ -69,23 +69,6 @@ public DataSourceInfo getDefaultDataSource() { return dataSourceCollection.get(KruizeConstants.DataSourceConstants.DEFAULT_DATASOURCE_NAME); } - /** - * Set or update the default dataSource - * @param dataSource dataSourceInfo object containing the details of default datasource - */ - public void setDefaultDataSource(DataSourceInfo dataSource) { - if (dataSourceCollection.containsKey(KruizeConstants.DataSourceConstants.DEFAULT_DATASOURCE_NAME)) { - updateDataSource(KruizeConstants.DataSourceConstants.DEFAULT_DATASOURCE_NAME, dataSource); - } else { - if (!dataSource.getName().equalsIgnoreCase(KruizeConstants.DataSourceConstants.DEFAULT_DATASOURCE_NAME)) { - addDataSource(dataSource); - } else { - LOGGER.error(KruizeConstants.DataSourceConstants.DataSourceErrorMsgs.INVALID_DEFAULT_DATASOURCE_NAME); - } - - } - } - /** * Adds datasource to collection * @param datasource DataSourceInfo object containing details of datasource From 5db25f4b3200a6a00378210d8a4ee2e4d6be1a7c Mon Sep 17 00:00:00 2001 From: Shekhar Saxena Date: Mon, 19 Feb 2024 17:33:47 +0530 Subject: [PATCH 5/9] Resolving merge conflicts --- src/main/java/com/autotune/utils/KruizeConstants.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/autotune/utils/KruizeConstants.java b/src/main/java/com/autotune/utils/KruizeConstants.java index ce135aa4f..43b56ac53 100644 --- a/src/main/java/com/autotune/utils/KruizeConstants.java +++ b/src/main/java/com/autotune/utils/KruizeConstants.java @@ -377,6 +377,7 @@ private DataSourceErrorMsgs() { public static final String ENDPOINT_NOT_FOUND = "Service endpoint not found."; public static final String INVALID_DEFAULT_DATASOURCE_NAME = "Invalid default datasource name."; public static final String DEFAULT_DATASOURCE_NOT_FOUND = "Default datasource is not set."; + public static final String MISSING_DATASOURCE_INFO = "Datasource is missing, add a valid Datasource"; } private DataSourceConstants() { From 9ce0e95719fcf9da59f0b82b8a00b71273996b10 Mon Sep 17 00:00:00 2001 From: Shekhar Saxena Date: Mon, 19 Feb 2024 17:57:01 +0530 Subject: [PATCH 6/9] updating datasource in yamls --- .../autotune/configmaps/minikube-config.yaml | 44 +++++++++++++++++++ .../minikube/kruize-crc-minikube.yaml | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/manifests/autotune/configmaps/minikube-config.yaml b/manifests/autotune/configmaps/minikube-config.yaml index 8c5fb9dbd..7a60bd79a 100644 --- a/manifests/autotune/configmaps/minikube-config.yaml +++ b/manifests/autotune/configmaps/minikube-config.yaml @@ -12,5 +12,49 @@ data: monitoring_agent_endpoint: "" root_logging_level: "error" logging_level: "info" + dbconfigjson: | + { + "database": { + "adminPassword": "admin", + "adminUsername": "admin", + "hostname": "postgres-service", + "name": "kruizeDB", + "password": "admin", + "port": 5432, + "sslMode": "require", + "username": "admin" + } + } + kruizeconfigjson: | + { + "clustertype": "kubernetes", + "k8stype": "minikube", + "authtype": "", + "monitoringagent": "prometheus", + "monitoringservice": "prometheus-k8s", + "monitoringendpoint": "prometheus-k8s", + "savetodb": "true", + "dbdriver": "jdbc:postgresql://", + "hibernate": { + "dialect": "org.hibernate.dialect.PostgreSQLDialect", + "driver": "org.postgresql.Driver", + "c3p0minsize": 2, + "c3p0maxsize": 5, + "c3p0timeout": 300, + "c3p0maxstatements": 50, + "hbm2ddlauto": "none", + "showsql": "false", + "timezone": "UTC" + }, + "datasource": [ + { + "name": "default", + "provider": "prometheus", + "serviceName": "prometheus-k8s", + "namespace": "monitoring", + "url": "" + } + ] + } diff --git a/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml b/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml index e56607d5a..e5f1da551 100644 --- a/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml +++ b/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml @@ -123,7 +123,7 @@ data: }, "datasource": [ { - "name": "prometheus-1", + "name": "default", "provider": "prometheus", "serviceName": "prometheus-k8s", "namespace": "monitoring", From 080d8e0fd1f337ca23175bd54f9cae90150a7081 Mon Sep 17 00:00:00 2001 From: Shekhar Saxena Date: Mon, 19 Feb 2024 22:51:50 +0530 Subject: [PATCH 7/9] handling exceptions and removing duplicate imports --- .../autotune/configmaps/minikube-config.yaml | 46 ------------------- .../minikube/kruize-crc-minikube.yaml | 2 +- src/main/java/com/autotune/Autotune.java | 1 - .../datasource/DataSourceOperatorImpl.java | 1 - .../operator/InitializeDeployment.java | 3 +- .../operator/KruizeDeploymentInfo.java | 8 ++-- .../com/autotune/utils/KruizeConstants.java | 1 - 7 files changed, 7 insertions(+), 55 deletions(-) diff --git a/manifests/autotune/configmaps/minikube-config.yaml b/manifests/autotune/configmaps/minikube-config.yaml index 7a60bd79a..183610f57 100644 --- a/manifests/autotune/configmaps/minikube-config.yaml +++ b/manifests/autotune/configmaps/minikube-config.yaml @@ -12,49 +12,3 @@ data: monitoring_agent_endpoint: "" root_logging_level: "error" logging_level: "info" - dbconfigjson: | - { - "database": { - "adminPassword": "admin", - "adminUsername": "admin", - "hostname": "postgres-service", - "name": "kruizeDB", - "password": "admin", - "port": 5432, - "sslMode": "require", - "username": "admin" - } - } - kruizeconfigjson: | - { - "clustertype": "kubernetes", - "k8stype": "minikube", - "authtype": "", - "monitoringagent": "prometheus", - "monitoringservice": "prometheus-k8s", - "monitoringendpoint": "prometheus-k8s", - "savetodb": "true", - "dbdriver": "jdbc:postgresql://", - "hibernate": { - "dialect": "org.hibernate.dialect.PostgreSQLDialect", - "driver": "org.postgresql.Driver", - "c3p0minsize": 2, - "c3p0maxsize": 5, - "c3p0timeout": 300, - "c3p0maxstatements": 50, - "hbm2ddlauto": "none", - "showsql": "false", - "timezone": "UTC" - }, - "datasource": [ - { - "name": "default", - "provider": "prometheus", - "serviceName": "prometheus-k8s", - "namespace": "monitoring", - "url": "" - } - ] - } - - diff --git a/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml b/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml index e5f1da551..e56607d5a 100644 --- a/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml +++ b/manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml @@ -123,7 +123,7 @@ data: }, "datasource": [ { - "name": "default", + "name": "prometheus-1", "provider": "prometheus", "serviceName": "prometheus-k8s", "namespace": "monitoring", diff --git a/src/main/java/com/autotune/Autotune.java b/src/main/java/com/autotune/Autotune.java index ed309a1d2..6d83b0afc 100644 --- a/src/main/java/com/autotune/Autotune.java +++ b/src/main/java/com/autotune/Autotune.java @@ -19,7 +19,6 @@ import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.analyzer.exceptions.K8sTypeNotSupportedException; import com.autotune.analyzer.exceptions.KruizeErrorHandler; -import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.analyzer.utils.AnalyzerConstants; import com.autotune.database.helper.DBConstants; import com.autotune.database.init.KruizeHibernateUtil; diff --git a/src/main/java/com/autotune/common/datasource/DataSourceOperatorImpl.java b/src/main/java/com/autotune/common/datasource/DataSourceOperatorImpl.java index 569c589ed..4759b4eb8 100644 --- a/src/main/java/com/autotune/common/datasource/DataSourceOperatorImpl.java +++ b/src/main/java/com/autotune/common/datasource/DataSourceOperatorImpl.java @@ -1,6 +1,5 @@ package com.autotune.common.datasource; -import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.analyzer.exceptions.TooManyRecursiveCallsException; import com.autotune.analyzer.utils.AnalyzerConstants; import com.autotune.common.datasource.prometheus.PrometheusDataOperatorImpl; diff --git a/src/main/java/com/autotune/operator/InitializeDeployment.java b/src/main/java/com/autotune/operator/InitializeDeployment.java index 2ca7ac918..0e8c55d12 100644 --- a/src/main/java/com/autotune/operator/InitializeDeployment.java +++ b/src/main/java/com/autotune/operator/InitializeDeployment.java @@ -17,7 +17,6 @@ import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.analyzer.exceptions.K8sTypeNotSupportedException; -import com.autotune.analyzer.exceptions.DefaultDataSourceNotFoundException; import com.autotune.common.datasource.*; import com.autotune.utils.KruizeConstants; import org.json.JSONObject; @@ -55,7 +54,7 @@ public static void setup_deployment_info() throws Exception, K8sTypeNotSupported DataSourceInfo defaultDataSource = KruizeDeploymentInfo.defaultDataSource; // If no default datasource was specified in the configmap if (defaultDataSource == null) { - throw new DefaultDataSourceNotFoundException(); + LOGGER.error(KruizeConstants.DataSourceConstants.DataSourceErrorMsgs.DEFAULT_DATASOURCE_NOT_FOUND); } KruizeDeploymentInfo.setLayerTable(); diff --git a/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java b/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java index ca5bdbc38..c7e112916 100644 --- a/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java +++ b/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java @@ -142,9 +142,11 @@ public static void logDeploymentInfo() { LOGGER.info("Cluster Type: {}", KruizeDeploymentInfo.cluster_type); LOGGER.info("Kubernetes Type: {}", KruizeDeploymentInfo.k8s_type); LOGGER.info("Auth Type: {}", KruizeDeploymentInfo.auth_type); - LOGGER.info("Default Datasource: {}", KruizeDeploymentInfo.defaultDataSource.getName()); - LOGGER.info("Default Datasource URL: {}", KruizeDeploymentInfo.defaultDataSource.getUrl()); - LOGGER.info("Default Datasource Provider: {}\n\n", KruizeDeploymentInfo.defaultDataSource.getProvider()); + if (null != KruizeDeploymentInfo.defaultDataSource) { + LOGGER.info("Default Datasource: {}", KruizeDeploymentInfo.defaultDataSource.getName()); + LOGGER.info("Default Datasource URL: {}", KruizeDeploymentInfo.defaultDataSource.getUrl()); + LOGGER.info("Default Datasource Provider: {}\n\n", KruizeDeploymentInfo.defaultDataSource.getProvider()); + } } } diff --git a/src/main/java/com/autotune/utils/KruizeConstants.java b/src/main/java/com/autotune/utils/KruizeConstants.java index 99166ca8e..4571bb69c 100644 --- a/src/main/java/com/autotune/utils/KruizeConstants.java +++ b/src/main/java/com/autotune/utils/KruizeConstants.java @@ -550,7 +550,6 @@ public static final class KRUIZE_CONFIG_ENV_NAME { public static final String K8S_TYPE = "k8stype"; public static final String AUTH_TYPE = "authtype"; public static final String AUTH_TOKEN = "authtoken"; - public static final String CLUSTER_TYPE = "clustertype"; public static final String AUTOTUNE_MODE = "autotunemode"; public static final String EM_ONLY_MODE = "emonly"; From abf4cbc97461050d1a50197ecfe4ff06de4be69d Mon Sep 17 00:00:00 2001 From: Shekhar Saxena Date: Mon, 19 Feb 2024 23:25:07 +0530 Subject: [PATCH 8/9] adding support to update default datasource --- .../autotune/configmaps/minikube-config.yaml | 2 ++ .../datasource/DataSourceCollection.java | 23 ++++++++++++++++++- .../operator/KruizeDeploymentInfo.java | 1 - .../com/autotune/utils/KruizeConstants.java | 4 +++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/manifests/autotune/configmaps/minikube-config.yaml b/manifests/autotune/configmaps/minikube-config.yaml index 183610f57..8c5fb9dbd 100644 --- a/manifests/autotune/configmaps/minikube-config.yaml +++ b/manifests/autotune/configmaps/minikube-config.yaml @@ -12,3 +12,5 @@ data: monitoring_agent_endpoint: "" root_logging_level: "error" logging_level: "info" + + diff --git a/src/main/java/com/autotune/common/datasource/DataSourceCollection.java b/src/main/java/com/autotune/common/datasource/DataSourceCollection.java index 9ecbf46e9..25a1efa53 100644 --- a/src/main/java/com/autotune/common/datasource/DataSourceCollection.java +++ b/src/main/java/com/autotune/common/datasource/DataSourceCollection.java @@ -17,6 +17,7 @@ import com.autotune.common.exceptions.*; import com.autotune.common.utils.CommonUtils; +import com.autotune.operator.KruizeDeploymentInfo; import com.autotune.utils.KruizeConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,6 +41,7 @@ public class DataSourceCollection { private static final Logger LOGGER = LoggerFactory.getLogger(DataSourceCollection.class); private static DataSourceCollection dataSourceCollectionInstance = new DataSourceCollection(); private HashMap dataSourceCollection; + private String defaultDataSource = KruizeConstants.DataSourceConstants.DEFAULT_DATASOURCE_NAME; private DataSourceCollection() { this.dataSourceCollection = new HashMap<>(); @@ -66,7 +68,26 @@ public HashMap getDataSourcesCollection() { * @return DataSourceInfo object */ public DataSourceInfo getDefaultDataSource() { - return dataSourceCollection.get(KruizeConstants.DataSourceConstants.DEFAULT_DATASOURCE_NAME); + return dataSourceCollection.get(defaultDataSource); + } + + /** + * Update or set the default data source + * @param updatedDefaultDataSourceName String name of the new default data source + */ + public void setDefaultDataSource(String updatedDefaultDataSourceName) { + try { + LOGGER.info(KruizeConstants.DataSourceConstants.DataSourceInfoMsgs.UPDATING_DEFAULT_DATASOURCE + updatedDefaultDataSourceName); + if (dataSourceCollection.containsKey(updatedDefaultDataSourceName)) { + defaultDataSource = updatedDefaultDataSourceName; + KruizeDeploymentInfo.setDefaultDataSource(); + LOGGER.info(KruizeConstants.DataSourceConstants.DataSourceSuccessMsgs.DEFAULT_DATASOURCE_UPDATED); + } else { + throw new DataSourceNotExist(KruizeConstants.DataSourceConstants.DataSourceErrorMsgs.DATASOURCE_NOT_EXIST); + } + } catch (DataSourceNotExist e) { + LOGGER.error(e.getMessage()); + } } /** diff --git a/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java b/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java index c7e112916..d5f7111c1 100644 --- a/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java +++ b/src/main/java/com/autotune/operator/KruizeDeploymentInfo.java @@ -135,7 +135,6 @@ public static void setAuth_type(String auth_type) { public static void setDefaultDataSource() { KruizeDeploymentInfo.defaultDataSource = DataSourceCollection.getInstance().getDefaultDataSource(); - } public static void logDeploymentInfo() { diff --git a/src/main/java/com/autotune/utils/KruizeConstants.java b/src/main/java/com/autotune/utils/KruizeConstants.java index 4571bb69c..b04ad5d3a 100644 --- a/src/main/java/com/autotune/utils/KruizeConstants.java +++ b/src/main/java/com/autotune/utils/KruizeConstants.java @@ -331,7 +331,7 @@ private Memory() { public static class DataSourceConstants { public static final String DATASOURCE_NAME = "name"; - public static final String DEFAULT_DATASOURCE_NAME = "default"; + public static final String DEFAULT_DATASOURCE_NAME = "prometheus"; public static final String DATASOURCE_PROVIDER = "provider"; public static final String DATASOURCE_SERVICE_NAME = "serviceName"; public static final String DATASOURCE_SERVICE_NAMESPACE = "namespace"; @@ -343,6 +343,7 @@ public static class DataSourceConstants { public static class DataSourceInfoMsgs { public static final String ADDING_DATASOURCE = "Trying to add the datasource to collection: "; + public static final String UPDATING_DEFAULT_DATASOURCE = "Trying to update the default datasource: "; public static final String VERIFYING_DATASOURCE_REACHABILITY = "Verifying datasource reachability status: "; public static final String CHECKING_AVAILABLE_DATASOURCE = "Checking available datasources:"; private DataSourceInfoMsgs() { @@ -351,6 +352,7 @@ private DataSourceInfoMsgs() { public static class DataSourceSuccessMsgs { public static final String DATASOURCE_ADDED = "Datasource added to the collection successfully."; + public static final String DEFAULT_DATASOURCE_UPDATED = "Default datasource is updated successfully."; public static final String DATASOURCE_FOUND = "Datasource found: "; public static final String DATASOURCE_SERVICEABLE = "Datasource is serviceable."; private DataSourceSuccessMsgs() { From 5da26811579e2214c56965f98f88b4e343a335ed Mon Sep 17 00:00:00 2001 From: Shekhar Saxena Date: Mon, 25 Mar 2024 18:31:05 +0530 Subject: [PATCH 9/9] renaming datasource-providers-supported --- .../com/autotune/analyzer/kruizeLayer/LayerPresenceQuery.java | 2 +- .../performanceProfiles/PerformanceProfileValidation.java | 2 +- src/main/java/com/autotune/utils/KruizeSupportedTypes.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/autotune/analyzer/kruizeLayer/LayerPresenceQuery.java b/src/main/java/com/autotune/analyzer/kruizeLayer/LayerPresenceQuery.java index 0be0be514..c2b367027 100644 --- a/src/main/java/com/autotune/analyzer/kruizeLayer/LayerPresenceQuery.java +++ b/src/main/java/com/autotune/analyzer/kruizeLayer/LayerPresenceQuery.java @@ -31,7 +31,7 @@ public LayerPresenceQuery(String datasource, String layerPresenceQuery, String layerPresenceKey) throws MonitoringAgentNotSupportedException { - if (KruizeSupportedTypes.DATASOURCES_SUPPORTED.contains(datasource)) { + if (KruizeSupportedTypes.DATASOURCE_PROVIDERS_SUPPORTED.contains(datasource)) { this.dataSource = datasource; } else { throw new MonitoringAgentNotSupportedException(); diff --git a/src/main/java/com/autotune/analyzer/performanceProfiles/PerformanceProfileValidation.java b/src/main/java/com/autotune/analyzer/performanceProfiles/PerformanceProfileValidation.java index 894f03761..19ae8122f 100644 --- a/src/main/java/com/autotune/analyzer/performanceProfiles/PerformanceProfileValidation.java +++ b/src/main/java/com/autotune/analyzer/performanceProfiles/PerformanceProfileValidation.java @@ -144,7 +144,7 @@ private ValidationOutputData validatePerformanceProfileData(PerformanceProfile p String expression = null; for (Metric functionVariable : sloInfo.getFunctionVariables()) { // Check if datasource is supported - if (!KruizeSupportedTypes.DATASOURCES_SUPPORTED.contains(functionVariable.getDatasource().toLowerCase())) { + if (!KruizeSupportedTypes.DATASOURCE_PROVIDERS_SUPPORTED.contains(functionVariable.getDatasource().toLowerCase())) { errorString.append(AnalyzerConstants.AutotuneObjectConstants.FUNCTION_VARIABLE) .append(functionVariable.getName()) .append(AnalyzerErrorConstants.AutotuneObjectErrors.DATASOURCE_NOT_SUPPORTED); diff --git a/src/main/java/com/autotune/utils/KruizeSupportedTypes.java b/src/main/java/com/autotune/utils/KruizeSupportedTypes.java index 30c0e7395..ada24d640 100644 --- a/src/main/java/com/autotune/utils/KruizeSupportedTypes.java +++ b/src/main/java/com/autotune/utils/KruizeSupportedTypes.java @@ -29,7 +29,7 @@ private KruizeSupportedTypes() { } public static final Set DIRECTIONS_SUPPORTED = new HashSet<>(Arrays.asList("minimize", "maximize")); - public static final Set DATASOURCES_SUPPORTED = + public static final Set DATASOURCE_PROVIDERS_SUPPORTED = new HashSet<>(Arrays.asList("prometheus")); public static final Set MODES_SUPPORTED =