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

Healthcheck for Kepler #834

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,24 @@
# License for the specific language governing permissions and limitations
# under the License.

ss -lnp | grep $1 || netstat -plnt | grep -i listen | grep $1
paramite marked this conversation as resolved.
Show resolved Hide resolved
URL="http://0.0.0.0:8888/healthz"

# Get the HTTP status code and response body using curl
RESPONSE=$(curl -s -w "%{http_code}" $URL)
BODY=${RESPONSE:0:-3} # Extract the body (all but the last 3 characters)
HTTP_CODE=${RESPONSE: -3} # Extract the last 3 characters as the HTTP status code

# Check the HTTP status code
if [ "$HTTP_CODE" -ne 200 ]; then
echo "$1 Health check failed: HTTP status code $HTTP_CODE"
exit 1
fi

# Check if the response body contains "ok"
if [[ "$BODY" != *"ok"* ]]; then
echo "$1 Health check failed: Response body does not contain 'ok'"
exit 1
fi

echo "$1 Health check passed: HTTP status code $HTTP_CODE, Health response 'ok'"
exit 0
Loading