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

Comments

Projects
None yet
3 participants
@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

This comment has been minimized.

Copy link
Member

spinscale commented Apr 14, 2014

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

spinscale commented Apr 14, 2014

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

@XANi

This comment has been minimized.

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 spinscale added the packaging label Jul 18, 2014

spinscale added a commit to spinscale/elasticsearch that referenced this issue Jul 30, 2014

Packaging: Dont remove ancestors on deb removal
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

Packaging: Dont remove ancestors on deb removal
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

Packaging: Dont remove ancestors on deb removal
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

This comment has been minimized.

Copy link
Contributor

t-lo commented Dec 3, 2014

With #7078 merged does the issue still exist?

@spinscale

This comment has been minimized.

Copy link
Member

spinscale commented Dec 5, 2014

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

@spinscale spinscale closed this Dec 5, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.