-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add health check probe for k8s upgrade containers. #15223
Merged
qiluo-msft
merged 8 commits into
sonic-net:master
from
lixiaoyuner:add-health-check-probe
Jul 11, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d819b27
Add health check probe for k8s upgrade containers
lixiaoyuner 4b53a12
Update
lixiaoyuner a74b408
Update comments
lixiaoyuner 28ae09b
Fix typo issue
lixiaoyuner 30b4c06
Update the hook script to an executable file
lixiaoyuner 353c0c0
Update check start service logic
lixiaoyuner 95008f7
Merge branch 'master' into add-health-check-probe
lixiaoyuner f914042
Merge branch 'master' into add-health-check-probe
lixiaoyuner 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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
# This script is used by k8s to check the readiness of containers | ||
# Check if the container is readiness or not, exit code 0 means readiness, others mean not readiness | ||
|
||
#### exit code contract, k8s only cares zero or not none-zero, but we want to use none-zero code to indicate different error | ||
# 0: readiness | ||
# 1: if the hook script is python code, the default crash exit code is 1 | ||
# 2: supervisor start service doesn't exit normally | ||
# other exit code: returned by post_check_script, define in the post_check_script, should not include 1,2 | ||
|
||
# check if the start service exists | ||
# if the start service doesn't exist, do nothing | ||
# if the start service exists, check if it exits normally | ||
# if the start service doesn't exit normally, exit with code 2 | ||
pre_check_service_name="start" | ||
no_process_string="ERROR (no such process)" | ||
service_status=$(supervisorctl status $pre_check_service_name) | ||
if [[ $service_status != *"$no_process_string"* ]] && [[ $(echo $service_status |awk '{print $2}') != 'EXITED' ]]; then | ||
exit 2 | ||
fi | ||
|
||
# feature owner can add their own readiness check script | ||
# check if the post_check_script exists | ||
# if the post_check_script exists, run it | ||
# if the post_check_script exits with non-zero code, exit with the code | ||
post_check_script="/usr/bin/readiness_probe_hook" | ||
if [ -x $post_check_script ]; then | ||
$post_check_script | ||
post_check_result=$? | ||
if [ $post_check_result != 0 ]; then | ||
exit $post_check_result | ||
fi | ||
fi | ||
|
||
exit 0 |
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.
Will you check all the critical processes? #Closed
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.
The critical processes unexpected event will be handled by the supervisord exit-listener for now, the listener will kill the container, I don't think we need to check them here. Is this correct?