Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizing memory and cpu specifications for VMs #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 45 additions & 12 deletions manual-workflows/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ arguments:
--server-account Email identifier of service account used by main Cromwell instance
--cromwell-conf Local path to configuration file for Cromwell server. DEFAULT \$SRC_DIR/cromwell.conf
--workflow-options Local path to workflow_options.json. DEFAULT \$SRC_DIR/workflow_options.json
--machine-type GCP machine type for the instance. DEFAULT e2-standard-2
--machine-type GCP machine type for the instance. DEFAULT e2-standard-2.
This flag is overridden if --custom-cpu and --custom-memory are specified.
Check gcloud documentations for further details.
--zone DEFAULT us-central1-c. For options, visit: https://cloud.google.com/compute/docs/regions-zones

Additional arguments are passed directly to gsutil compute instances
Expand Down Expand Up @@ -97,15 +99,29 @@ while test $# -gt 0; do
shift
fi
;;
--custom-cpu*)
if [ ! "$2" ]; then
die 'ERROR: "--custom-cpu" requires an argument'
else
CPU=$2
shift
fi
;;
--custom-memory*)
if [ ! "$2" ]; then
die 'ERROR: "--custome-memory" requires an argument'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
die 'ERROR: "--custome-memory" requires an argument'
die 'ERROR: "--custom-memory" requires an argument'

else
MEM=$2
shift
fi
;;
*)
break
;;
esac
shift
done

MACHINE_TYPE=${MACHINE_TYPE:-"e2-standard-2"}

[ -z $SERVER_ACCOUNT ] && die "Missing argument --server-account"
[ -z $PROJECT ] && die "Missing argument --project"
[ -z $CROMWELL_CONF ] && CROMWELL_CONF="$SRC_DIR/cromwell.conf"
Expand All @@ -132,18 +148,35 @@ EOF
exit 1
fi

MACHINE_TYPE=${MACHINE_TYPE:-"e2-standard-2"}

param=(
--project $PROJECT
--image-family debian-11
--image-project debian-cloud
--zone $ZONE
--service-account=$SERVER_ACCOUNT
--scopes=cloud-platform
--network=$NETWORK
--subnet=$SUBNET
--metadata=cromwell-version=71
--metadata-from-file=startup-script=$SRC_DIR/server_startup.py,cromwell-conf=$CROMWELL_CONF,helpers-sh=$SRC_DIR/helpers.sh,cromwell-service=$SRC_DIR/cromwell.service,workflow-options=$WORKFLOW_OPTIONS,persist-artifacts=$SRC_DIR/../scripts/persist_artifacts.py
)

# optionally add either machine type when neither --custom-memory
# nor --custom-cpu are specified
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be nitpicky about this comment: we're adding machine type when either --custom-memory or --custom cpu are not specified as well as when neither are specified. (You might say it "add machine type unless --custom-memory and --custom-cpu are specified".)

I could see having it throw an error if only one of the two is specified though.

if [ -z "$MEM" ] || [ -z "$CPU" ]; then
echo "$MEM BLAAAAH $CPU"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like set -x for debugging shell scripts! (echo works too 🙂--just a reminder to remove this line before we merge it in.)

param+=(--machine-type=$MACHINE_TYPE)
else
param+=(--custom-memory $MEM)
param+=(--custom-cpu $CPU)
fi

# $@ indicates the ability to add any of the other flags that come with gcloud compute instances creat
# for a full account, visit https://cloud.google.com/sdk/gcloud/reference/compute/instances/create
gcloud compute instances create $INSTANCE_NAME \
--project $PROJECT \
--image-family debian-11 \
--image-project debian-cloud \
--zone $ZONE \
--machine-type=$MACHINE_TYPE \
--service-account=$SERVER_ACCOUNT --scopes=cloud-platform \
--network=$NETWORK --subnet=$SUBNET \
--metadata=cromwell-version=71 \
--metadata-from-file=startup-script=$SRC_DIR/server_startup.py,cromwell-conf=$CROMWELL_CONF,helpers-sh=$SRC_DIR/helpers.sh,cromwell-service=$SRC_DIR/cromwell.service,workflow-options=$WORKFLOW_OPTIONS,persist-artifacts=$SRC_DIR/../scripts/persist_artifacts.py \
${param[@]} \
$@

cat <<EOF
Expand Down