Bug 1298355

Summary: kickstart stuck at "Reached Target Shutdown" stage when removing media before shutdown completes
Product: Red Hat Enterprise Linux 7 Reporter: jcastran
Component: systemdAssignee: systemd-maint
Status: CLOSED ERRATA QA Contact: Branislav Blaškovič <bblaskov>
Severity: high Docs Contact:
Priority: urgent    
Version: 7.2CC: bblaskov, fkrska, h.teunis, jcastran, jkoduvathra, jruemker, kwalker, mrichter, mschena, rsawhill, systemd-maint-list, systemd-maint, thierry.laurion, vagrawal, yann.lopez
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: systemd-219-31.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1421712 (view as bug list) Environment:
Last Closed: 2017-08-01 09:09:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1383699, 1421712    

Description jcastran 2016-01-13 21:39:04 UTC
Description of problem:
Rhel 7.2 will not complete shutdown. Halts at "Reached Target Shutdown"
Customer has previously used this method for RHEL 5,6,7,7.1 but now if you manually eject the DVD before the shutdown is complete, the system will hang attempting to unmount media that is already gone.

Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux 7.2

How reproducible:
Everytime

Steps to Reproduce:
1. Complete kickstart installation
2. As system is beginning the reboot process, eject the ISO/DVD

Actual results:
Halts at "Reached Target Shutdown"

Expected results:
System completes reboot, preventing bios from targeting CDROM drive as boot target

Additional info:
Customer is using VMWare
VMware boot screen delay is set to 0 seconds

Comment 2 jcastran 2016-01-24 13:06:00 UTC
Customer Comment/Request:

Hello,

As discussed, we have been using the procedure of disconnecting the DVD image before reboot in RHEL5/6 and even in RHEL7.1. If we cannot get the same procedure working in RHEL7.2 we will have to make lot of changes in build process and the standards followed in VM creation. If it's a matter of very limited number of servers workaround's are fine. But when it comes to huge number of servers and changing process and procedures followed by different team, it makes it very complicated. What I am requesting is to find what behavior is changed from RHEL7.1 to 7.2 and is that a customizable parameter ?

Thanks.
 Joseph Koduvathra  (1/22/2016 4:42 PM)

Comment 7 Mauro Mozzarelli 2016-10-29 12:36:36 UTC
I have exactly the same problem. VM Shutdown and Reboot stop at:

[ OK ] Stopped Remount Root and Kernel Filesystems.
       Stopping Remount Root and Kernel Filesystems...
[ OK ] Reached Target Shutdown

However there is no DVD or any other media involved, thus it does not depend just on media removal as reported above.

After the last message the VM hangs and fails to shutdown or reboot requiring manual intervention.

This should be considered a "blocking" bug as it impacts essential server automation.

Comment 8 Mauro Mozzarelli 2016-10-29 16:03:53 UTC
After further investigation I found that:
- systemd hangs on shutdown/reboot when there is a tmpfs filesystem.
- By removing every tmpfs filesystem it no longer hangs.

This is because systemd runs swapoff (remove all swaps) before tmpfs are unmounted and this causes the system to hang.


A fix is available in systemd 229:

https://github.com/systemd/systemd/issues/1902
Swap units are deactivated too early

This is linked to Bug 1031158

As this affects system operations and availability (remote VMs hang when rebooted and require manual intervention) I recommend to raise the priority to HIGH.

Comment 9 Lukáš Nykrýn 2016-11-10 12:40:49 UTC
https://github.com/lnykryn/systemd-rhel/pull/66

Comment 10 Joseph Biju Koduvathra 2016-11-10 15:36:13 UTC
Can someone confirm if a fix is available yet ? how is RHEL7.3 ?  Unfortunately I am not allowed to open github at my workplace.

Comment 11 Branislav Blaškovič 2016-11-11 12:04:12 UTC
qa acking for 7.4

Comment 12 Joseph Biju Koduvathra 2016-11-11 12:38:55 UTC
(In reply to Branislav Blaškovič from comment #11)
> qa acking for 7.4

Thank you.

Comment 13 Jakub Rączkowski 2016-11-17 09:40:16 UTC
I believe the same bug happens for Atomic Hosts after prelonged time of running Docker containers.

Comment 17 Mauro Mozzarelli 2017-01-11 14:34:59 UTC
The change proposed in Comment 14, although necessary, does not resolve the problem (already tried).

The issue occurs whether there is a tmpfs mounted or not. Having a tmpfs mounted only exacerbates the problem because the system runs out of physical memory earlier and consistently when the swap is turned off, for example on a Virtual Machine that has a small amount of "physical" memory allocated.

The issue occurs because during the shutdown/reboot process systemd calls swapoff that attempts to remove every swap device.

If there isn't sufficient physical memory to hold what was being held in the swap area, then the system hangs indefinitely.

In previous RedHat versions (up to 6) swapoff was never called during shutdown/reboot.

I wonder what has changed in RHEL 7 that now requires a swapoff. Couldn't we just do without and solve the problem? After all it should not be necessary to "remove" memory to shutdown a system.

Comment 18 Lukáš Nykrýn 2017-01-11 15:50:34 UTC
> In previous RedHat versions (up to 6) swapoff was never called during
> shutdown/reboot.
> 

I don't think that is true:
https://github.com/fedora-sysv/initscripts/blob/rhel6-branch/rc.d/init.d/halt#L117

Comment 19 Mauro Mozzarelli 2017-01-11 18:50:18 UTC
That is "halt"

Nevertheless. Is it necessary to call swapoff? And why?
It should be safe to halt the system without calling swapoff.

Comment 20 Lukáš Nykrýn 2017-01-11 20:11:01 UTC
For example you can use a swap file instead of partition. Then you need to call swapoff first otherwise you won't be able to unmount the partition, where the swap file is stored.

Comment 21 Jan Synacek 2017-01-13 07:44:14 UTC
*** Bug 1379268 has been marked as a duplicate of this bug. ***

Comment 26 thierry.laurion 2017-04-13 15:39:48 UTC
Still not fixed. https://bugzilla.redhat.com/show_bug.cgi?id=1379268 marked falsely as a duplicate.

Comment 31 errata-xmlrpc 2017-08-01 09:09:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:2297