diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4ffd8cc..a244bb6 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "Nokia EDA in GitHub Codespaces", - "image": "ghcr.io/eda-labs/codespaces/base:main", + "image": "ghcr.io/eda-labs/codespaces/base:logging-and-other", "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": { "version": "latest", diff --git a/.devcontainer/onCreate.sh b/.devcontainer/onCreate.sh index 461c157..795367b 100755 --- a/.devcontainer/onCreate.sh +++ b/.devcontainer/onCreate.sh @@ -1,15 +1,27 @@ #!/bin/bash source .devcontainer/utils.sh -echo "System has $(nproc) CPUs" -free -m +dump_system_info + +log "Waiting for docker" +T_START=$(date +%s) ensure-docker-is-ready +T_END=$(date +%s) +log "Docker is ready. Took $((T_END-T_START)) seconds." + +log "Creating k3d cluster" +T_START=$(date +%s) + # start the k3d cluster k3d cluster create eda-demo \ --image rancher/k3s:v1.34.1-k3s1 \ --k3s-arg "--disable=traefik@server:*" \ --volume "$HOME/.images.txt:/opt/images.txt@server:*" \ --port "9443:443" \ - --port "9400-9410:9400-9410" \ No newline at end of file + --port "9400-9410:9400-9410" + +T_END=$(date +%s) +log "K3d cluster is ready. Took $((T_END-T_START)) seconds." + diff --git a/.devcontainer/postAttach.sh b/.devcontainer/postAttach.sh index ed1d11d..16427f8 100755 --- a/.devcontainer/postAttach.sh +++ b/.devcontainer/postAttach.sh @@ -1,5 +1,8 @@ #!/bin/bash +source .devcontainer/utils.sh +if check_eda_api_reachability; then + clear printf " \033[38;2;255;124;88m⢀\033[38;2;255;218;152m⢀\033[38;2;255;115;123m⡄\033[38;2;255;197;123m⣠\033[38;2;255;179;106m⣦\033[38;2;252;111;48m⣴\033[38;2;255;195;123m⣎\033[38;2;255;197;129m⣤\033[38;2;255;197;128m⠖\033[38;2;255;170;142m⢀\033[38;2;255;136;135m⡀\033[0m \033[0m \033[38;2;255;167;7m⢠\033[38;2;252;185;65m⣤\033[38;2;253;143;93m⣿\033[38;2;252;195;143m⣿\033[38;2;246;128;79m⣿\033[38;2;229;121;83m⣿\033[38;2;244;150;123m⣿\033[38;2;244;164;137m⣿\033[38;2;243;170;132m⣿\033[38;2;253;183;152m⣶\033[38;2;255;162;126m⣿\033[38;2;255;81;63m⣯\033[38;2;255;131;41m⣴\033[38;2;254;122;52m⡶\033[38;2;255;75;14m⠂\033[0m \033[0m @@ -12,5 +15,9 @@ \033[38;2;136;239;251m⠭\033[38;2;98;228;253m⢿\033[38;2;40;200;254m⣿\033[38;2;52;178;245m⣿\033[38;2;6;82;178m⣿\033[38;2;26;44;115m⣿\033[38;2;50;37;110m⣿\033[38;2;30;4;41m⣿\033[38;2;133;11;57m⣿\033[38;2;12;20;68m⠋\033[38;2;17;0;32m⡏\033[38;2;16;0;30m⠈\033[0m \033[0m \033[38;2;109;240;255m⠉\033[38;2;105;231;245m⠛\033[38;2;24;75;129m⠉\033[38;2;44;12;58m⠙\033[38;2;55;26;87m⠋\033[38;2;15;0;29m⠘\033[38;2;16;0;31m⠁\033[38;2;16;0;29m⠉\033[0m \033[0m " -echo " - ⚡ EDA UI: https://${CODESPACE_NAME}-${EDA_PORT}.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" \ No newline at end of file + echo " + ⚡ EDA UI: https://${CODESPACE_NAME}-${EDA_PORT}.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" +else + log "Unable to reach EDA API server. Dumping system info" + dump_system_info +fi \ No newline at end of file diff --git a/.devcontainer/postCreate.sh b/.devcontainer/postCreate.sh index df64d97..6256e8b 100755 --- a/.devcontainer/postCreate.sh +++ b/.devcontainer/postCreate.sh @@ -9,9 +9,20 @@ prefix=$(printf '%s' 'Z2hwCg==' | base64 -d) suffix=$(printf '%s' "$encoded" | base64 -d | cut -c 4- | tr -d '\n') TOKEN="${prefix}${suffix}" +log "Starting image prepull" +T_START=$(date +%s) # preload images into the cluster from the EDA core list # to reduce the number of jobs: PARALLEL_JOBS=$(($(nproc) - 1)) PARALLEL_JOBS=$(nproc) docker exec k3d-eda-demo-server-0 sh -c "cat /opt/images.txt | xargs -P $PARALLEL_JOBS -I {} crictl pull --creds nokia-eda-bot:$TOKEN {}" +T_END=$(date +%s) +log "Images pulled. Took $((T_END-T_START)) seconds." + +log "Starting TRY EDA" +T_START=$(date +%s) + make -f Makefile -f $TRY_EDA_OVERRIDES_FILE try-eda NO_KIND=yes NO_LB=yes KPT_SETTERS_FILE=$TRY_EDA_KPT_SETTERS_FILE + +T_END=$(date +%s) +log "TRY EDA done. Took $((T_END-T_START)) seconds." \ No newline at end of file diff --git a/.devcontainer/utils.sh b/.devcontainer/utils.sh index db3cac8..0a0aee1 100644 --- a/.devcontainer/utils.sh +++ b/.devcontainer/utils.sh @@ -6,4 +6,28 @@ function ensure-docker-is-ready { sleep 1 done echo "Docker is ready" +} + +function log { + local msg="${1:-}" + echo "[$(date '+%Y-%m-%d %H:%M:%S')] $msg" +} + +function check_eda_api_reachability { + log "Checking EDA API reachability" + curl -vkf --retry 3 "https://127.0.0.1:$EDA_PORT" -o /dev/null +} + +function dump_system_info { + log "SYSTEM INFO: nproc" + echo "System has $(nproc) CPUs" + + log "MEMORY: free -m" + free -m + + log "DISK: df -h" + df -h + + log "DISK: lsblk" + lsblk } \ No newline at end of file