Added logic to handle kill signals in the bash script#205
Merged
tgianos merged 4 commits intoNetflix:developfrom Mar 23, 2016
Merged
Added logic to handle kill signals in the bash script#205tgianos merged 4 commits intoNetflix:developfrom
tgianos merged 4 commits intoNetflix:developfrom
Conversation
… for the job. The Kill(DELETE) HTTP request not just returns the status Accepted notifying user of its asynchronous behavior. Also added conditional logic for Linux vs Non-Linux operating systems.
Conflicts: genie-core/src/main/java/com/netflix/genie/core/jobs/JobConstants.java
…it kill and timeout. Fixed a bug where the timeout value for the job was getting lost before being persisted to the database
| // is launched in process group id which is the same as the pid of the parent process | ||
| if (SystemUtils.IS_OS_LINUX) { | ||
| command.add("setsid"); | ||
| } |
Contributor
There was a problem hiding this comment.
If we're going to start having lots of OS level differences I'd say we should create subclasses for LinuxJobKickoffTask, OSXJobKickoffTask, etc... that are created as beans based on what OS it is. That may well be overkill for right now but it's something to keep in mind.
…ess groups instead of immediate children only on Linux OS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The run.sh script for each job now has a handle_kill_request method which gets triggered once it traps a SIGTERM (kill or kill -15) signal. This initiates a kill sequence as follows:
The behavior of kill is slightly different between Linux and Non-Linux OS.
For a linux OS , the system launches the run.sh script using setsid. This results in run.sh, its children and all its grandchildren to launch in the same process group which is the pid of run.sh. Once this is done the kill logic uses the "-g" flag to send the kill and kill -9 signals to all at the processes in the process group. This signal is send to run.sh itself in this case. The kill signal is handled by run.sh and ignored, but the kill -9 kills the run.sh as well, which is fine as at this point there is nothing else it can do.
For a Non-Linux OS we simply launch the run.sh as a normal process and use its pid to send kill and kill -9 signals to its immediate children only, and hope that they handle the killing of their own children.