From aa3dc15d0cc821a81769da351e57ccec35daba24 Mon Sep 17 00:00:00 2001 From: Yu Hu Date: Mon, 10 Mar 2025 14:27:47 -0400 Subject: [PATCH 01/11] fix app proxy for non-google --- startupscript/dataproc/startup.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/startupscript/dataproc/startup.sh b/startupscript/dataproc/startup.sh index 9c3c0ca2..d01f912d 100644 --- a/startupscript/dataproc/startup.sh +++ b/startupscript/dataproc/startup.sh @@ -197,21 +197,30 @@ function set_guest_attributes() { # Map the CLI server to appropriate service path function get_service_url() { case "$1" in - "verily") echo "https://terra-$2.api.verily.com" ;; - "verily-devel") echo "https://terra-devel-$2.api.verily.com" ;; - "verily-autopush") echo "https://terra-autopush-$2.api.verily.com" ;; - "verily-staging") echo "https://terra-staging-$2.api.verily.com" ;; - "verily-preprod") echo "https://terra-preprod-$2.api.verily.com" ;; + "verily") echo "https://workbench.verily.com/api/$2" ;; "dev-stable") echo "https://workbench-dev.verily.com/api/$2" ;; "dev-unstable") echo "https://workbench-dev-unstable.verily.com/api/$2" ;; "test") echo "https://workbench-test.verily.com/api/$2" ;; "staging") echo "https://workbench-staging.verily.com/api/$2" ;; - "prod") echo "https://workbench-prod.verily.com/api/$2" ;; + "prod") echo "https://workbench.verily.com/api/$2" ;; *) return 1 ;; esac } readonly -f get_service_url +function get_app_proxy_url() { + local env=$1 + case "$env" in + verily) + env="prod" + ;; + dev-stable) + env="dev" + ;; + esac + echo "https://workbench-app-${env}.verily.com" +} + # If the script exits without error let the UI know it completed successfully # Otherwise if an error occurred write the line and command that failed to guest attributes. function exit_handler { @@ -798,7 +807,7 @@ chown "${LOGIN_USER}:${LOGIN_USER}" "${USER_BASH_PROFILE}" # TODO(BENCH-2612): use workbench CLI instead to get user profile. IS_NON_GOOGLE_ACCOUNT="$(curl "${USER_SERVICE_URL}/api/profile?path=non_google_account" \ - -H "accept: application/json" -H "Authorization: Bearer $(gcloud auth print-access-token)" \ + -H "accept: application/json" -H "Authorization: Bearer $(wb auth print-access-token)" \ | jq '.value')" readonly IS_NON_GOOGLE_ACCOUNT @@ -808,12 +817,12 @@ if [[ "${IS_NON_GOOGLE_ACCOUNT}" == "true" ]]; then # Start workbench app proxy agent ################################### - APP_PROXY="$(get_metadata_value "instance/attributes/terra-app-proxy")" + APP_PROXY="$(get_app_proxy_url "${TERRA_SERVER}")" readonly APP_PROXY if [[ -n "${APP_PROXY}" ]]; then emit "Using custom Proxy Agent" RESOURCE_ID="$(get_metadata_value "instance/attributes/terra-resource-id")" - NEW_PROXY="https://${APP_PROXY}" + NEW_PROXY="${APP_PROXY}" NEW_PROXY_URL="${RESOURCE_ID}.${APP_PROXY}" readonly RESOURCE_ID readonly NEW_PROXY From cdd8c53f422c7988ca7b96e499f53ed3e4840bff Mon Sep 17 00:00:00 2001 From: Yu Hu Date: Mon, 10 Mar 2025 14:30:33 -0400 Subject: [PATCH 02/11] add comment --- startupscript/dataproc/startup.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/startupscript/dataproc/startup.sh b/startupscript/dataproc/startup.sh index d01f912d..3f4386cf 100644 --- a/startupscript/dataproc/startup.sh +++ b/startupscript/dataproc/startup.sh @@ -208,18 +208,20 @@ function get_service_url() { } readonly -f get_service_url +# Get the app proxy url for the env. function get_app_proxy_url() { - local env=$1 - case "$env" in - verily) + local env="${1}" + case "${env}" in + "verily") env="prod" ;; - dev-stable) + "dev-stable") env="dev" ;; esac echo "https://workbench-app-${env}.verily.com" } +readonly -f get_app_proxy_url # If the script exits without error let the UI know it completed successfully # Otherwise if an error occurred write the line and command that failed to guest attributes. From 06ae86c03ee8a9cc85e6264701e02dd2d403af80 Mon Sep 17 00:00:00 2001 From: Yu Hu <93544261+yuhuyoyo@users.noreply.github.com> Date: Mon, 10 Mar 2025 16:02:21 -0400 Subject: [PATCH 03/11] Update startup.sh --- startupscript/dataproc/startup.sh | 32 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/startupscript/dataproc/startup.sh b/startupscript/dataproc/startup.sh index 3f4386cf..618af140 100644 --- a/startupscript/dataproc/startup.sh +++ b/startupscript/dataproc/startup.sh @@ -209,7 +209,7 @@ function get_service_url() { readonly -f get_service_url # Get the app proxy url for the env. -function get_app_proxy_url() { +function get_app_proxy_uri() { local env="${1}" case "${env}" in "verily") @@ -221,7 +221,22 @@ function get_app_proxy_url() { esac echo "https://workbench-app-${env}.verily.com" } -readonly -f get_app_proxy_url +readonly -f get_app_proxy_uri + +# Get workbench frontend url +function get_ui_uri() { + local env="${1}" + if [[ "${env}" == "verily" || "${env}" == "prod" ]]; then + echo "https://workbench.verily.com" + elif [[ "${env}" == "dev-stable" ]]; then + echo "https://workbench-dev.verily.com" + else [[ "${env}" == "dev-unstable" || "${env}" == "test" || "${env}" == "staging" ]] + echo "https://workbench-${env}.verily.com" + else + echo "https://workbench.verily.com" + fi +} +readonly -f get_ui_uri # If the script exits without error let the UI know it completed successfully # Otherwise if an error occurred write the line and command that failed to guest attributes. @@ -1065,18 +1080,7 @@ fi # Configure the original (non-workbench) proxy agent ###################################################### emit "Configuring the original Proxy Agent banner for Google account..." - # Map the CLI server to the appropriate UI url - if [[ "${TERRA_SERVER}" == *"verily"* ]]; then - # Map the CLI server to the appropriate UI url - if [[ "${TERRA_SERVER}" == "verily" ]]; then - UI_BASE_URL="workbench.verily.com" - else - UI_BASE_URL="${TERRA_SERVER/verily/terra}-ui-terra.api.verily.com" - fi - else - >&2 echo "ERROR: ${TERRA_SERVER} is not a known verily server." - exit 1 - fi + UI_BASE_URL=$(get_ui_url "${TERRA_SERVER}") readonly UI_BASE_URL # The banner.html file contains