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

Conversation

Layth17
Copy link
Member

@Layth17 Layth17 commented Mar 7, 2023

  • Order matters!
    bash start.sh $GCS_INSTANCE_NAME --server-account $GCS_SERVICE_ACCOUNT --project $GCS_PROJECT --custom-cpu 10 --custom-memory 64G --boot-disk-size=200GB is ok .... but bash start.sh $GCS_INSTANCE_NAME --server-account $GCS_SERVICE_ACCOUNT --project $GCS_PROJECT --boot-disk-size=200GB --custom-cpu 10 --custom-memory 64G is not

because boot-disk-size is a param taken in through the @ and at that point MEM and CPU weren't specified so MACHINE_TYPE was added by default to the list of params.

In other words, set the flags that start.sh ask for first then add flags accepted by GCP afterwards.

I do not think this is new/unique to this case. This is probably just a new finding for me.

@Layth17
Copy link
Member Author

Layth17 commented Mar 7, 2023

rework* of parameters

@Layth17 Layth17 linked an issue Mar 7, 2023 that may be closed by this pull request
@Layth17
Copy link
Member Author

Layth17 commented Mar 27, 2023

if MACHINE_TYPE is not specified by user then it is defaulted to e2-standard-2

if either MEM or CPU are empty, then --machine-type=$MACHINE_TYPE is added to the list of params.

@Layth17 Layth17 marked this pull request as ready for review March 27, 2023 23:39
@Layth17 Layth17 requested a review from tmooney March 27, 2023 23:39
Copy link
Member

@tmooney tmooney left a comment

Choose a reason for hiding this comment

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

Generally makes sense to me!

;;
--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'

# optionally add either machine type when neither --custom-memory
# nor --custom-cpu are specified
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.)

)

# 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Customizing VM's CPU/RAM instead of setting --machine-type
2 participants