Skip to content

Commit

Permalink
[Package] Remove bin/lib/modules directories on RPM uninstall/upgrade (
Browse files Browse the repository at this point in the history
…#20448)

When uninstalling or upgrading elasticsearch using the RPM package some empty directories remain on the filesystem:

    /usr/share/elasticsearch/bin
    /usr/share/elasticsearch/lib
    /usr/share/elasticsearch/modules
    /usr/share/elasticsearch/modules/foo

Having empty directories in modules can prevent elasticsearch to start after an upgrade: the plugins service expects to find a plugin-descriptor.properties file in every sub directory of modules.

This PR cleans things a bit so that these empty directories are removed on upgrade/removal like it was in 2.x.

(cherry picked from commit 3caaafa)
  • Loading branch information
tlrx committed Sep 14, 2016
1 parent a585c93 commit 5c30bc2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions distribution/rpm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ task buildRpm(type: Rpm) {
fileMode 0644
addParentDirs false
// TODO ospackage doesn't support icon but we used to have one

// Declare the folders so that the RPM package manager removes
// them when upgrading or removing the package
directory('/usr/share/elasticsearch/bin', 0755)
directory('/usr/share/elasticsearch/lib', 0755)
directory('/usr/share/elasticsearch/modules', 0755)
modulesFiles.eachFile { FileCopyDetails fcp ->
if (fcp.name == "plugin-descriptor.properties") {
directory('/usr/share/elasticsearch/modules/' + fcp.file.parentFile.name, 0755)
}
}
}

artifacts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,15 @@ setup() {
# see postrm file
assert_file_not_exist "/var/log/elasticsearch"
assert_file_not_exist "/usr/share/elasticsearch/plugins"
assert_file_not_exist "/usr/share/elasticsearch/modules"
assert_file_not_exist "/var/run/elasticsearch"

# Those directories are removed by the package manager
assert_file_not_exist "/usr/share/elasticsearch/bin"
assert_file_not_exist "/usr/share/elasticsearch/lib"
assert_file_not_exist "/usr/share/elasticsearch/modules"
assert_file_not_exist "/usr/share/elasticsearch/modules/lang-painless"

# The configuration files are still here
assert_file_exist "/etc/elasticsearch"
assert_file_exist "/etc/elasticsearch/scripts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,15 @@ setup() {
# see postrm file
assert_file_not_exist "/var/log/elasticsearch"
assert_file_not_exist "/usr/share/elasticsearch/plugins"
assert_file_not_exist "/usr/share/elasticsearch/modules"
assert_file_not_exist "/var/run/elasticsearch"

# Those directories are removed by the package manager
assert_file_not_exist "/usr/share/elasticsearch/bin"
assert_file_not_exist "/usr/share/elasticsearch/lib"
assert_file_not_exist "/usr/share/elasticsearch/modules"
assert_file_not_exist "/usr/share/elasticsearch/modules/lang-painless"

assert_file_not_exist "/etc/elasticsearch"
assert_file_not_exist "/etc/elasticsearch/scripts"
assert_file_not_exist "/etc/elasticsearch/elasticsearch.yml"
Expand Down Expand Up @@ -158,8 +165,14 @@ setup() {
# see postrm file
assert_file_not_exist "/var/log/elasticsearch"
assert_file_not_exist "/usr/share/elasticsearch/plugins"
assert_file_not_exist "/usr/share/elasticsearch/modules"
assert_file_not_exist "/var/run/elasticsearch"

assert_file_not_exist "/usr/share/elasticsearch/bin"
assert_file_not_exist "/usr/share/elasticsearch/lib"
assert_file_not_exist "/usr/share/elasticsearch/modules"
assert_file_not_exist "/usr/share/elasticsearch/modules/lang-painless"

assert_file_not_exist "/etc/elasticsearch/elasticsearch.yml"
assert_file_exist "/etc/elasticsearch/elasticsearch.yml.rpmsave"
assert_file_not_exist "/etc/elasticsearch/jvm.options"
Expand Down

0 comments on commit 5c30bc2

Please sign in to comment.