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

Remove seemingly unnecessary ignoring of SIGTERM #96

Merged
merged 1 commit into from
Aug 17, 2017

Conversation

jrafanie
Copy link
Member

See the same change in ovirt:
ManageIQ/manageiq-providers-ovirt#80

Replaces #95

It was added originally back in 2011 in manageiq:
946657b11a0a65abbcdca9975206d71f7c2b7afc

This was actually copied from the vmware vim monitoring events
code from 2009: 22a911716b40428b6d822f0f1e95aabd022e59c9

def monitorEvents
  raise "monitorEvents: no block given" if !block_given?

 trap(:TERM) { $log.info "monitorEvents: ignoring SIGTERM" }
...

First of all, trap with logging doesn't work since ruby 2.0+:

irb(main):001:0> require 'logger'
=> true
irb(main):002:0> trap(:TERM) { Logger.new("stdout").info
"EventMonitor#start: ignoring SIGTERM" }
=> "DEFAULT"
irb(main):003:0> `kill #{Process.pid}`
log writing failed. can't be called from trap context
=> ""

See ManageIQ/manageiq#2386

Second, we need to TERM processes in container land.

See the same change in ovirt:
ManageIQ/manageiq-providers-ovirt#80

It was added originally back in 2011 in manageiq:
946657b11a0a65abbcdca9975206d71f7c2b7afc

This was actually copied from the vmware vim monitoring events
code from 2009: 22a911716b40428b6d822f0f1e95aabd022e59c9

```
def monitorEvents
  raise "monitorEvents: no block given" if !block_given?

 trap(:TERM) { $log.info "monitorEvents: ignoring SIGTERM" }
...
```

First of all, trap with logging doesn't work since ruby 2.0+:

```
irb(main):001:0> require 'logger'
=> true
irb(main):002:0> trap(:TERM) { Logger.new("stdout").info
"EventMonitor#start: ignoring SIGTERM" }
=> "DEFAULT"
irb(main):003:0> `kill #{Process.pid}`
log writing failed. can't be called from trap context
=> ""
```

See ManageIQ/manageiq#2386

Second, we need to TERM processes in container land.
@miq-bot
Copy link
Member

miq-bot commented Aug 17, 2017

Checked commit jrafanie@d6d3b1c with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks fine. 👍

@moolitayer
Copy link

moolitayer commented Aug 17, 2017

Makes sense. In k8s If we just ignore TERM we will eventually be killed after waiting ~30 sec for no good reason[1]

[1] https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods

Copy link

@moolitayer moolitayer left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@moolitayer
Copy link

@cben @simon3z please review

@jrafanie
Copy link
Member Author

Makes sense. In k8s If we just ignore TERM we will eventually be killed after waiting ~30 sec for no good reason[1]

Yes, this is exactly what @carbonin found, I believe

@moolitayer moolitayer added the bug label Aug 17, 2017
@moolitayer moolitayer merged commit e7128a9 into ManageIQ:master Aug 17, 2017
@moolitayer moolitayer added this to the Sprint 67 Ending Aug 21, 2017 milestone Aug 17, 2017
@jrafanie jrafanie deleted the do_not_ignore_sigterm branch January 26, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants