mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Fall back to non-atomic move when removing plugins
When plugins are installed on a union filesystem (for example, inside a Docker container), removing them can fail because we attempt an atomic move which will not work if the plugin is not installed in the top layer. This commit modifies removing a plugin to fall back to a non-atomic move in cases when the underlying filesystem does not support atomic moves. Relates #23548
This commit is contained in:
parent
8dfb68cf1c
commit
2a26ae1d6a
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package org.elasticsearch.plugins;
|
package org.elasticsearch.plugins;
|
||||||
|
|
||||||
|
import java.nio.file.AtomicMoveNotSupportedException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
@ -83,7 +84,12 @@ class RemovePluginCommand extends EnvironmentAwareCommand {
|
|||||||
|
|
||||||
terminal.println(VERBOSE, "Removing: " + pluginDir);
|
terminal.println(VERBOSE, "Removing: " + pluginDir);
|
||||||
final Path tmpPluginDir = env.pluginsFile().resolve(".removing-" + pluginName);
|
final Path tmpPluginDir = env.pluginsFile().resolve(".removing-" + pluginName);
|
||||||
|
try {
|
||||||
Files.move(pluginDir, tmpPluginDir, StandardCopyOption.ATOMIC_MOVE);
|
Files.move(pluginDir, tmpPluginDir, StandardCopyOption.ATOMIC_MOVE);
|
||||||
|
} catch (final AtomicMoveNotSupportedException e) {
|
||||||
|
// this can happen on a union filesystem when a plugin is not installed on the top layer; we fall back to a non-atomic move
|
||||||
|
Files.move(pluginDir, tmpPluginDir);
|
||||||
|
}
|
||||||
pluginPaths.add(tmpPluginDir);
|
pluginPaths.add(tmpPluginDir);
|
||||||
|
|
||||||
IOUtils.rm(pluginPaths.toArray(new Path[pluginPaths.size()]));
|
IOUtils.rm(pluginPaths.toArray(new Path[pluginPaths.size()]));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user