Bug 1655902

Summary: kernel.sysrq is changed when running pcs cluster start, but system reboot cannot change kernel.sysrq to 136
Product: Red Hat Enterprise Linux 7 Reporter: mezhang <mezhang>
Component: pacemakerAssignee: Ken Gaillot <kgaillot>
Status: CLOSED NOTABUG QA Contact: cluster-qe <cluster-qe>
Severity: high Docs Contact:
Priority: high    
Version: 7.6CC: abeekhof, cluster-maint, mezhang, sbradley
Target Milestone: rc   
Target Release: 7.7   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-12-12 17:24:25 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:

Description mezhang 2018-12-04 08:59:05 UTC
Description of problem:

kernel.sysrq is changed when running pcs cluster start, but system reboot cannot change kernel.sysrq to 136 

Version-Release number of selected component (if applicable):

pacemaker-1.1.19-8.el7_6.1.x86_64

How reproducible:

There are two circumstances as below. but get different value. 

===
1. configure kernel.sysrq = 0 in /etc/sysctl.conf
2. # sysctl -p 
3. # pcs cluster start 
4. # sysctl -a | grep sysrq 
kernel.sysrq = 136
===

===
1. configure kernel.sysrq = 0 in /etc/sysctl.conf
2. # sysctl -p
3. # reboot
4. # sysctl -a | grep sysrq 
kernel.sysrq = 0
===

Expected results:

I have checked the pacemaker's source code. I figured out that watchdog changed the sysrq value. the source code is as below:

https://github.com/ClusterLabs/pacemaker/blob/master/lib/common/watchdog.c

I think reboot the system also can change the kernel.sysrq to 136. This is the expected result.

Maybe the reason is when reboot the system kernel.sysrq is setted after pacemaker? I think adding the dependency can solve this issue?

Additional info:

add kernel.sysrq=136 to sysctl.conf is workaround now.

Would you please check this for me?

Thank you so much

Mengyi

Comment 2 Ken Gaillot 2018-12-04 15:01:41 UTC
Hi mezhang,

I believe this is expected behavior. Pacemaker changes the sysrq contents when it starts, to make sure it can panic the kernel in case of severe error, but it does not change the user's permanent configuration.

Is there some negative effect on the cluster from not having it set at boot time?

Comment 3 mezhang 2018-12-05 01:39:52 UTC
Hi Gaillot,

Many thanks for your update.

>Is there some negative effect on the cluster from not having it set at boot time?

Manually restart the cluster can cause sysrq be changed. I know this is the expected behavior to make sure it can panic kernel.

But the sysrq isn't changed at the boot time. After the boot time if I never restart the cluster the sysrq cannot be changed, so that it cannot panic kernel.
I don't think this is an expected behavior. 

Mengyi

