Merge ~kajiya/+git/next-demo:reducing-times into ~kajiya/+git/next-demo:main

Proposed by Chloé Smith
Status: Merged
Merged at revision: ac446f601f748089616c5c3a10d45b8a7075dd72
Proposed branch: ~kajiya/+git/next-demo:reducing-times
Merge into: ~kajiya/+git/next-demo:main
Diff against target: 50 lines (+13/-5)
1 file modified
main.sh (+13/-5)
Reviewer Review Type Date Requested Status
Ankush Pathak (community) Approve
Review via email: mp+463705@code.launchpad.net

Commit message

Reduce the time the demo runs for

* Refactor to make the deletion a separate function
* Push the above function into the background after it's run
* Remove `ros`-* installation from the startup-script (no ESM updates yet)
* Use the latest focal image instead so there's less non-ESM updates

To post a comment you must log in.
Revision history for this message
Ankush Pathak (ankushpathak) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/main.sh b/main.sh
2index cbf41e4..4557f81 100755
3--- a/main.sh
4+++ b/main.sh
5@@ -1,8 +1,7 @@
6 #!/bin/bash
7
8-INSTANCE_NAME=focal-$(petname)
9 ZONE="us-central1-a"
10-IMAGE_NAME="ubuntu-2004-focal-v20231130"
11+IMAGE_FAMILY="ubuntu-2004-lts"
12 PROJECT="${1}"
13
14 lets_spin(){
15@@ -36,10 +35,12 @@ wait_instance_connectable() {
16
17 launch_instance(){
18
19+ INSTANCE_NAME=focal-$(petname)
20+
21 printf "Launching a new instance...\n"
22- gcloud compute instances create ${INSTANCE_NAME} --machine-type n2d-standard-8 --project ${PROJECT} --image ${IMAGE_NAME} --image-project=ubuntu-os-cloud --zone ${ZONE} --metadata=startup-script='#! /bin/bash
23+ gcloud compute instances create ${INSTANCE_NAME} --machine-type n2d-standard-8 --project ${PROJECT} --image-family ${IMAGE_FAMILY} --image-project=ubuntu-os-cloud --zone ${ZONE} --quiet --metadata=startup-script='#! /bin/bash
24 apt update
25- apt -y install mongodb ros-base-python-dev ubuntu-advantage-tools slurm*
26+ apt -y install mongodb ubuntu-advantage-tools slurm*
27 EOF' & lets_spin
28
29 echo "Waiting for instance to start..."
30@@ -59,6 +60,12 @@ launch_instance(){
31
32 }
33
34+delete_instance(){
35+ INSTANCE_NAME="${1}"
36+ gcloud compute instances delete ${INSTANCE_NAME} --project ${PROJECT} --zone ${ZONE} --quiet
37+
38+}
39+
40 while true; do
41 clear
42 printf "Press any key to begin."
43@@ -70,5 +77,6 @@ while true; do
44 fi
45
46 echo "Deleting the instance and starting over again!"
47- gcloud compute instances delete ${INSTANCE_NAME} --project ${PROJECT} --zone ${ZONE} --quiet & lets_spin
48+ delete_instance $INSTANCE_NAME &
49+
50 done

Subscribers

People subscribed via source and target branches

to all changes: