You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by av...@apache.org on 2016/05/23 17:36:15 UTC
ambari git commit: AMBARI-15898 : Grafana fails to start when using
custom data directory (avijayan)
Repository: ambari
Updated Branches:
refs/heads/branch-2.4 1e54411f8 -> 56377d4e2
AMBARI-15898 : Grafana fails to start when using custom data directory (avijayan)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/56377d4e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/56377d4e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/56377d4e
Branch: refs/heads/branch-2.4
Commit: 56377d4e2b8733b5fa618b160a9947701a3d3f09
Parents: 1e54411
Author: Aravindan Vijayan <av...@hortonworks.com>
Authored: Mon May 23 10:36:01 2016 -0700
Committer: Aravindan Vijayan <av...@hortonworks.com>
Committed: Mon May 23 10:36:09 2016 -0700
----------------------------------------------------------------------
.../server/upgrade/UpgradeCatalog240.java | 21 ++++++++++++++++++++
.../0.1.0/configuration/ams-grafana-ini.xml | 2 +-
.../server/upgrade/UpgradeCatalog240Test.java | 20 +++++++++++++++++++
3 files changed, 42 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/56377d4e/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
index 57cfa26..f08cab8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
@@ -1689,11 +1689,32 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
}
updateConfigurationPropertiesForCluster(cluster, AMS_SITE, newProperties, true, true);
}
+
+ Config amsGrafanaIni = cluster.getDesiredConfigByType("ams-grafana-ini");
+ if (amsGrafanaIni != null) {
+ Map<String, String> amsGrafanaIniProperties = amsGrafanaIni.getProperties();
+ String content = amsGrafanaIniProperties.get("content");
+ Map<String, String> newProperties = new HashMap<>();
+ newProperties.put("content", updateAmsGrafanaIni(content));
+ updateConfigurationPropertiesForCluster(cluster, "ams-grafana-ini", newProperties, true, true);
+ }
}
}
}
}
+ protected String updateAmsGrafanaIni(String content) {
+
+ if (content == null) {
+ return null;
+ }
+ String regSearch = "/var/lib/ambari-metrics-grafana";
+ String replacement = "{{ams_grafana_data_dir}}";
+ content = content.replaceAll(regSearch, replacement);
+
+ return content;
+ }
+
/**
* Create blueprint_setting table for storing the "settings" section
* in the blueprint. Auto start information is specified in the "settings" section.
http://git-wip-us.apache.org/repos/asf/ambari/blob/56377d4e/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/configuration/ams-grafana-ini.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/configuration/ams-grafana-ini.xml b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/configuration/ams-grafana-ini.xml
index 9e05860..40c89a0 100644
--- a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/configuration/ams-grafana-ini.xml
+++ b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/configuration/ams-grafana-ini.xml
@@ -57,7 +57,7 @@
# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
#
;data = /var/lib/grafana
-data = /var/lib/ambari-metrics-grafana
+data = {{ams_grafana_data_dir}}
#
# Directory where grafana can store logs
#
http://git-wip-us.apache.org/repos/asf/ambari/blob/56377d4e/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
index 606fc72..ce6d8e3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
@@ -31,6 +31,7 @@ import static org.junit.Assert.assertNull;
import java.io.File;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -1605,5 +1606,24 @@ public class UpgradeCatalog240Test {
assertTrue(upgradeCatalog240.isAtLeastHdp25(new StackId("HDP-2.6")));
assertFalse(upgradeCatalog240.isAtLeastHdp25(new StackId("SOMETHINGELSE-1.4")));
}
+
+ @Test
+ public void testUpdateAmsGrafanaIniContent() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
+ {
+ Method updateAmsEnvContent = UpgradeCatalog240.class.getDeclaredMethod("updateAmsGrafanaIni", String.class);
+ UpgradeCatalog240 upgradeCatalog240 = new UpgradeCatalog240(injector);
+ String oldContent = "# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)\n" +
+ "#\n" +
+ ";data = /var/lib/grafana\n" +
+ "data = /var/lib/ambari-metrics-grafana";
+
+ String expectedContent = "# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)\n" +
+ "#\n" +
+ ";data = /var/lib/grafana\n" +
+ "data = {{ams_grafana_data_dir}}";
+
+ String result = (String) updateAmsEnvContent.invoke(upgradeCatalog240, oldContent);
+ Assert.assertEquals(expectedContent, result);
+ }
}