Closed thraxil closed 3 years ago
@thraxil You're right, I did some debugging and the instances are shutting down when I revert #47. Why did we have that change in the first place?
Here's what I've tried (I made it look like the script in instance.sh
as possible)
#!/bin/bash
ALIVE_TIME=45
INSTANCE_NAME=example-instance
PROJECT_ID=appsembler-devstack-30
ZONE=us-central1-c
cmd=(
"gcloud" "compute" "instances" "create" "$INSTANCE_NAME"
"--project=$PROJECT_ID"
"--zone=$ZONE"
"--metadata=startup-script=/bin/bash -c '( sleep $ALIVE_TIME; sudo poweroff -p --no-wall ) &'"
)
"${cmd[@]}"
gcloud beta compute ssh --zone "$ZONE" "$INSTANCE_NAME" --project "$PROJECT_ID"
# sudo journalctl -u google-startup-scripts.service
# gcloud compute instances delete example-instance --project=appsembler-devstack-30
@ahmedaljazzar I made #47 because on my machine ./sultan devstack create
was failing with ERROR: (gcloud) unrecognized arguments: -c
I noticed that an instance I created last week was still running, despite the addition of the
ALIVE_TIME
. The issue appears to be that thestartup-script
metadata doesn't accept a direct command, it's expecting some text that it wants to write to a file like/tmp/metadata-scripts.../startup-script.sh
and then execute that.Steps to reproduce:
./sultan instance create
sudo grep startup /var/log/syslog
. failure looks something like:I was able to do a very simple
And verified that that created a VM that turned itself off after a minute. I tried a few variations on getting that into the command in sultan's
instance.sh
but couldn't get it to work right with the bash escaping in that context.