diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index cdcccae..7a1c5b0 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -41,10 +41,7 @@ RUN echo 'export PATH="$PATH:$EDA_PLAYGROUND_DIR/tools"' >> /etc/zsh/zshrc USER vscode -# patching kpt version to beta59 to see if it is better in handling sporadic k8s -# issues in GH codespaces where beta57 is stuck in reading the reconciled resources. -RUN git clone --depth 1 "https://github.com/$EDA_PLAYGROUND_REPO" $EDA_PLAYGROUND_DIR && cd $EDA_PLAYGROUND_DIR && \ - sed -i 's/KPT_VERSION ?= v1.0.0-beta.57/KPT_VERSION ?= v1.0.0-beta.59/' Makefile && \ +RUN git clone --depth 1 --branch v0.0.1 "https://github.com/$EDA_PLAYGROUND_REPO" $EDA_PLAYGROUND_DIR && cd $EDA_PLAYGROUND_DIR && \ make download-tools RUN curl -o $HOME/.bundle.yaml "https://raw.githubusercontent.com/nokia-eda/edaadm/refs/heads/main/bundles/eda-bundle-core-$EDA_VERSION.yaml" && \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9a4c4a2..27ce73a 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:kaelem-test", "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": { "version": "latest", @@ -10,17 +10,19 @@ "customizations": { "vscode": { "extensions": [ - // "ms-kubernetes-tools.vscode-kubernetes-tools", + "entuent.fira-code-nerd-font", + "ms-kubernetes-tools.vscode-kubernetes-tools", "eda-labs.vscode-eda" ], "settings": { + "chat.disableAIFeatures": true, "terminal.integrated.defaultProfile.linux": "zsh", "terminal.integrated.profiles.linux": { "zsh": { "path": "/bin/zsh" } }, - "terminal.integrated.fontFamily": "'JetBrainsMono Nerd Font', 'JetBrainsMono NF', monospace", + "terminal.integrated.fontFamily": "JetBrainsMono Nerd Font, JetBrainsMono, JetBrains Mono, fira-code-nerd, Fira Code Nerd Font, FiraCode Nerd Font, Fira Code, Consolas, Hasklig, Menlo, Monaco, 'Courier New', monospace", "vscode-eda.edaTargets": { "https://127.0.0.1:9443": { "edaUsername": "admin", @@ -39,7 +41,10 @@ "postCreateCommand": ".devcontainer/postCreate.sh", "postAttachCommand": ".devcontainer/postAttach.sh", "containerEnv": { - "EDA_PORT": "9443" + "EDA_PORT": "9443", + "TRY_EDA_OVERRIDES_FILE": "/workspaces/codespaces/.devcontainer/overrides.mk", + "TRY_EDA_KPT_SETTERS_FILE": "/eda-codespaces/codespaces-4vcpu-kpt-setters.yaml", + "NUM_CONCURRENT_IMG_PREPULLS": "8" }, "forwardPorts": [ 9443 diff --git a/.devcontainer/onCreate.sh b/.devcontainer/onCreate.sh index 1b83790..de91b6d 100755 --- a/.devcontainer/onCreate.sh +++ b/.devcontainer/onCreate.sh @@ -7,8 +7,6 @@ free -m sudo sysctl -w fs.inotify.max_user_watches=1048576 sudo sysctl -w fs.inotify.max_user_instances=512 -TOKEN=$($EDA_PLAYGROUND_DIR/tools/yq -o=json '.assets.registries[].auth' $HOME/.bundle.yaml | jq -r '(reduce range(.extraEncodeCount + 1) as $_ (.username; @base64d)) + ":" + (reduce range(.extraEncodeCount + 1) as $_ (.password; @base64d))') - ensure-docker-is-ready k3d cluster create eda-demo \ @@ -17,5 +15,3 @@ k3d cluster create eda-demo \ --k3s-arg "--disable=servicelb@server:*" \ --volume "$HOME/.images.txt:/opt/images.txt@server:*" \ --no-lb - -docker exec -d k3d-eda-demo-server-0 sh -c "cat /opt/images.txt | xargs -P 4 -I {} crictl pull --creds $TOKEN {}" \ No newline at end of file diff --git a/.devcontainer/overrides.mk b/.devcontainer/overrides.mk new file mode 100644 index 0000000..e3d01cf --- /dev/null +++ b/.devcontainer/overrides.mk @@ -0,0 +1,33 @@ +KPT_RETRY ?= 5 +KPT_LIVE_APPLY_ARGS += --reconcile-timeout=3m + +# Override the INSTALL_KPT_PACKAGE macro +# +# Set the --reconcile-timeout flag so that KPT doesn't just hang for a while +# then the updated macro below, will handle the exit by retrying the kpt live apply +# until we hit the retry limit. +define INSTALL_KPT_PACKAGE + { \ + echo -e "--> INSTALL: [\033[1;34m$2\033[0m] - Applying kpt package" ;\ + pushd $1 &>/dev/null || (echo "[ERROR]: Failed to switch cwd to $2" && exit 1) ;\ + if [[ ! -f resourcegroup.yaml ]] || [[ $(KPT_LIVE_INIT_FORCE) -eq 1 ]]; then \ + $(KPT) live init --force 2>&1 | $(INDENT_OUT) ;\ + else \ + echo -e "--> INSTALL: [\033[1;34m$2\033[0m] - Resource group found, don't re-init this package" ;\ + fi ;\ + for attempt in $$(seq 1 $(KPT_RETRY)); do \ + echo -e "--> INSTALL: [\033[1;34m$2\033[0m] - Attempt $$attempt/$(KPT_RETRY)" ;\ + if $(KPT) live apply $(KPT_LIVE_APPLY_ARGS) 2>&1 | $(INDENT_OUT); then \ + break ;\ + fi ;\ + if [[ $$attempt -eq $(KPT_RETRY) ]]; then \ + echo -e "--> INSTALL: [\033[1;31m$2\033[0m] - Failed after $(KPT_RETRY) attempts" ;\ + exit 1 ;\ + fi ;\ + echo -e "--> INSTALL: [\033[1;33m$2\033[0m] - Attempt $$attempt failed, retrying..." ;\ + sleep 2 ;\ + done ;\ + popd &>/dev/null || (echo "[ERROR]: Failed to switch back from $2" && exit 1) ;\ + echo -e "--> INSTALL: [\033[0;32m$2\033[0m] - Applied and reconciled package" ;\ + } +endef diff --git a/.devcontainer/postCreate.sh b/.devcontainer/postCreate.sh index 0f2a018..b32d69e 100755 --- a/.devcontainer/postCreate.sh +++ b/.devcontainer/postCreate.sh @@ -5,4 +5,8 @@ cd $EDA_PLAYGROUND_DIR ensure-docker-is-ready -make try-eda NO_KIND=yes NO_LB=yes KPT_SETTERS_FILE=/eda-codespaces/codespaces-4vcpu-kpt-setters.yaml \ No newline at end of file + +TOKEN=$($EDA_PLAYGROUND_DIR/tools/yq -o=json '.assets.registries[].auth' $HOME/.bundle.yaml | jq -r '(reduce range(.extraEncodeCount + 1) as $_ (.username; @base64d)) + ":" + (reduce range(.extraEncodeCount + 1) as $_ (.password; @base64d))') +docker exec k3d-eda-demo-server-0 sh -c "cat /opt/images.txt | xargs -P $NUM_CONCURRENT_IMG_PREPULLS -I {} crictl pull --creds $TOKEN {}" + +make -f Makefile -f $TRY_EDA_OVERRIDES_FILE try-eda NO_KIND=yes NO_LB=yes KPT_SETTERS_FILE=$TRY_EDA_KPT_SETTERS_FILE \ No newline at end of file diff --git a/.devcontainer/shell/starship.toml b/.devcontainer/shell/starship.toml index af918b0..9bfd270 100644 --- a/.devcontainer/shell/starship.toml +++ b/.devcontainer/shell/starship.toml @@ -1,39 +1,29 @@ # Get editor completions based on the config schema "$schema" = 'https://starship.rs/config-schema.json' - # Inserts a blank line between shell prompts add_newline = true [git_branch] -symbol = " " format = '· [$symbol$branch(:$remote_branch)]($style) ' [git_commit] tag_disabled = false -tag_symbol = "  " [golang] -symbol = ' ' format = '· [$symbol($version )]($style)' [package] format = '· [$symbol$version]($style) ' -symbol = "󰏗 " [python] format = '· [${symbol}${pyenv_prefix}(${version} )(\($virtualenv\) )]($style)' -symbol = " " [kubernetes] -disabled = false -symbol = "󱃾 " +disabled = true [container] disabled = true [direnv] disabled = true - -[hostname] -ssh_symbol = " " \ No newline at end of file