Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES 1.0.2 debian package fails on removing dirs when purged #5770

Closed
XANi opened this issue Apr 10, 2014 · 6 comments
Closed

ES 1.0.2 debian package fails on removing dirs when purged #5770

XANi opened this issue Apr 10, 2014 · 6 comments
Assignees
Labels
:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts Team:Delivery Meta label for Delivery team

Comments

@XANi
Copy link

XANi commented Apr 10, 2014

Purging package doesn't work in any way:

When /var/lib/elasticsearch exists and is a directory, it tries to rmdir /var/lib

(Reading database ... 159672 files and directories currently installed.)
Removing elasticsearch (1.0.2) ...
rmdir: failed to remove directory '/var/lib'
dpkg: error processing package elasticsearch (--purge):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 elasticsearch
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install.  Trying to recover:
Press Return to continue.

When /var/lib/elasticsearch doesn't exist, it tries to remove it and fails:

(Reading database ... 159672 files and directories currently installed.)
Removing elasticsearch (1.0.2) ...
rmdir: failed to remove '/var/lib/elasticsearch': No such file or directory
dpkg: error processing package elasticsearch (--purge):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 elasticsearch
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install.  Trying to recover:
Press Return to continue.

When /var/lib/elasticsearch is a mounted partition, it tries to remove dir and fails at it:

(Reading database ... 159672 files and directories currently installed.)
Removing elasticsearch (1.0.2) ...
rmdir: failed to remove '/var/lib/elasticsearch'
dpkg: error processing package elasticsearch (--purge):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 elasticsearch
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install.  Trying to recover:
Press Return to continue.

It also should probably do same stuff *DB packages do: ask if you want to keep your data when purging package

@XANi XANi changed the title ES 1.0.2 package fails on removing dirs when purged ES 1.0.2 debian package fails on removing dirs when purged Apr 10, 2014
@spinscale
Copy link
Contributor

Hey,

what linux distribution did you try this on. The only call in question in the prerm script is

rmdir -p --ignore-fail-on-non-empty /var/lib/elasticsearch

Agreed, the -p parameter does not make a lot of sense. But apart from that you should not get any invalid error message, except that the --ignore-fail-on-non-empty is somehow ignored... can you try on the commandline, if it works?

@XANi
Copy link
Author

XANi commented Apr 14, 2014

It was install->uninstall on debian wheezy/sid (i installed 1.0.2 and realized I need older version so I purged it)

"failed to remove directory '/var/lib'" only occurs when directory above (in my case /var/lib) is also a mount:

☠ mount | grep lib
/dev/mapper/rootvg-lib on /var/lib type xfs (rw,noatime,attr2,inode64,noquota)
/dev/mapper/rootvg-collectd on /var/lib/collectd type reiserfs (rw,noatime)
/dev/mapper/rootvg-elasticsearch on /var/lib/elasticsearch type xfs (rw,noatime,attr2,inode64,sunit=1024,swidth=2048,noquota)
☠ mkdir /usr/test; rmdir -p --ignore-fail-on-non-empty /usr/test
☠ mkdir /var/lib/test; rmdir -p --ignore-fail-on-non-empty /var/lib/test
rmdir: failed to remove directory '/var/lib'

but that is basically a bug in rmdir, it should just return silently, instead:

mkdir /asd;rmdir -p /asd
rmdir: failed to remove directory '/': Device or resource busy

and it's some old bug, as I see same behaviour on old centos 5 systems

It works if directory exists but it will fail if it is a mounted partition.

It will also fail if directory was already removed (like admin first removing mount ,then purging package).

I think just ignoring exit code of rmdir should be fine.

@spinscale spinscale self-assigned this Apr 14, 2014
@spinscale
Copy link
Contributor

great explanation, thanks for digging into this.. so removing -p and ignoring the error seems the way to go.

@XANi
Copy link
Author

XANi commented Apr 14, 2014

-p only works well when used with relative paths.

If you want to clean up empty dirs,

find /tmp/dir -type d -empty  -delete

works much better, but still exit code have to be handled/ignored

spinscale added a commit to spinscale/elasticsearch that referenced this issue Jul 30, 2014
The used -p option could result in accidentally deleting more directories
than /var/lib/elasticsearch - so this option was removed

Note: This only happens if the directories are empty, but still isnt needed.

Relates elastic#5770
spinscale added a commit that referenced this issue Jul 30, 2014
The used -p option could result in accidentally deleting more directories
than /var/lib/elasticsearch - so this option was removed

Note: This only happens if the directories are empty, but still isnt needed.

Relates #5770
spinscale added a commit that referenced this issue Sep 8, 2014
The used -p option could result in accidentally deleting more directories
than /var/lib/elasticsearch - so this option was removed

Note: This only happens if the directories are empty, but still isnt needed.

Relates #5770
@t-lo
Copy link

t-lo commented Dec 3, 2014

With #7078 merged does the issue still exist?

@spinscale
Copy link
Contributor

@t-lo you are right, this should be fixed. Closing.

@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts Team:Delivery Meta label for Delivery team
Projects
None yet
Development

No branches or pull requests

4 participants