Comment 4 Ken Gaillot 2018-12-05 18:31:19 UTC
(In reply to mezhang from comment #3)
> Hi Gaillot,
> 
> Many thanks for your update.
> 
> >Is there some negative effect on the cluster from not having it set at boot time?
> 
> Manually restart the cluster can cause sysrq be changed. I know this is the
> expected behavior to make sure it can panic kernel.
> 
> But the sysrq isn't changed at the boot time. After the boot time if I never
> restart the cluster the sysrq cannot be changed, so that it cannot panic
> kernel.
> I don't think this is an expected behavior. 
> 
> Mengyi

I'm not sure I understand. If the cluster isn't running, how could it panic the kernel?

If your goal is to be able to panic the kernel by other means when the cluster is not running, then the sysctl.conf change in the Description is appropriate.

Comment 5 mezhang 2018-12-06 01:30:32 UTC
Hi Gaillot,

I am sorry for the confusing description.

>I'm not sure I understand. If the cluster isn't running, how could it panic the kernel?

I mean that when reboot the system, cluster is started by default. In this situation sysrq should be changed. In other words, cluster is running for the boot. But sysrq is not changed to 136 because sysctl.conf is worked.

mengyi

Comment 6 Ken Gaillot 2018-12-06 15:58:42 UTC
(In reply to mezhang from comment #5)
> Hi Gaillot,
> 
> I am sorry for the confusing description.
> 
> >I'm not sure I understand. If the cluster isn't running, how could it panic the kernel?
> 
> I mean that when reboot the system, cluster is started by default. In this
> situation sysrq should be changed. In other words, cluster is running for
> the boot. But sysrq is not changed to 136 because sysctl.conf is worked.
> 
> mengyi

Ah, I see. I didn't realize the cluster was enabled at boot, sorry.

Pacemaker should set the sysrq in this case as well, but I suspect something later in the boot sequence may be resetting it.

Does your /etc/sysctl.conf or any .conf file in /etc/sysctl.d have an explicit setting for kernel.sysrq?

Comment 7 Ken Gaillot 2018-12-06 16:03:06 UTC
I see the standard file /usr/lib/sysctl.d/50-default.conf contains "kernel.sysrq = 16", so that may be where it is coming from.

To confirm whether this is the cause, please remove your workaround, run this, and reboot:

mkdir -p /etc/systemd/system/pacemaker.service.d/
cat >/etc/systemd/system/pacemaker.service.d/after-sysctl.conf <<EOF
[Unit]
After=systemd-sysctl
EOF

Your workaround is actually better, but this should help confirm whether my suspicion is correct.

Comment 8 Ken Gaillot 2018-12-06 16:14:48 UTC
I think I see a good way to fix this. Pacemaker calls its sysrq_init() function at start-up, and again just before panicking the host if the need arises. However sysrq_init() has a static variable to ensure it only modifies the kernel setting once. If we simply remove this control, it will reset the setting just before it is needed.

It would still be interesting to know if the unit override helps, but I think I will go with that fix. In the meantime, either your original workaround (preferred) or the unit override workaround (if it works) will be helpful.

Comment 9 mezhang 2018-12-10 08:31:11 UTC
Hi Gaillot,

Thanks you so much for your update.

>Does your /etc/sysctl.conf or any .conf file in /etc/sysctl.d have an explicit setting for kernel.sysrq?

yes. I configured kernel.sysrq in /etc/sysctl.conf explicitly.

>To confirm whether this is the cause, please remove your workaround, run this, and reboot:
>mkdir -p /etc/systemd/system/pacemaker.service.d/
>cat >/etc/systemd/system/pacemaker.service.d/after-sysctl.conf <<EOF
>[Unit]
>After=systemd-sysctl
>EOF

I added "After=systemd-sysctl" in pacemaker.service directly. It helps to fix the issue!

Mengyi

Comment 10 Ken Gaillot 2018-12-11 15:29:03 UTC
Hi Mengyi,

I'm having trouble reproducing the issue. I have a patch that reliably resets kernel.sysrq when needed, but as far as I can tell, setting kernel.sysrq has never been necessary for pacemaker, since it writes to /proc/sysrq-trigger with root privileges, which is not constrained by kernel.sysrq.

In your testing, was pacemaker actually unable to perform a reboot? What steps did you take to get that to happen?

Comment 11 Ken Gaillot 2018-12-11 15:44:30 UTC
Specifically, from the kernel "sysrq.txt" documentation: "Note that the value of /proc/sys/kernel/sysrq influences only the invocation via a keyboard. Invocation of any operation via /proc/sysrq-trigger is always allowed (by a user with admin privileges)."

When Pacemaker uses sysrq, it's always via /proc/sysrq-trigger as root, so I do not think that Pacemaker needs to set kernel.sysrq at all.

Comment 12 mezhang 2018-12-12 08:40:39 UTC
>In your testing, was pacemaker actually unable to perform a reboot? What steps did you take to get that to happen?

I am not sure if pacemaker perform a reboot correctly.

I just realized that the kernal.sysrq don't show the right output.
So I raise this bug ticket.

Comment 13 Ken Gaillot 2018-12-12 17:24:25 UTC
Great, thanks!

Based on my testing and the kernel documentation, pacemaker should never have changed kernel.sysrq at all. I will remove that code for a future release. Since the code doesn't really cause any problems, I'm going to close this bz. Thanks for reporting it, I am glad to know we don't need to change the system settings.