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

Needs extension for Centos/RHEL distros #4

Closed
rsohn opened this issue Nov 10, 2017 · 11 comments
Closed

Needs extension for Centos/RHEL distros #4

rsohn opened this issue Nov 10, 2017 · 11 comments

Comments

@rsohn
Copy link

rsohn commented Nov 10, 2017

The use of a file such as /var/run/reboot-required is specific to Ubuntu family distros, but such a flag does not get set for RHEL/Centos distros using Yum/RPM for package management. In those environments, the yum-utils package is installed, then the needs-restarting -r command can run to detect the need for a reboot when its exit code is 1.

Suggest adding an optional argument to kured that provides a command to be executed, If the command exists and the exit code from that command is non-zero, then trigger a reboot the same as if the sentinel file exists. The default value for the option, if provided, would be needs-restarting -r.

Reference: How can I check from the command line if a reboot is required on rhel or centos

An alternative approach would be include a short script along the lines of the following that runs when installed on a RHEL/Centos system:

[[ -x /bin/needs-restarting ]] && needs-restarting -r >/dev/null || touch /var/run/reboot-required
@awh
Copy link
Contributor

awh commented Nov 20, 2017

Thanks for the report @rsohn. I like your idea of specifying a command, but sadly kured is running inside a container - it has neither access to arbitrary executables in the host filesystem, nor the sources of information such an executable might be using to determine if a reboot is required. You'll note that for the Debian/Ubuntu case the daemonset bind mounts /var/run into the container so that it can detect the presence of the sentinel file in the host - we would have to do something similar here after working out where needs-restarting is getting its information from. We may also have to include a copy of needs-restarting in the kured container image. In the meantime your workaround is sound, I will update the docs until we can do better.

@Matty9191
Copy link

@rsohn I cobbled together a restart script for my Fedora and CentOS lab systems. I'm installing and activating it with ansible and its working like a champ. Not sure if this will be of any value to you but thought I would pass it on.

@awh
Copy link
Contributor

awh commented Oct 30, 2018

Some progress on this - #39 moves us towards supporting CentOS/RHEL without external scripts...

@davidkarlsen
Copy link
Collaborator

With #39 on board - what more is needed?

@rsohn
Copy link
Author

rsohn commented Dec 4, 2018

It appears to me to be complete.

@davidkarlsen
Copy link
Collaborator

So . basically this issue should be closed as fixed?

@etiennetremel
Copy link

Maybe I'm missing something but if I look at the changes introduced by #39, it doesn't let you execute a binary.
@awh, should we introduce a new flag for this purpose? I can help if needed

@lumi017
Copy link

lumi017 commented May 22, 2019

Some progress on this - #39 moves us towards supporting CentOS/RHEL without external scripts...

@awh can you please elaborate? We still cannot use needs-restarting -r as sentinel.
The current implementation is using sentinelCmd := newCommand("/usr/bin/nsenter", "-m/proc/1/ns/mnt", "--", "/usr/bin/test", "-f", rebootSentinel)

Some tests to confirm it doesn't work with a command:

[root@host ~]# needs-restarting -r
No core libraries or services have been updated.
Reboot is probably not necessary.
[root@host ~]# echo $?
0
[root@host ~]# test -f 'needs-restarting -r'
[root@host ~]# echo $?
1
[root@host ~]# test -f '! needs-restarting -r'
[root@host ~]# echo $?
1
[root@host ~]# needs-restarting -r
Core libraries or services have been updated:
  systemd -> 219-62.el7_6.6

Reboot is required to ensure that your system benefits from these updates.

More information:
https://access.redhat.com/solutions/27943
[root@host ~]# echo $?
1
[root@host ~]# test -f '! needs-restarting -r'
[root@host ~]# echo $?
1
[root@host ~]# test -f 'needs-restarting -r'
[root@host ~]# echo $?
1

Can we have a successful implementation to depend on a return code of needs-restarting -r or you cannot bypass some limitation(s)?

@rsohn
Copy link
Author

rsohn commented May 24, 2019

It seems like "test" might not be the right mechanism to use here. Certainly, the -f option is a problem, as that checks for the existence of a file, rather than a return code.

Perhaps eval 'needs-restarting -r >/dev/null' is closer to what is needed here?

@winjer
Copy link

winjer commented Jul 25, 2019

PR #77 Seems to work ok and it would be great if someone is able to review it and merge it. Is that possible? @awh?

@github-actions
Copy link

This issue was automatically considered stale due to lack of activity. Please update it and/or join our slack channels to promote it, before it automatically closes (in 7 days).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants