Bug 785701

Summary: HALT_POWERDOWN_INSERT is ignored under systemd
Product: [openSUSE] openSUSE 12.2 Reporter: Andrei Borzenkov <arvidjaar>
Component: BasesystemAssignee: Frederic Crozat <fcrozat>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Minor    
Priority: P5 - None CC: bpetkov, forgotten_Ld-QSk4UDc, sbrabec
Version: Final   
Target Milestone: ---   
Hardware: Other   
OS: openSUSE 12.2   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Andrei Borzenkov 2012-10-18 15:20:23 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1

HALT_POWERDOWN_INSERT is evaluated by /etc/init.d/halt which no more runs under systemd. This variable was used by UPS packages to perform late "UPS off" command. This functionality is no more directly available in 12.2.

Either this variable need to be removed to avoid confusion or compatibility systemd unit similar to below is needed.

[Unit] 
Description=Execute HALT_POWERDOWN_INSERT  
DefaultDependencies=no 
After=shutdown.target umount.target
Before=final.target  

[Service] 
Type=oneshot
Environment=HALT_POWERDOWN_INSERT=
EnvironmentFile=/etc/sysconfig/shutdown
ExecStart=-/bin/sh -c '[ -n "$HALT_POWERDOWN_INSERT" ] && $HALT_POWERDOWN_INSERT'
TimeoutSec=0 
StandardOutput=tty 
RemainAfterExit=yes  

[Install] 
WantedBy=shutdown.target

Reproducible: Always

Steps to Reproduce:
1.
2.
3.
Comment 1 Frederic Crozat 2012-10-31 10:00:15 UTC
Thanks, I'll try to integrate your solution
Comment 2 Frederic Crozat 2012-11-05 18:07:38 UTC
*** Bug 788165 has been marked as a duplicate of this bug. ***
Comment 3 Stanislav Brabec 2012-11-05 19:15:36 UTC
Well, there is a question: Do we need to support HALT_POWERDOWN_INSERT in systemd? (Not thinking the about the late powerdown command feature, just about the HALT_POWERDOWN_INSERT sysconfig variable.)

I introduced HALT_POWERDOWN_INSERT several years ago, because there was no easy way to create init script running in the late halt sequence. (There was only /etc/init.d/halt.local, but its use is a bit complicated for packages. (The file is intended for admin, and it had to be auto-edited by rpm scriptlets.) And it is called before stopping software RAID.)

If systemd has a clean way to perform action just before calling the final poweroff, then HALT_POWERDOWN_INSERT is no more needed, and packages can use standard systemd integration.

If it is true, we can update HALT_POWERDOWN_INSERT description and say, that it is systemv specific.

What it would mean? Do not introduce the service proposed by you in the core systemd package, but add needed service to apcupsd and nut. I think that there were no other packages using this feature.
Comment 4 Frederic Crozat 2012-11-06 10:37:24 UTC
(In reply to comment #3)
> If systemd has a clean way to perform action just before calling the final
> poweroff, then HALT_POWERDOWN_INSERT is no more needed, and packages can use
> standard systemd integration.

It has: final.target is run just before shutting down, so it can be used like HALT_POWERDOWN_INSERT.

> If it is true, we can update HALT_POWERDOWN_INSERT description and say, that it
> is systemv specific.
> 
> What it would mean? Do not introduce the service proposed by you in the core
> systemd package, but add needed service to apcupsd and nut. I think that there
> were no other packages using this feature.

I could integrate Andrey fix for 12.2 (since it is already released) and we follow your suggestion for Factory.

WDYT ?
Comment 5 Andrei Borzenkov 2012-11-06 16:58:51 UTC
I think I was mistaken. When this issue was raised on forums I did not get clear picture where packages originated. But now I see that both apcupsd and nut are in standard openSUSE 12.2 repositories. That makes it really problem of packages integration which has to be fixed in respective packages, not in systemd.

I will rebuild apcupsd with proper system-shutdown script and ask user to test it.
Comment 6 Stanislav Brabec 2012-11-06 17:36:26 UTC
To Andrey: Thanks.

It seems that this approach is upstream-able, as it will work on all distros.

Note to HALT_POWERDOWN_INSERT introduction 6 years ago: In an ideal situation, it should be possible to shutdown correctly even without late poweroff command: Just initiate UPS grace period during the standard init script stop, and hope, that machine powers itself off in say 30 seconds.

Real life is different: However it should not happen with a properly configured nut, we should be prepared for situation, when network storage is already out of power and unmounting network storage fails on timeout. Initiating grace period as late as possible gives as much time as battery permits.
Comment 7 Forgotten User Ld-QSk4UDc 2012-12-13 18:14:00 UTC
I'm not sure if this bug is related to my issue.  I've got the problem of the PC never powering down even though I get the "System Halted" message ok (i escaped the shutdown splash to watch the shutdown).    I expect the PC then to power off.
Comment 8 Frederic Crozat 2012-12-14 10:22:40 UTC
(In reply to comment #7)
> I'm not sure if this bug is related to my issue.  I've got the problem of the
> PC never powering down even though I get the "System Halted" message ok (i
> escaped the shutdown splash to watch the shutdown).    I expect the PC then to
> power off.

This is unrelated, you need to use "halt -p" to shutdown your computer (as explained in the manual). With sysvinit, we had a patch which was injecting "-p" on x86/x86_64 hardware without you noticing.
Comment 9 Forgotten User Ld-QSk4UDc 2013-01-20 16:26:38 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > I'm not sure if this bug is related to my issue.  I've got the problem of the
> > PC never powering down even though I get the "System Halted" message ok (i
> > escaped the shutdown splash to watch the shutdown).    I expect the PC then to
> > power off.
> 
> This is unrelated, you need to use "halt -p" to shutdown your computer (as
> explained in the manual). With sysvinit, we had a patch which was injecting
> "-p" on x86/x86_64 hardware without you noticing.

Unfortunately that made no difference at all. 
There is "Bug 794889 - Shutdown does not power off machine" created by someone else which is more relevant but no-one has looked at it.  I had also posted to that one.
I installed Fedora on an old laptop to check another issue and noticed it used "poweroff".  So i tried it as well but it did the same thing, shut everything down okay but did not power off.
Comment 10 Frederic Crozat 2013-01-21 08:28:50 UTC
if halt -p doesn't work, it is a kernel issue.
Comment 11 Forgotten User Ld-QSk4UDc 2013-01-21 11:34:56 UTC
(In reply to comment #10)
> if halt -p doesn't work, it is a kernel issue.

Unfortunatly it doesn't work either, nothing seems to power off the machine.
Comment 12 Frederic Crozat 2013-01-21 12:10:47 UTC
so, it is not about this bug report.
Comment 13 Forgotten User Ld-QSk4UDc 2013-01-21 18:11:36 UTC
(In reply to comment #12)
> so, it is not about this bug report.

so it would appear.  just hope someone gets time to look at logged fault to check to see if it affects 12.3
Comment 14 Frederic Crozat 2013-03-12 14:11:12 UTC
closing as fixed, since andrej pushed fixes for proper systemd integration in Factory
Comment 15 Borislav Petkov 2013-07-25 16:34:06 UTC
So which systemd version has the fixes and how can I point people to it to try it out? I have a bug of two machines with similar symptoms (bnc#813244).

Thanks.
Comment 16 Frederic Crozat 2013-07-26 08:09:38 UTC
I think affected packages (UPS related) has been fixed in 12.3 to not rely on HALT_POWERDOWN_INSERT anymore. But we didn't integrate HALT_POWERDOWN_INSERT support in systemd for 12.3 (nor Factory) since it is deprecated.