Bug 4880 - koha-remove sometimes fails because user is logged in
Summary: koha-remove sometimes fails because user is logged in
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Packaging (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Bugs List
URL:
Keywords:
: 17054 (view as bug list)
Depends on: 6684
Blocks: 17468
  Show dependency treegraph
 
Reported: 2010-06-10 01:45 UTC by Lars Wirzenius
Modified: 2017-06-14 22:13 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 4880: Make koha-remove stop all instance's services (1.95 KB, patch)
2016-10-20 15:04 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 4880: Make koha-remove stop all instance's services (2.00 KB, patch)
2016-10-27 03:08 UTC, Lucio Moraes
Details | Diff | Splinter Review
Bug 4880: Make koha-remove stop all instance's services (2.06 KB, patch)
2016-10-28 16:37 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Wirzenius 2010-06-10 01:45:39 UTC
I have not been able to reproduce this, but sometimes koha-remove fails because the user is logged in. I have no idea how that happens, since the instance-specific user cannot log in at all, and there is no trace of them being logged in.
Comment 1 Simon Story 2011-11-18 14:05:14 UTC
Perhaps deluser/userdel are complaining that the user is logged in because the zebra daemon still running as that user.

Maybe the daemon has not finished shutting down by the time the deluser command is run?
Comment 2 MJ Ray (software.coop) 2013-02-20 12:01:55 UTC
I think the daemon has not finished shutting down by the time the deluser command is run.  Could a wait, pkill or sleep be put before the deluser?
Comment 3 Robin Sheat 2013-02-24 22:47:35 UTC
hmm, this sounds quite plausible. I think a ps -u instance-koha test loop with (say) a 5 second sleep might be a useful solution here.
Comment 4 Magnus Enger 2013-10-14 13:08:51 UTC
Not sure if this really adds anything, but here goes:

I have been moving some instances around today, and done some koha-removes. In the beginning I was getting errors because the koha user for the given instance was logged in. Now I have tried several times to run koha-stop-zebra before I run koha-remove, and now I'm not getting the error about the logged in user. At least that seems to confirm the theory from comment #2.
Comment 5 Tomás Cohen Arazi (tcohen) 2016-09-27 18:54:34 UTC
Steps to reproduce:

- Run:
  $ koha-create --create-db favourite_name
- Run:
  $ koha-remove favourite_name
=> FAIL: koha-indexer is still running for user favourite_name-koha
Comment 6 Tomás Cohen Arazi (tcohen) 2016-10-20 15:04:38 UTC
Created attachment 56701 [details] [review]
Bug 4880: Make koha-remove stop all instance's services

This patch makes koha-remove stop all instance's services before
attempting to remove the system user,

Before this patch, only zebra was stopped.

To test:
- Run:
  $ sudo koha-create --created-db favourite_name
- Run:
  $ sudo koha-remove favourite_name
=> FAIL: koha-indexer is still running for user favourite_name-koha
- Run:
  $ sudo koha-create --created-db another_name
  $ sudo koha-plack --enable another_name
  $ sudo koha-plack --start another_name
  $ sudo koha-indexer --stop another_name
  $ sudo koha-remove another_name
=> FAIL: koha-plack is still running for user another_name-koha
- Apply the patch
- Repeat the previous tests, with new names
=> SUCCESS: Everything works as expected :-D
- Sign off :-D
Comment 7 Mirko Tietgen 2016-10-20 15:14:01 UTC
*** Bug 17054 has been marked as a duplicate of this bug. ***
Comment 8 Lucio Moraes 2016-10-26 08:41:41 UTC
I did

1)sudo koha-create --create-db f_name, and got:
Koha instance is empty, no staff user created.
Starting Zebra server for f_name
[ ok ] Starting Koha indexing daemon for f_name:.

2) sudo koha-remove f_name, and got: 

