From: ssum21 Date: Mon, 30 Sep 2024 17:25:07 +0000 (+0900) Subject: Enhance logging install_kserve.sh X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F91%2F13491%2F1;p=aiml-fw%2Faimlfw-dep.git Enhance logging install_kserve.sh Change-Id: I2fdf0ed52480a668af61c2ea6c8b996cdc67ae67 Signed-off-by: ssum21 --- diff --git a/bin/install_kserve.sh b/bin/install_kserve.sh index 0e756c3..94bfdce 100755 --- a/bin/install_kserve.sh +++ b/bin/install_kserve.sh @@ -18,15 +18,26 @@ set -eu +# Function to dynamically generate log messages +# This function allows logging with a consistent format, supporting different levels like INFO, ERROR, and WARN +log_message() { + local log_level=$1 + local component=$2 + local message=$3 + echo "[$log_level] $component: $message" +} + + DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" cd "$DIR" || exit -# import configs +# Import KServe configs +log_message "INFO" "KServe" "Importing configurations" source ${DIR}/../tools/kserve/config.sh -function wait_for_deployment() { - echo -n "waiting for all pods running underneath of $1 deployment" - +# Function to wait for Kubernetes deployments +wait_for_deployment() { + log_message "INFO" "Kubernetes" "Waiting for all pods under deployment $1 in namespace $2" STILL_WAITING=true while $STILL_WAITING; do STILL_WAITING=false @@ -38,12 +49,11 @@ function wait_for_deployment() { if [ $DESIRED_STATE -ne $CURRENT_STATE ]; then STILL_WAITING=true sleep 1 - echo -n "." + log_message "INFO" "Kubernetes" "Pod $POD is not ready. Retrying..." fi done done - - echo + log_message "INFO" "Kubernetes" "All pods for deployment $1 are now running" } function wait_for_statefulset() {