restore my lost code changes and add measures to detect/prevent this in the future
This commit is contained in:
parent
354504334f
commit
8d5b5ad862
|
@ -47,6 +47,7 @@ import java.nio.file.DirectoryStream;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -107,7 +108,7 @@ public class PluginsService extends AbstractComponent {
|
|||
List<Bundle> bundles = getPluginBundles(environment);
|
||||
tupleBuilder.addAll(loadBundles(bundles));
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException("Can't load plugins into classloader", ex);
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
|
||||
plugins = tupleBuilder.build();
|
||||
|
@ -309,34 +310,30 @@ public class PluginsService extends AbstractComponent {
|
|||
|
||||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(pluginsDirectory)) {
|
||||
for (Path plugin : stream) {
|
||||
try {
|
||||
if (FileSystemUtils.isHidden(plugin)) {
|
||||
logger.trace("--- skip hidden plugin file[{}]", plugin.toAbsolutePath());
|
||||
continue;
|
||||
}
|
||||
logger.trace("--- adding plugin [{}]", plugin.toAbsolutePath());
|
||||
PluginInfo info = PluginInfo.readFromProperties(plugin);
|
||||
List<URL> urls = new ArrayList<>();
|
||||
if (info.isJvm()) {
|
||||
// a jvm plugin: gather urls for jar files
|
||||
try (DirectoryStream<Path> jarStream = Files.newDirectoryStream(plugin, "*.jar")) {
|
||||
for (Path jar : jarStream) {
|
||||
urls.add(jar.toUri().toURL());
|
||||
}
|
||||
if (FileSystemUtils.isHidden(plugin)) {
|
||||
logger.trace("--- skip hidden plugin file[{}]", plugin.toAbsolutePath());
|
||||
continue;
|
||||
}
|
||||
logger.trace("--- adding plugin [{}]", plugin.toAbsolutePath());
|
||||
PluginInfo info = PluginInfo.readFromProperties(plugin);
|
||||
List<URL> urls = new ArrayList<>();
|
||||
if (info.isJvm()) {
|
||||
// a jvm plugin: gather urls for jar files
|
||||
try (DirectoryStream<Path> jarStream = Files.newDirectoryStream(plugin, "*.jar")) {
|
||||
for (Path jar : jarStream) {
|
||||
urls.add(jar.toUri().toURL());
|
||||
}
|
||||
}
|
||||
final Bundle bundle;
|
||||
if (info.isJvm() && info.isIsolated() == false) {
|
||||
bundle = bundles.get(0); // purgatory
|
||||
} else {
|
||||
bundle = new Bundle();
|
||||
bundles.add(bundle);
|
||||
}
|
||||
bundle.plugins.add(info);
|
||||
bundle.urls.addAll(urls);
|
||||
} catch (Throwable e) {
|
||||
logger.warn("failed to add plugin [" + plugin + "]", e);
|
||||
}
|
||||
final Bundle bundle;
|
||||
if (info.isJvm() && info.isIsolated() == false) {
|
||||
bundle = bundles.get(0); // purgatory
|
||||
} else {
|
||||
bundle = new Bundle();
|
||||
bundles.add(bundle);
|
||||
}
|
||||
bundle.plugins.add(info);
|
||||
bundle.urls.addAll(urls);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,7 +357,7 @@ public class PluginsService extends AbstractComponent {
|
|||
jars.addAll(bundle.urls);
|
||||
JarHell.checkJarHell(jars.toArray(new URL[0]));
|
||||
} catch (Exception e) {
|
||||
logger.warn("failed to load bundle {} due to jar hell", bundle.urls, e);
|
||||
throw new IllegalStateException("failed to load bundle " + bundle.urls + " due to jar hell", e);
|
||||
}
|
||||
|
||||
// create a child to load the plugins in this bundle
|
||||
|
@ -371,17 +368,13 @@ public class PluginsService extends AbstractComponent {
|
|||
.build();
|
||||
|
||||
for (PluginInfo pluginInfo : bundle.plugins) {
|
||||
try {
|
||||
final Plugin plugin;
|
||||
if (pluginInfo.isJvm()) {
|
||||
plugin = loadPlugin(pluginInfo.getClassname(), settings);
|
||||
} else {
|
||||
plugin = new SitePlugin(pluginInfo.getName(), pluginInfo.getDescription());
|
||||
}
|
||||
plugins.add(new Tuple<>(pluginInfo, plugin));
|
||||
} catch (Throwable e) {
|
||||
logger.warn("failed to load plugin from [" + bundle.urls + "]", e);
|
||||
final Plugin plugin;
|
||||
if (pluginInfo.isJvm()) {
|
||||
plugin = loadPlugin(pluginInfo.getClassname(), settings);
|
||||
} else {
|
||||
plugin = new SitePlugin(pluginInfo.getName(), pluginInfo.getDescription());
|
||||
}
|
||||
plugins.add(new Tuple<>(pluginInfo, plugin));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class SitePluginRelativePathConfigTests extends ElasticsearchIntegrationT
|
|||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
String cwdToRoot = getRelativePath(PathUtils.get(".").toAbsolutePath());
|
||||
Path pluginDir = PathUtils.get(cwdToRoot, relativizeToRootIfNecessary(getDataPath("/org/elasticsearch/plugins")).toString());
|
||||
Path pluginDir = PathUtils.get(cwdToRoot, relativizeToRootIfNecessary(getDataPath("/org/elasticsearch/test_plugins")).toString());
|
||||
|
||||
Path tempDir = createTempDir();
|
||||
boolean useRelativeInMiddleOfPath = randomBoolean();
|
||||
|
|
|
@ -49,7 +49,7 @@ public class SitePluginTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
Path pluginDir = getDataPath("/org/elasticsearch/plugins");
|
||||
Path pluginDir = getDataPath("/org/elasticsearch/test_plugins");
|
||||
return settingsBuilder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put("path.plugins", pluginDir.toAbsolutePath())
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
site=true
|
||||
description=anotherplugin
|
||||
version=1.0
|
|
@ -0,0 +1,3 @@
|
|||
site=true
|
||||
description=dummy
|
||||
version=1.0
|
|
@ -0,0 +1,3 @@
|
|||
site=true
|
||||
description=subdir
|
||||
version=1.0
|
|
@ -95,18 +95,18 @@ if __name__ == '__main__':
|
|||
|
||||
run('%s; %s clean package -DskipTests' % (JAVA_ENV, MVN))
|
||||
|
||||
for f in os.listdir('core/target/releases/'):
|
||||
for f in os.listdir('distribution/tar/target/releases/'):
|
||||
if f.endswith('.tar.gz'):
|
||||
artifact = f
|
||||
break
|
||||
else:
|
||||
raise RuntimeError('could not find elasticsearch release under core/target/releases/')
|
||||
raise RuntimeError('could not find elasticsearch release under distribution/tar/target/releases/')
|
||||
|
||||
tmp_dir = tempfile.mkdtemp()
|
||||
p = None
|
||||
try:
|
||||
# Extract artifact:
|
||||
run('tar -xzf core/target/releases/%s -C %s' % (artifact, tmp_dir))
|
||||
run('tar -xzf distribution/tar/target/releases/%s -C %s' % (artifact, tmp_dir))
|
||||
es_install_dir = os.path.join(tmp_dir, artifact[:-7])
|
||||
es_plugin_path = os.path.join(es_install_dir, 'bin/plugin')
|
||||
installed_plugin_names = set()
|
||||
|
@ -131,6 +131,7 @@ if __name__ == '__main__':
|
|||
'-Des.node.name=smoke_tester',
|
||||
'-Des.cluster.name=smoke_tester_cluster'
|
||||
'-Des.discovery.zen.ping.multicast.enabled=false',
|
||||
'-Des.logger.level=debug',
|
||||
'-Des.script.inline=on',
|
||||
'-Des.script.indexed=on'),
|
||||
stdout = subprocess.PIPE,
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
<!-- runs an OS script -->
|
||||
<macrodef name="run-script">
|
||||
<attribute name="script"/>
|
||||
<attribute name="dir"/>
|
||||
<attribute name="args"/>
|
||||
<attribute name="spawn" default="false"/>
|
||||
<element name="nested" optional="true"/>
|
||||
|
@ -31,15 +30,18 @@
|
|||
<isfalse value="@{spawn}"/>
|
||||
</condition>
|
||||
|
||||
<exec executable="cmd" osfamily="winnt" dir="@{dir}" failonerror="${failonerror}" spawn="@{spawn}">
|
||||
<!-- create a temp CWD, to enforce that commands don't rely on CWD -->
|
||||
<mkdir dir="${integ.temp}"/>
|
||||
|
||||
<exec executable="cmd" osfamily="winnt" dir="${integ.temp}" failonerror="${failonerror}" spawn="@{spawn}">
|
||||
<arg value="/c"/>
|
||||
<arg value="@{dir}/@{script}.bat"/>
|
||||
<arg value="@{script}.bat"/>
|
||||
<arg line="@{args}"/>
|
||||
<nested/>
|
||||
</exec>
|
||||
|
||||
<exec executable="sh" osfamily="unix" dir="@{dir}" failonerror="${failonerror}" spawn="@{spawn}">
|
||||
<arg value="@{dir}/@{script}"/>
|
||||
<exec executable="sh" osfamily="unix" dir="${integ.temp}" failonerror="${failonerror}" spawn="@{spawn}">
|
||||
<arg value="@{script}"/>
|
||||
<arg line="@{args}"/>
|
||||
<nested/>
|
||||
</exec>
|
||||
|
@ -86,7 +88,7 @@
|
|||
|
||||
<!-- install plugin -->
|
||||
<echo>Installing plugin @{name}...</echo>
|
||||
<run-script dir="@{home}" script="bin/plugin" args="install @{name} -u ${url}"/>
|
||||
<run-script script="@{home}/bin/plugin" args="install @{name} -u ${url}"/>
|
||||
|
||||
<!-- check that plugin was installed into correct place -->
|
||||
<local name="longname"/>
|
||||
|
@ -116,7 +118,7 @@
|
|||
<attribute name="args" default="${integ.args}"/>
|
||||
<sequential>
|
||||
<echo>Starting up external cluster...</echo>
|
||||
<run-script dir="@{home}" script="bin/elasticsearch" spawn="true"
|
||||
<run-script script="@{home}/bin/elasticsearch" spawn="true"
|
||||
args="@{args} -Des.path.repo=@{home}/repo" />
|
||||
|
||||
<waitfor maxwait="3" maxwaitunit="minute" checkevery="500">
|
||||
|
@ -144,7 +146,7 @@
|
|||
<unzip src="${project.build.directory}/releases/elasticsearch-${project.version}.zip" dest="${integ.scratch}"/>
|
||||
<local name="home"/>
|
||||
<property name="home" location="${integ.scratch}/elasticsearch-${elasticsearch.version}"/>
|
||||
<run-script dir="${home}" script="bin/elasticsearch" spawn="false"
|
||||
<run-script script="${home}/bin/elasticsearch" spawn="false"
|
||||
args="${integ.args} -Des.path.repo=${home}/repo">
|
||||
<nested>
|
||||
<env key="JAVA_OPTS" value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"/>
|
||||
|
|
|
@ -89,5 +89,10 @@ set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8
|
|||
REM Use our provided JNA always versus the system one
|
||||
set JAVA_OPTS=%JAVA_OPTS% -Djna.nosys=true
|
||||
|
||||
set ES_CLASSPATH=%ES_CLASSPATH%;%ES_HOME%/lib/${project.build.finalName}.jar;%ES_HOME%/lib/*
|
||||
set CORE_CLASSPATH=%ES_HOME%/lib/${project.build.finalName}.jar;%ES_HOME%/lib/*
|
||||
if "%ES_CLASSPATH%" == "" (
|
||||
set ES_CLASSPATH=%CORE_CLASSPATH%
|
||||
) else (
|
||||
set ES_CLASSPATH=%ES_CLASSPATH%;%CORE_CLASSPATH%
|
||||
)
|
||||
set ES_PARAMS=-Delasticsearch -Des-foreground=yes -Des.path.home="%ES_HOME%"
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/lib/${project.build.finalName}.jar:$ES_HOME/lib/*"
|
||||
CORE_CLASSPATH="$ES_HOME/lib/${project.build.finalName}.jar:$ES_HOME/lib/*"
|
||||
|
||||
if [ "x$ES_CLASSPATH" = "x" ]; then
|
||||
ES_CLASSPATH="$CORE_CLASSPATH"
|
||||
else
|
||||
ES_CLASSPATH="$ES_CLASSPATH:$CORE_CLASSPATH"
|
||||
fi
|
||||
|
||||
if [ "x$ES_MIN_MEM" = "x" ]; then
|
||||
ES_MIN_MEM=${packaging.elasticsearch.heap.min}
|
||||
|
|
Loading…
Reference in New Issue