-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Force kill testcluster nodes #37353
Merged
alpar-t
merged 7 commits into
elastic:master
from
alpar-t:testclusters-force-kill-clusters
Feb 18, 2019
Merged
Force kill testcluster nodes #37353
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6d08571
Force kill testcluster nodes
alpar-t adadb5b
Merge remote-tracking branch 'origin/master' into testclusters-force-…
alpar-t bff15cf
make it clear when we wait
alpar-t 9539961
Merge remote-tracking branch 'origin/master' into testclusters-force-…
alpar-t b4c3a97
PR review
alpar-t 1b2d1c4
PR review
alpar-t efc3ae3
Merge remote-tracking branch 'origin/master' into testclusters-force-…
alpar-t File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,35 +243,45 @@ synchronized void stop(boolean tailLogs) { | |
} | ||
logger.info("Stopping `{}`, tailLogs: {}", this, tailLogs); | ||
requireNonNull(esProcess, "Can't stop `" + this + "` as it was not started or already stopped."); | ||
stopHandle(esProcess.toHandle()); | ||
// Test clusters are not reused, don't spend time on a graceful shutdown | ||
stopHandle(esProcess.toHandle(), true); | ||
if (tailLogs) { | ||
logFileContents("Standard output of node", esStdoutFile); | ||
logFileContents("Standard error of node", esStderrFile); | ||
} | ||
esProcess = null; | ||
} | ||
|
||
private void stopHandle(ProcessHandle processHandle) { | ||
private void stopHandle(ProcessHandle processHandle, boolean forcibly) { | ||
// Stop all children first, ES could actually be a child when there's some wrapper process like on Windows. | ||
if (processHandle.isAlive()) { | ||
processHandle.children().forEach(this::stopHandle); | ||
} | ||
logProcessInfo("Terminating elasticsearch process:", processHandle.info()); | ||
if (processHandle.isAlive()) { | ||
processHandle.destroy(); | ||
} else { | ||
if (processHandle.isAlive() == false) { | ||
logger.info("Process was not running when we tried to terminate it."); | ||
return; | ||
} | ||
waitForProcessToExit(processHandle); | ||
if (processHandle.isAlive()) { | ||
logger.info("process did not terminate after {} {}, stopping it forcefully", | ||
ES_DESTROY_TIMEOUT, ES_DESTROY_TIMEOUT_UNIT | ||
); | ||
|
||
// Stop all children first, ES could actually be a child when there's some wrapper process like on Windows. | ||
processHandle.children().forEach(each -> stopHandle(each, forcibly)); | ||
|
||
logProcessInfo( | ||
"Terminating elasticsearch process" + (forcibly ? " forcibly " : "gratefully") + ":", | ||
processHandle.info() | ||
); | ||
|
||
if (forcibly) { | ||
processHandle.destroyForcibly(); | ||
} else { | ||
processHandle.destroy(); | ||
waitForProcessToExit(processHandle); | ||
if (processHandle.isAlive()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can invert this, so:
|
||
logger.info("process did not terminate after {} {}, stopping it forcefully", | ||
ES_DESTROY_TIMEOUT, ES_DESTROY_TIMEOUT_UNIT); | ||
processHandle.destroyForcibly(); | ||
} | ||
} | ||
|
||
waitForProcessToExit(processHandle); | ||
if (processHandle.isAlive()) { | ||
throw new TestClustersException("Was not able to terminate es process"); | ||
throw new TestClustersException("Was not able to terminate elasticsearch process"); | ||
} | ||
} | ||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo, should be "gracefully". Not say we are not grateful 😉