Skip to content

Commit

Permalink
Merge #95193
Browse files Browse the repository at this point in the history
95193: gceworker: add created-by label to new gceworker VMs r=rail a=jlinder

We want to be able to tell who created a given gceworker VM. Normally, people follow a good naming practice for their VMs. But sometime it's not clear.

This commit adds the `created-by` label to new VMs and sets the value as the email address (with a few tweaks) on the GCP account that is used to create the VM. This will make it easy know who created the VM.

Epic: none
Release note: none

Co-authored-by: James H. Linder <[email protected]>
  • Loading branch information
craig[bot] and jlinder committed Jan 13, 2023
2 parents 59e7cab + e865d91 commit 446bf30
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/gceworker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ case "${cmd}" in
read COCKROACH_DEV_LICENSE
fi

gsuite_account_for_label="$(gcloud auth list | \
grep '^\*' | \
sed -e 's/\* *//' -e 's/@/__at__/g' -e 's/\./__dot__/g'\
)"
gcloud compute instances \
create "${NAME}" \
--machine-type "n2-custom-24-32768" \
Expand All @@ -44,7 +48,8 @@ case "${cmd}" in
--boot-disk-size "100" \
--boot-disk-type "pd-ssd" \
--boot-disk-device-name "${NAME}" \
--scopes "cloud-platform"
--scopes "cloud-platform" \
--labels "created-by=${gsuite_account_for_label:0:63}"
gcloud compute firewall-rules create "${NAME}-mosh" --allow udp:60000-61000

# wait a bit to let gcloud create the instance before retrying
Expand Down

0 comments on commit 446bf30

Please sign in to comment.