summaryrefslogtreecommitdiff
path: root/core/src/main/java
diff options
context:
space:
mode:
authorJason Tedor <jason@tedor.me>2017-06-26 21:43:20 -0400
committerGitHub <noreply@github.com>2017-06-26 21:43:20 -0400
commitdfd241e0a66192ca4e7599ca49c26d2d165af7b8 (patch)
tree43e3c23c3e41b9e7b7aef7dc6145a8b67bd691c1 /core/src/main/java
parentcca18a2c356afbe1025d6ba680e126236158a938 (diff)
Remove default path settings
This commit removes the default path settings for data and logs. With this change, we now ship the packages with these settings set in the elasticsearch.yml configuration file rather than going through the default.path.data and default.path.logs dance that we went through in the past. Relates #25408
Diffstat (limited to 'core/src/main/java')
-rw-r--r--core/src/main/java/org/elasticsearch/bootstrap/Security.java46
-rw-r--r--core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java2
-rw-r--r--core/src/main/java/org/elasticsearch/env/Environment.java9
-rw-r--r--core/src/main/java/org/elasticsearch/node/Node.java70
4 files changed, 3 insertions, 124 deletions
diff --git a/core/src/main/java/org/elasticsearch/bootstrap/Security.java b/core/src/main/java/org/elasticsearch/bootstrap/Security.java
index 81dc6f9d40..9504bdefa5 100644
--- a/core/src/main/java/org/elasticsearch/bootstrap/Security.java
+++ b/core/src/main/java/org/elasticsearch/bootstrap/Security.java
@@ -280,26 +280,6 @@ final class Security {
throw new IllegalStateException("unable to access [" + path + "]", e);
}
}
- /*
- * If path.data and default.path.data are set, we need read access to the paths in default.path.data to check for the existence of
- * index directories there that could have arisen from a bug in the handling of simultaneous configuration of path.data and
- * default.path.data that was introduced in Elasticsearch 5.3.0.
- *
- * If path.data is not set then default.path.data would take precedence in setting the data paths for the environment and
- * permissions would have been granted above.
- *
- * If path.data is not set and default.path.data is not set, then we would fallback to the default data directory under
- * Elasticsearch home and again permissions would have been granted above.
- *
- * If path.data is set and default.path.data is not set, there is nothing to do here.
- */
- if (Environment.PATH_DATA_SETTING.exists(environment.settings())
- && Environment.DEFAULT_PATH_DATA_SETTING.exists(environment.settings())) {
- for (final String path : Environment.DEFAULT_PATH_DATA_SETTING.get(environment.settings())) {
- // write permissions are not needed here, we are not going to be writing to any paths here
- addPath(policy, Environment.DEFAULT_PATH_DATA_SETTING.getKey(), getPath(path), "read,readlink");
- }
- }
for (Path path : environment.repoFiles()) {
addPath(policy, Environment.PATH_REPO_SETTING.getKey(), path, "read,readlink,write,delete");
}
@@ -309,11 +289,6 @@ final class Security {
}
}
- @SuppressForbidden(reason = "read path that is not configured in environment")
- private static Path getPath(final String path) {
- return PathUtils.get(path);
- }
-
/**
* Add dynamic {@link SocketPermission}s based on HTTP and transport settings.
*
@@ -428,27 +403,6 @@ final class Security {
}
/**
- * Add access to a directory iff it exists already
- * @param policy current policy to add permissions to
- * @param configurationName the configuration name associated with the path (for error messages only)
- * @param path the path itself
- * @param permissions set of file permissions to grant to the path
- */
- static void addPathIfExists(Permissions policy, String configurationName, Path path, String permissions) {
- if (Files.isDirectory(path)) {
- // add each path twice: once for itself, again for files underneath it
- policy.add(new FilePermission(path.toString(), permissions));
- policy.add(new FilePermission(path.toString() + path.getFileSystem().getSeparator() + "-", permissions));
- try {
- path.getFileSystem().provider().checkAccess(path.toRealPath(), AccessMode.READ);
- } catch (IOException e) {
- throw new IllegalStateException("Unable to access '" + configurationName + "' (" + path + ")", e);
- }
- }
- }
-
-
- /**
* Ensures configured directory {@code path} exists.
* @throws IOException if {@code path} exists, but is not a directory, not accessible, or broken symbolic link.
*/
diff --git a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
index d6a6b88764..15dffc427e 100644
--- a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
+++ b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
@@ -314,10 +314,8 @@ public final class ClusterSettings extends AbstractScopedSettings {
HunspellService.HUNSPELL_IGNORE_CASE,
HunspellService.HUNSPELL_DICTIONARY_OPTIONS,
IndicesStore.INDICES_STORE_DELETE_SHARD_TIMEOUT,
- Environment.DEFAULT_PATH_DATA_SETTING,
Environment.PATH_DATA_SETTING,
Environment.PATH_HOME_SETTING,
- Environment.DEFAULT_PATH_LOGS_SETTING,
Environment.PATH_LOGS_SETTING,
Environment.PATH_REPO_SETTING,
Environment.PATH_SHARED_DATA_SETTING,
diff --git a/core/src/main/java/org/elasticsearch/env/Environment.java b/core/src/main/java/org/elasticsearch/env/Environment.java
index f46f15b9d6..8f386f79dc 100644
--- a/core/src/main/java/org/elasticsearch/env/Environment.java
+++ b/core/src/main/java/org/elasticsearch/env/Environment.java
@@ -46,13 +46,10 @@ import java.util.function.Function;
// public+forbidden api!
public class Environment {
public static final Setting<String> PATH_HOME_SETTING = Setting.simpleString("path.home", Property.NodeScope);
- public static final Setting<List<String>> DEFAULT_PATH_DATA_SETTING =
- Setting.listSetting("default.path.data", Collections.emptyList(), Function.identity(), Property.NodeScope);
public static final Setting<List<String>> PATH_DATA_SETTING =
- Setting.listSetting("path.data", DEFAULT_PATH_DATA_SETTING, Function.identity(), Property.NodeScope);
- public static final Setting<String> DEFAULT_PATH_LOGS_SETTING = Setting.simpleString("default.path.logs", Property.NodeScope);
+ Setting.listSetting("path.data", Collections.emptyList(), Function.identity(), Property.NodeScope);
public static final Setting<String> PATH_LOGS_SETTING =
- new Setting<>("path.logs", DEFAULT_PATH_LOGS_SETTING, Function.identity(), Property.NodeScope);
+ new Setting<>("path.logs", "", Function.identity(), Property.NodeScope);
public static final Setting<List<String>> PATH_REPO_SETTING =
Setting.listSetting("path.repo", Collections.emptyList(), Function.identity(), Property.NodeScope);
public static final Setting<String> PATH_SHARED_DATA_SETTING = Setting.simpleString("path.shared_data", Property.NodeScope);
@@ -137,7 +134,7 @@ public class Environment {
}
// this is trappy, Setting#get(Settings) will get a fallback setting yet return false for Settings#exists(Settings)
- if (PATH_LOGS_SETTING.exists(settings) || DEFAULT_PATH_LOGS_SETTING.exists(settings)) {
+ if (PATH_LOGS_SETTING.exists(settings)) {
logsFile = PathUtils.get(PATH_LOGS_SETTING.get(settings)).normalize();
} else {
logsFile = homeFile.resolve("logs");
diff --git a/core/src/main/java/org/elasticsearch/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java
index bb7a2fd7f2..93f37cddf0 100644
--- a/core/src/main/java/org/elasticsearch/node/Node.java
+++ b/core/src/main/java/org/elasticsearch/node/Node.java
@@ -269,9 +269,6 @@ public class Node implements Closeable {
Logger logger = Loggers.getLogger(Node.class, tmpSettings);
final String nodeId = nodeEnvironment.nodeId();
tmpSettings = addNodeNameIfNeeded(tmpSettings, nodeId);
- if (DiscoveryNode.nodeRequiresLocalStorage(tmpSettings)) {
- checkForIndexDataInDefaultPathData(tmpSettings, nodeEnvironment, logger);
- }
// this must be captured after the node name is possibly added to the settings
final String nodeName = NODE_NAME_SETTING.get(tmpSettings);
if (hadPredefinedNodeName == false) {
@@ -525,73 +522,6 @@ public class Node implements Closeable {
}
}
- /**
- * Checks for path.data and default.path.data being configured, and there being index data in any of the paths in default.path.data.
- *
- * @param settings the settings to check for path.data and default.path.data
- * @param nodeEnv the current node environment
- * @param logger a logger where messages regarding the detection will be logged
- * @throws IOException if an I/O exception occurs reading the directory structure
- */
- static void checkForIndexDataInDefaultPathData(
- final Settings settings, final NodeEnvironment nodeEnv, final Logger logger) throws IOException {
- if (!Environment.PATH_DATA_SETTING.exists(settings) || !Environment.DEFAULT_PATH_DATA_SETTING.exists(settings)) {
- return;
- }
-
- boolean clean = true;
- for (final String defaultPathData : Environment.DEFAULT_PATH_DATA_SETTING.get(settings)) {
- final Path defaultNodeDirectory = NodeEnvironment.resolveNodePath(getPath(defaultPathData), nodeEnv.getNodeLockId());
- if (Files.exists(defaultNodeDirectory) == false) {
- continue;
- }
-
- if (isDefaultPathDataInPathData(nodeEnv, defaultNodeDirectory)) {
- continue;
- }
-
- final NodeEnvironment.NodePath nodePath = new NodeEnvironment.NodePath(defaultNodeDirectory);
- final Set<String> availableIndexFolders = nodeEnv.availableIndexFoldersForPath(nodePath);
- if (availableIndexFolders.isEmpty()) {
- continue;
- }
-
- clean = false;
- logger.error("detected index data in default.path.data [{}] where there should not be any", nodePath.indicesPath);
- for (final String availableIndexFolder : availableIndexFolders) {
- logger.info(
- "index folder [{}] in default.path.data [{}] must be moved to any of {}",
- availableIndexFolder,
- nodePath.indicesPath,
- Arrays.stream(nodeEnv.nodePaths()).map(np -> np.indicesPath).collect(Collectors.toList()));
- }
- }
-
- if (clean) {
- return;
- }
-
- final String message = String.format(
- Locale.ROOT,
- "detected index data in default.path.data %s where there should not be any; check the logs for details",
- Environment.DEFAULT_PATH_DATA_SETTING.get(settings));
- throw new IllegalStateException(message);
- }
-
- private static boolean isDefaultPathDataInPathData(final NodeEnvironment nodeEnv, final Path defaultNodeDirectory) throws IOException {
- for (final NodeEnvironment.NodePath dataPath : nodeEnv.nodePaths()) {
- if (Files.isSameFile(dataPath.path, defaultNodeDirectory)) {
- return true;
- }
- }
- return false;
- }
-
- @SuppressForbidden(reason = "read path that is not configured in environment")
- private static Path getPath(final String path) {
- return PathUtils.get(path);
- }
-
// visible for testing
static void warnIfPreRelease(final Version version, final boolean isSnapshot, final Logger logger) {
if (!version.isRelease() || isSnapshot) {