Enhance logging install_kserve.sh 91/13491/1
authorssum21 <ssumuss@khu.ac.kr>
Mon, 30 Sep 2024 17:25:07 +0000 (02:25 +0900)
committerssum21 <ssumuss@khu.ac.kr>
Mon, 30 Sep 2024 17:25:49 +0000 (02:25 +0900)
Change-Id: I2fdf0ed52480a668af61c2ea6c8b996cdc67ae67
Signed-off-by: ssum21 <ssumuss@khu.ac.kr>
bin/install_kserve.sh

index 0e756c3..94bfdce 100755 (executable)
 
 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() {