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

CentOS reboot-required command support #77

Closed
wants to merge 3 commits into from

Conversation

winjer
Copy link

@winjer winjer commented Jun 17, 2019

This has had minimal testing, but does appear to run at least. This is meant to address #4

I have this running in a test cluster now.

@winjer
Copy link
Author

winjer commented Jun 19, 2019

This has had some more testing and has rebooted a node running on Amazon Linux 2 correctly.

@laghoule
Copy link

@winjer EKS AMI?

@winjer
Copy link
Author

winjer commented Jun 20, 2019

Yep, specifically amazon-eks-node-1.12-v20190614 (ami-0bc8d0262346bd65e)

@winjer
Copy link
Author

winjer commented Jun 20, 2019

It's kind of hard to test, and I am not a CentOS expert, if you have things I should try I am very happy to try them.

@laghoule
Copy link

No, we are in the process to migrate to EKS, from our CoreOS based cluster (updated via CLUO). Was wondering is kured was working for EKS worker node. We will test your patch ;)

@lareeth
Copy link

lareeth commented Jun 21, 2019

Will test on CentOS 7.6

@lareeth
Copy link

lareeth commented Jun 21, 2019

@winjer what command did you use to test this? I'm having issues getting it working with any variation of needs-restarting commands

@winjer
Copy link
Author

winjer commented Jun 24, 2019 via email

@lareeth
Copy link

lareeth commented Jun 24, 2019

@winjer I'm using this custom image, however that command returns the exit codes the opposite to what kured requires, I can see in the logs the command is running, but nothing is being flagged for reboot

@winjer
Copy link
Author

winjer commented Jun 24, 2019

Yes, reading the code I think you are correct. I'll spin up the test system again and look at the logs to verify.

I can think of a couple of approaches to solving this but they are all a bit ugly. I'd be interested in what you think.

  1. define the exit codes for the reboot-sentinel-command to happily match those for needs-restarting.
  2. provide additional arguments to say whether a successful exit for the reboot-sentinel-command means reboot or don't reboot.
  3. provide a wrapper script as part of the image that tests for the existence of /var/run/reboot-required and returns the proper exit codes for (1) and remove reboot-sentinel entirely.
  4. use some shell for the needs-restarting command, so it is instead something like sh -c ! needs-restarting -r

do you have any better ideas?

@winjer
Copy link
Author

winjer commented Jun 24, 2019

FWIW sh -c ! needs-restarting -r looks like it might work.

@lareeth
Copy link

lareeth commented Jun 24, 2019

sh -c ! needs-restarting -r seems to always return exit code 1, is this from sh instead of needs-restarting

[root@test-one ~]# needs-restarting -r; echo $?
No core libraries or services have been updated.
Reboot is probably not necessary.
1
[root@test-one ~]# sh -c ! needs-restarting -r; echo $?
1
[root@test-two ~]# needs-restarting -r; echo $?
Core libraries or services have been updated:
  glibc -> 2.17-260.el7_6.5
  systemd -> 219-62.el7_6.6
  kernel -> 3.10.0-957.12.2.el7
  kernel -> 3.10.0-957.21.3.el7

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

More information:
https://access.redhat.com/solutions/27943
0
[root@test-two ~]# sh -c ! needs-restarting -r; echo $?
1

@winjer
Copy link
Author

winjer commented Jun 24, 2019

It is all to do with quoting I think.

sh -c "! needs-restarting -r"; echo $?

is, i think, correct.

