From 628fe3c1cabc8866b42c50baab5c557b04cf02c3 Mon Sep 17 00:00:00 2001 From: gurusai-voleti Date: Tue, 20 Oct 2026 05:36:13 +0000 Subject: [PATCH 1/3] Migrate gsutil usage to gcloud storage --- gcloud/README.md | 2 +- gcloud/bin/create-dpgce | 2 +- gcloud/bin/recreate-dpgce | 2 +- gcloud/init/gce-proxy-setup.sh | 4 ++-- gcloud/lib/database/oracle.sh | 4 ++-- .../2026-W11/20260310T222921-review-gpu-custom-image-prep.md | 2 +- spark-tensorflow/doc/tf-serve.md | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcloud/README.md b/gcloud/README.md index e77aec50..5ad0d159 100644 --- a/gcloud/README.md +++ b/gcloud/README.md @@ -40,7 +40,7 @@ These scripts deploy Dataproc clusters in various configurations, supporting bot ## Setup & Configuration 1. **Prerequisites:** - * `gcloud` CLI and `gsutil` + * `gcloud` CLI and `gcloud storage` * `jq` (for JSON parsing) * `sqlite3` (for state cache queries) * `perl` (used in some robust text-manipulation utilities) diff --git a/gcloud/bin/create-dpgce b/gcloud/bin/create-dpgce index 7a3ec570..38e8b265 100755 --- a/gcloud/bin/create-dpgce +++ b/gcloud/bin/create-dpgce @@ -98,7 +98,7 @@ if [[ "${ENABLE_GPU}" == "true" ]]; then TIMESTAMP=$(date +%s) export GPU_INIT_ACTION_URI="gs://${BUCKET}/tmp_init_actions/install_gpu_driver_${TIMESTAMP}.sh" echo "INFO: Uploading local GPU init action to ${GPU_INIT_ACTION_URI}" >&2 - gsutil cp "${DP_EVOLUTION_DIR}/initialization-actions/gpu/install_gpu_driver.sh" "${GPU_INIT_ACTION_URI}" + gcloud storage cp "${DP_EVOLUTION_DIR}/initialization-actions/gpu/install_gpu_driver.sh" "${GPU_INIT_ACTION_URI}" fi if [[ "${IS_CUSTOM}" == "true" ]]; then diff --git a/gcloud/bin/recreate-dpgce b/gcloud/bin/recreate-dpgce index e3472c2d..1a7d9598 100755 --- a/gcloud/bin/recreate-dpgce +++ b/gcloud/bin/recreate-dpgce @@ -132,7 +132,7 @@ if [[ "${ENABLE_GPU}" == "true" ]]; then TIMESTAMP=$(date +%s) export GPU_INIT_ACTION_URI="gs://${BUCKET}/tmp_init_actions/install_gpu_driver_${TIMESTAMP}.sh" echo "INFO: Uploading local GPU init action to ${GPU_INIT_ACTION_URI}" >&2 - gsutil cp "${DP_EVOLUTION_DIR}/initialization-actions/gpu/install_gpu_driver.sh" "${GPU_INIT_ACTION_URI}" + gcloud storage cp "${DP_EVOLUTION_DIR}/initialization-actions/gpu/install_gpu_driver.sh" "${GPU_INIT_ACTION_URI}" fi # --- Source other necessary function files --- diff --git a/gcloud/init/gce-proxy-setup.sh b/gcloud/init/gce-proxy-setup.sh index dd31c15c..4ae660e9 100644 --- a/gcloud/init/gce-proxy-setup.sh +++ b/gcloud/init/gce-proxy-setup.sh @@ -218,14 +218,14 @@ function set_proxy(){ trusted_pem_dir="/usr/local/share/ca-certificates" proxy_ca_pem="${trusted_pem_dir}/proxy_ca.crt" mkdir -p "${trusted_pem_dir}" - gsutil cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; } + gcloud storage cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; } update-ca-certificates trusted_pem_path="/etc/ssl/certs/ca-certificates.crt" elif is_rocky ; then trusted_pem_dir="/etc/pki/ca-trust/source/anchors" proxy_ca_pem="${trusted_pem_dir}/proxy_ca.crt" mkdir -p "${trusted_pem_dir}" - gsutil cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; } + gcloud storage cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; } update-ca-trust trusted_pem_path="/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" fi diff --git a/gcloud/lib/database/oracle.sh b/gcloud/lib/database/oracle.sh index 0065033e..b3ca7bb1 100644 --- a/gcloud/lib/database/oracle.sh +++ b/gcloud/lib/database/oracle.sh @@ -32,7 +32,7 @@ echo "Starting Oracle DB setup..." # sudo yum install -y oracle-database-preinstall-19c # 2. Download Oracle Database Software (e.g., from Oracle website or GCS) -# Example: wget ... or gsutil cp ... +# Example: wget ... or gcloud storage cp ... # 3. Unzip and Run Oracle Installer # Example: unzip ... @@ -60,7 +60,7 @@ EOF fi print_status " Uploading OVA to GCS..." - if run_gcloud "${log_file}" gsutil cp "${REPRO_TMPDIR}/${ova_file}" "${gcs_uri}"; then + if run_gcloud "${log_file}" gcloud storage cp "${REPRO_TMPDIR}/${ova_file}" "${gcs_uri}"; then report_result "Pass" else report_result "Fail" diff --git a/gcloud/work-narrative/2026-W11/20260310T222921-review-gpu-custom-image-prep.md b/gcloud/work-narrative/2026-W11/20260310T222921-review-gpu-custom-image-prep.md index d7876a1c..67205897 100644 --- a/gcloud/work-narrative/2026-W11/20260310T222921-review-gpu-custom-image-prep.md +++ b/gcloud/work-narrative/2026-W11/20260310T222921-review-gpu-custom-image-prep.md @@ -4,7 +4,7 @@ This session focused on preparing for the next phase of testing GPU configurations on Dataproc, specifically within custom images. The key activities included: -1. **Reviewing Recent Code Changes:** Analyzed `tmp/current-change.diff`, noting significant updates to metadata handling in `lib/dataproc/cluster.sh` (using `^|^` separator), new GPU-related metadata, updated machine/accelerator types, and a shift to `gcloud storage` from `gsutil`. +1. **Reviewing Recent Code Changes:** Analyzed `tmp/current-change.diff`, noting significant updates to metadata handling in `lib/dataproc/cluster.sh` (using `^|^` separator), new GPU-related metadata, updated machine/accelerator types, and a shift to `gcloud storage` from `gcloud storage`. 2. **Examining Git History:** Reviewed `git log` output, revealing substantial refactoring efforts around private cluster creation (`lib/dataproc/private-cluster.sh`), extensive updates to `init/gce-proxy-setup.sh` for robust proxy handling, and the introduction of GPU test scripts in the `t/` directory. The README has also been significantly overhauled for clarity. 3. **Consulting Planning Documents:** Reviewed `plan-for-continued-work-2026-01-20.md` and `work-completed-2026-01-20.md` to understand the current goals, which involve testing `install_gpu_driver.sh` as a customization script during custom image creation. diff --git a/spark-tensorflow/doc/tf-serve.md b/spark-tensorflow/doc/tf-serve.md index b6cacc11..77b1aa55 100644 --- a/spark-tensorflow/doc/tf-serve.md +++ b/spark-tensorflow/doc/tf-serve.md @@ -60,7 +60,7 @@ in the [Preprocessing](#preprocessing) section so that the preprocessed data meant for prediction is stored in `$OUTPUT_DIR`. If you used Dataproc to preprocess the data for prediction, `$OUTPUT_DIR` is a Cloud Storage bucket. If not, then you will have to move your data to Cloud Storage to make it available -for batch prediction. You can do so using the [gsutil +for batch prediction. You can do so using the [gcloud storage tool](https://cloud.google.com/storage/docs/gsutil). Once your data is on GCS, please set the `GCS_PATH` environment variable to the From 04163355e85d173d27421bfe5128527d1dfbac46 Mon Sep 17 00:00:00 2001 From: gurusai-voleti Date: Tue, 20 Oct 2026 13:49:29 +0530 Subject: [PATCH 2/3] Update 20260310T222921-review-gpu-custom-image-prep.md --- .../2026-W11/20260310T222921-review-gpu-custom-image-prep.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud/work-narrative/2026-W11/20260310T222921-review-gpu-custom-image-prep.md b/gcloud/work-narrative/2026-W11/20260310T222921-review-gpu-custom-image-prep.md index 67205897..d7876a1c 100644 --- a/gcloud/work-narrative/2026-W11/20260310T222921-review-gpu-custom-image-prep.md +++ b/gcloud/work-narrative/2026-W11/20260310T222921-review-gpu-custom-image-prep.md @@ -4,7 +4,7 @@ This session focused on preparing for the next phase of testing GPU configurations on Dataproc, specifically within custom images. The key activities included: -1. **Reviewing Recent Code Changes:** Analyzed `tmp/current-change.diff`, noting significant updates to metadata handling in `lib/dataproc/cluster.sh` (using `^|^` separator), new GPU-related metadata, updated machine/accelerator types, and a shift to `gcloud storage` from `gcloud storage`. +1. **Reviewing Recent Code Changes:** Analyzed `tmp/current-change.diff`, noting significant updates to metadata handling in `lib/dataproc/cluster.sh` (using `^|^` separator), new GPU-related metadata, updated machine/accelerator types, and a shift to `gcloud storage` from `gsutil`. 2. **Examining Git History:** Reviewed `git log` output, revealing substantial refactoring efforts around private cluster creation (`lib/dataproc/private-cluster.sh`), extensive updates to `init/gce-proxy-setup.sh` for robust proxy handling, and the introduction of GPU test scripts in the `t/` directory. The README has also been significantly overhauled for clarity. 3. **Consulting Planning Documents:** Reviewed `plan-for-continued-work-2026-01-20.md` and `work-completed-2026-01-20.md` to understand the current goals, which involve testing `install_gpu_driver.sh` as a customization script during custom image creation. From 5cb5cbc442af88b5829b10046b12036ec1e27480 Mon Sep 17 00:00:00 2001 From: gurusai-voleti Date: Mon, 2 Nov 2026 10:27:35 +0000 Subject: [PATCH 3/3] Check gcloud SDK version and fall back to gsutil for cp, stat, and rsync --- gcloud/bin/create-dpgce | 2 +- gcloud/bin/recreate-dpgce | 2 +- gcloud/init/gce-proxy-setup.sh | 19 +++++++++++++++++-- gcloud/lib/database/oracle.sh | 2 +- gcloud/lib/script-utils.sh | 21 +++++++++++++++++++++ 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/gcloud/bin/create-dpgce b/gcloud/bin/create-dpgce index 38e8b265..b2479e27 100755 --- a/gcloud/bin/create-dpgce +++ b/gcloud/bin/create-dpgce @@ -98,7 +98,7 @@ if [[ "${ENABLE_GPU}" == "true" ]]; then TIMESTAMP=$(date +%s) export GPU_INIT_ACTION_URI="gs://${BUCKET}/tmp_init_actions/install_gpu_driver_${TIMESTAMP}.sh" echo "INFO: Uploading local GPU init action to ${GPU_INIT_ACTION_URI}" >&2 - gcloud storage cp "${DP_EVOLUTION_DIR}/initialization-actions/gpu/install_gpu_driver.sh" "${GPU_INIT_ACTION_URI}" + "${gsutil_cmd[@]}" cp "${DP_EVOLUTION_DIR}/initialization-actions/gpu/install_gpu_driver.sh" "${GPU_INIT_ACTION_URI}" fi if [[ "${IS_CUSTOM}" == "true" ]]; then diff --git a/gcloud/bin/recreate-dpgce b/gcloud/bin/recreate-dpgce index 1a7d9598..b9c96004 100755 --- a/gcloud/bin/recreate-dpgce +++ b/gcloud/bin/recreate-dpgce @@ -132,7 +132,7 @@ if [[ "${ENABLE_GPU}" == "true" ]]; then TIMESTAMP=$(date +%s) export GPU_INIT_ACTION_URI="gs://${BUCKET}/tmp_init_actions/install_gpu_driver_${TIMESTAMP}.sh" echo "INFO: Uploading local GPU init action to ${GPU_INIT_ACTION_URI}" >&2 - gcloud storage cp "${DP_EVOLUTION_DIR}/initialization-actions/gpu/install_gpu_driver.sh" "${GPU_INIT_ACTION_URI}" + "${gsutil_cmd[@]}" cp "${DP_EVOLUTION_DIR}/initialization-actions/gpu/install_gpu_driver.sh" "${GPU_INIT_ACTION_URI}" fi # --- Source other necessary function files --- diff --git a/gcloud/init/gce-proxy-setup.sh b/gcloud/init/gce-proxy-setup.sh index 4ae660e9..43dfbd08 100644 --- a/gcloud/init/gce-proxy-setup.sh +++ b/gcloud/init/gce-proxy-setup.sh @@ -56,10 +56,25 @@ function is_rocky() { [[ "$(os_id)" == "rocky" ]] ; } # --- End OS Detection Helpers --- # --- Version Comparison Helpers --- +function version_ge(){ [[ "$1" = "$(echo -e "$1\n$2"|sort -V|tail -n1)" ]]; } +function version_gt(){ [[ "$1" = "$2" ]] && return 1 || version_ge "$1" "$2"; } function version_le(){ [[ "$1" = "$(echo -e "$1\n$2"|sort -V|head -n1)" ]]; } function version_lt(){ [[ "$1" = "$2" ]] && return 1 || version_le "$1" "$2"; } # --- End Version Comparison Helpers --- +# With the 402.0.0 release of gcloud sdk, `gcloud storage` can be +# used as a more performant replacement for `gsutil` +gcloud_sdk_version="$(gcloud --version 2>/dev/null | awk -F'SDK ' '/Google Cloud SDK/ {print $2}' || echo '0.0.0')" +if [[ -z "${gcloud_sdk_version}" ]] || version_lt "${gcloud_sdk_version}" "402.0.0" ; then + gsutil_cmd=("gsutil" "-o" "GSUtil:check_hashes=never") + gsutil_stat_cmd=("gsutil" "stat") + rsync_cmd=("gsutil" "-o" "GSUtil:check_hashes=never" "-m" "rsync") +else + gsutil_cmd=("gcloud" "storage") + gsutil_stat_cmd=("gcloud" "storage" "objects" "describe") + rsync_cmd=("gcloud" "storage" "rsync") +fi + function execute_with_retries() { local -r cmd="$*" local retries=3 @@ -218,14 +233,14 @@ function set_proxy(){ trusted_pem_dir="/usr/local/share/ca-certificates" proxy_ca_pem="${trusted_pem_dir}/proxy_ca.crt" mkdir -p "${trusted_pem_dir}" - gcloud storage cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; } + "${gsutil_cmd[@]}" cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; } update-ca-certificates trusted_pem_path="/etc/ssl/certs/ca-certificates.crt" elif is_rocky ; then trusted_pem_dir="/etc/pki/ca-trust/source/anchors" proxy_ca_pem="${trusted_pem_dir}/proxy_ca.crt" mkdir -p "${trusted_pem_dir}" - gcloud storage cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; } + "${gsutil_cmd[@]}" cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; } update-ca-trust trusted_pem_path="/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" fi diff --git a/gcloud/lib/database/oracle.sh b/gcloud/lib/database/oracle.sh index b3ca7bb1..c02d0a3e 100644 --- a/gcloud/lib/database/oracle.sh +++ b/gcloud/lib/database/oracle.sh @@ -60,7 +60,7 @@ EOF fi print_status " Uploading OVA to GCS..." - if run_gcloud "${log_file}" gcloud storage cp "${REPRO_TMPDIR}/${ova_file}" "${gcs_uri}"; then + if run_gcloud "${log_file}" "${gsutil_cmd[@]}" cp "${REPRO_TMPDIR}/${ova_file}" "${gcs_uri}"; then report_result "Pass" else report_result "Fail" diff --git a/gcloud/lib/script-utils.sh b/gcloud/lib/script-utils.sh index 4c60f637..a35b8b0f 100644 --- a/gcloud/lib/script-utils.sh +++ b/gcloud/lib/script-utils.sh @@ -6,6 +6,27 @@ YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color +# --- Version Comparison Helpers --- +function version_ge(){ [[ "$1" = "$(echo -e "$1\n$2"|sort -V|tail -n1)" ]]; } +function version_gt(){ [[ "$1" = "$2" ]] && return 1 || version_ge "$1" "$2"; } +function version_le(){ [[ "$1" = "$(echo -e "$1\n$2"|sort -V|head -n1)" ]]; } +function version_lt(){ [[ "$1" = "$2" ]] && return 1 || version_le "$1" "$2"; } +export -f version_ge version_gt version_le version_lt +# --- End Version Comparison Helpers --- + +# With the 402.0.0 release of gcloud sdk, `gcloud storage` can be +# used as a more performant replacement for `gsutil` +gcloud_sdk_version="$(gcloud --version 2>/dev/null | awk -F'SDK ' '/Google Cloud SDK/ {print $2}' || echo '0.0.0')" +if [[ -z "${gcloud_sdk_version}" ]] || version_lt "${gcloud_sdk_version}" "402.0.0" ; then + gsutil_cmd=("gsutil" "-o" "GSUtil:check_hashes=never") + gsutil_stat_cmd=("gsutil" "stat") + rsync_cmd=("gsutil" "-o" "GSUtil:check_hashes=never" "-m" "rsync") +else + gsutil_cmd=("gcloud" "storage") + gsutil_stat_cmd=("gcloud" "storage" "objects" "describe") + rsync_cmd=("gcloud" "storage" "rsync") +fi + # Usage: print_status "Message..." function print_status() { local message="$1"