Removing Koha instance f_name
Stopping Zebra server for f_name
userdel: user f_name-koha is currently used by process 4793
/usr/sbin/deluser: `/usr/sbin/userdel f_name-koha' returned error code 8. Exiting.
Comment 9 Magnus Enger 2016-10-26 09:05:51 UTC
(In reply to Lucio Moraes from comment #8)
> userdel: user f_name-koha is currently used by process 4793
> /usr/sbin/deluser: `/usr/sbin/userdel f_name-koha' returned error code 8.
> Exiting.

Was this before or after applying the patch? If it was before, it confirms the bug. If it was after the patch should probably be marked as Failed QA.
Comment 10 Tomás Cohen Arazi (tcohen) 2016-10-26 10:31:28 UTC
(In reply to Lucio Moraes from comment #8)
> I did
> 
> 1)sudo koha-create --create-db f_name, and got:
> Koha instance is empty, no staff user created.
> Starting Zebra server for f_name
> [ ok ] Starting Koha indexing daemon for f_name:.
> 
> 2) sudo koha-remove f_name, and got: 
> 
> Removing Koha instance f_name
> Stopping Zebra server for f_name
> userdel: user f_name-koha is currently used by process 4793
> /usr/sbin/deluser: `/usr/sbin/userdel f_name-koha' returned error code 8.
> Exiting.

If you are testing the patch, please make sure you are running the patched koha-remove. The command should look like

kohaclone/debian/scripts/koha-remove f_name
Comment 11 Tomás Cohen Arazi (tcohen) 2016-10-27 01:39:07 UTC
Can anyone sign this, please? :-)
Comment 12 Lucio Moraes 2016-10-27 03:08:28 UTC
Created attachment 56910 [details] [review]
Bug 4880: Make koha-remove stop all instance's services

This patch makes koha-remove stop all instance's services before
attempting to remove the system user,

Before this patch, only zebra was stopped.

To test:
- Run:
  $ sudo koha-create --created-db favourite_name
- Run:
  $ sudo koha-remove favourite_name
=> FAIL: koha-indexer is still running for user favourite_name-koha
- Run:
  $ sudo koha-create --created-db another_name
  $ sudo koha-plack --enable another_name
  $ sudo koha-plack --start another_name
  $ sudo koha-indexer --stop another_name
  $ sudo koha-remove another_name
=> FAIL: koha-plack is still running for user another_name-koha
- Apply the patch
- Repeat the previous tests, with new names
=> SUCCESS: Everything works as expected :-D
- Sign off :-D

Signed-off-by: Lucio Moraes <lmoraes@catalyst.net.nz>
Comment 13 Jonathan Druart 2016-10-28 16:37:56 UTC
Created attachment 56965 [details] [review]
Bug 4880: Make koha-remove stop all instance's services

This patch makes koha-remove stop all instance's services before
attempting to remove the system user,

Before this patch, only zebra was stopped.

To test:
- Run:
  $ sudo koha-create --created-db favourite_name
- Run:
  $ sudo koha-remove favourite_name
=> FAIL: koha-indexer is still running for user favourite_name-koha
- Run:
  $ sudo koha-create --created-db another_name
  $ sudo koha-plack --enable another_name
  $ sudo koha-plack --start another_name
  $ sudo koha-indexer --stop another_name
  $ sudo koha-remove another_name
=> FAIL: koha-plack is still running for user another_name-koha
- Apply the patch
- Repeat the previous tests, with new names
=> SUCCESS: Everything works as expected :-D
- Sign off :-D

Signed-off-by: Lucio Moraes <lmoraes@catalyst.net.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 14 Kyle M Hall (khall) 2016-10-28 16:44:25 UTC
Pushed to master for 16.11, thanks Tomas!
Comment 15 Frédéric Demians 2016-11-02 18:30:39 UTC
Pushed in 16.05. Will be in 16.05.06.
Comment 16 Julian Maurice 2016-11-08 10:07:48 UTC
Pushed to 3.22.x, will be in 3.22.13