From 975715da5b2c1d31be466b17bc7a25c1999ed28d Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 8 Jan 2025 13:55:47 +0100 Subject: Use params instead of `read` function --- scripts/06-dataproc-update-cluster.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'scripts/06-dataproc-update-cluster.sh') diff --git a/scripts/06-dataproc-update-cluster.sh b/scripts/06-dataproc-update-cluster.sh index cb098ef..8714e7d 100755 --- a/scripts/06-dataproc-update-cluster.sh +++ b/scripts/06-dataproc-update-cluster.sh @@ -2,18 +2,30 @@ set -eu -if [ "$#" -ne 1 ]; then - echo "Usage: 'sh ${PWD}/$0 '" +if [ "$#" -ne 3 ]; then + echo "Usage: 'sh ${PWD}/$0 '" exit 1 fi NUM_WORKERS="$1" +MASTER_MACHINE="$2" +WORKER_MACHINE="$3" if [ "$NUM_WORKERS" -lt 1 ] || [ "$NUM_WORKERS" -gt 4 ]; then echo " must be 1, 2, 3, or 4" exit 1 fi +if [ -z "$MASTER_MACHINE" ]; then + echo "Error: Master machine type cannot be empty." + exit 1 +fi + +if [ -z "$WORKER_MACHINE" ]; then + echo "Error: Worker machine type cannot be empty." + exit 1 +fi + # Handle single worker case if [ "$NUM_WORKERS" -eq 1 ]; then @@ -23,7 +35,7 @@ if [ "$NUM_WORKERS" -eq 1 ]; then fi echo ">>>> Creating a new cluster with 1 worker..." - eval "scripts/04-dataproc-create-cluster.sh 1" + eval "scripts/04-dataproc-create-cluster.sh 1 ${MASTER_MACHINE} ${WORKER_MACHINE}" else if ! gcloud dataproc clusters update "${CLUSTER}" \ --project="${PROJECT}" --region="${REGION}" \ @@ -32,7 +44,7 @@ else gcloud dataproc clusters delete "${CLUSTER}" --region="${REGION}" --quiet echo ">>>> Creating a new cluster with ${NUM_WORKERS} workers..." - eval "scripts/04-dataproc-create-cluster.sh ${NUM_WORKERS}" + eval "scripts/04-dataproc-create-cluster.sh ${NUM_WORKERS} ${MASTER_MACHINE} ${WORKER_MACHINE}" else echo ">>>> Successfully updated the cluster to ${NUM_WORKERS} workers." fi -- cgit v1.2.3-71-g8e6c