I'll see how that can be accommodated. It's all pretty fugly :(

@lareeth
Copy link

lareeth commented Jun 24, 2019

So that works on the machine, but issues within kured, standard way of escaping doesnt seem to work, any ideas?

time="2019-06-24T14:22:59Z" level=info msg="Executing /usr/bin/nsenter -m/proc/1/ns/mnt -- sh -c \"! needs-restarting -r\""
time="2019-06-24T14:22:59Z" level=warning msg="needs-restarting: -c: line 0: unexpected EOF while looking for matching `\"'" cmd=/usr/bin/nsenter std=err
time="2019-06-24T14:22:59Z" level=warning msg="needs-restarting: -c: line 1: syntax error: unexpected end of file" cmd=/usr/bin/nsenter std=err 
time="2019-06-24T14:22:06Z" level=info msg="Executing /usr/bin/nsenter -m/proc/1/ns/mnt -- sh -c \\\"! needs-restarting -r\\\""
time="2019-06-24T14:22:06Z" level=warning msg="needs-restarting: \"!: command not found" cmd=/usr/bin/nsenter std=err 
 time="2019-06-24T14:23:49Z" level=info msg="Executing /usr/bin/nsenter -m/proc/1/ns/mnt -- sh -c '! needs-restarting -r'"
time="2019-06-24T14:23:49Z" level=warning msg="needs-restarting: -c: line 0: unexpected EOF while looking for matching `''" cmd=/usr/bin/nsenter std=err
time="2019-06-24T14:23:49Z" level=warning msg="needs-restarting: -c: line 1: syntax error: unexpected end of file" cmd=/usr/bin/nsenter std=err 

Does there need to be logic to clean up the command before we run it?

@winjer
Copy link
Author

winjer commented Jun 24, 2019

ok so with that update, you can use:

extraArgs:
  reboot-sentinel-command: '! needs-restarting -r'

in the stable chart.

and that maybe works! the output looks ok anyhow.

@lareeth
Copy link

lareeth commented Jun 24, 2019

Its working!

Will test on CentOS 7,8 and RHEL 7,8

@winjer
Copy link
Author

winjer commented Jun 24, 2019

thanks for your help :)

@lareeth
Copy link

lareeth commented Jun 24, 2019

OS Tested
CentOS 7.6.1810 ✔️
RHEL 7.6 ✔️
CentOS 8.0.1905 (Nightly)
RHEL 8.0

RHEL/CentOS 8 doesnt include needs-restarting instead uses dnf needs-restarting which doesnt support the reboothint switch https://access.redhat.com/solutions/3847481

@laghoule
Copy link

laghoule commented Jul 2, 2019

I confirm it's working too, on AWS EKS (1.13).

@lareeth
Copy link

lareeth commented Jul 2, 2019

@laghoule can you include the OS and release details, as EKS can run different OS types

@laghoule
Copy link

laghoule commented Jul 2, 2019

OS Tested
AmazonLinux2 (amazon-eks-node-1.13-v20190614) ✔️

Deployed with eksctl 0.1.38

@StevenACoffman
Copy link

@awh This works for us as well. Is there anything you would like me to do further to be able to merge this?

@bboreham
Copy link
Contributor

bboreham commented Sep 5, 2019

Why does go.sum change? That doesn't seem relevant to this PR. If I do go mod vendor I do get some changes to go.mod and go.sum, so I'll do a PR to update those.

The code change looks plausible to me.

@stefansedich
Copy link

Looking for this functionality too, will this get merged eventually?

@bboreham
Copy link
Contributor

Needs rebase.

Copy link
Collaborator

@evrardjp evrardjp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a duplicate of #43

@@ -101,9 +105,20 @@ func newCommand(name string, arg ...string) *exec.Cmd {
return cmd
}

func sentinelCommand() *exec.Cmd {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need this? Can't we just pass a sentinel command that's defaulting to the current systemctl command instead? We know the first part will always be nsenter -m /proc/1/ns/mnt , so the user could simply pass "systemctl reboot" as an argument?

@dholbach
Copy link
Member

dholbach commented Mar 9, 2020

Just a quick PSA from me:

  • we're hanging out in #kured on Slack
  • we're planning a contributors meeting soon: here's the link to the doodle to find a good time - be sure to pick your timezone before submitting (preliminary agenda)

We'd love to see you there.

@evrardjp
Copy link
Collaborator

Could you add "Closes: #4 " in the commit/PR messages? That would allow us to clean up things.

@joschi36
Copy link

Hey what's the status of this?
We are using this branch currently in production and would love to see this merged.

@evrardjp
Copy link
Collaborator

There are pending PRs which refactor the command used to reboot (or to not use a command at all, and directly the syscalls), so this is currently indirectly worked on.

@github-actions
Copy link

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

@StevenACoffman
Copy link

Still a good idea.

@evrardjp evrardjp added this to the 1.7.0 milestone Jan 11, 2021
@github-actions
Copy link

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

@onedr0p
Copy link

onedr0p commented Mar 13, 2021

Still a good idea.

@evrardjp
Copy link
Collaborator

Ok, keeping it open until a more flexible reboot command is out.

@evrardjp
Copy link
Collaborator

You might be interested by this pr: #297

@dholbach dholbach closed this Apr 6, 2021
@dholbach dholbach deleted the branch kubereboot:master April 6, 2021 10:08
@dholbach
Copy link
Member

dholbach commented Apr 6, 2021

Sorry. Can you please retarget your branch to be merged into main please?

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

Successfully merging this pull request may close these issues.

None yet

10 participants