Skip to content

Commit

Permalink
digitalocean changed something in how the droplet comes online, we ha…
Browse files Browse the repository at this point in the history
…ve to wait twice

it also reports ready without an IP, so now we wait for that as well
  • Loading branch information
nikosch86 committed Sep 17, 2022
1 parent 850c398 commit d233d30
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions stand-up.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,26 @@ def validate_digitalocean():
for action in actions:
action.load()
action.wait()
if action.status == 'in-progress':
logger.debug("droplet not yet up, waiting some more")
actions = droplet.get_actions()
for action in actions:
action.load()
action.wait()
droplet.load()
if droplet.status != 'active' and droplet.status != 'new':
cleanup_and_die('something went wrong creating the instance, the status is "{}"'.format(droplet.status))
waitForNetworkingCount = 0
waitForNetworkingMax = 10
while droplet.ip_address is None and waitForNetworkingCount < waitForNetworkingMax:
waitForNetworkingCount += 1
logger.debug("the droplet does not report back an external IP, waiting {}/{}".format(waitForNetworkingCount, waitForNetworkingMax))
time.sleep(2)
droplet.load()
instance_ip = droplet.ip_address
if instance_ip is None:
print(vars(droplet))
cleanup_and_die('something went wrong, the droplet does not report back an external IP: {}'.format(vars(droplet)))
logger.info("instance with id {} has external IP {}".format(droplet.id, instance_ip))
printProgressBar(7)
try:
Expand Down Expand Up @@ -628,11 +644,16 @@ def validate_digitalocean():
printProgressBar(9)
logger.info("setting up system")
stdin, stdout, stderr = ssh.exec_command("echo LC_ALL=\"en_US.UTF-8\" >> /etc/default/locale; \
apt-get -q update && apt-get install -yq curl software-properties-common dirmngr && \
docker -v >/dev/null 2>&1 || curl https://get.docker.com | bash")
apt-get -q -o DPkg::Lock::Timeout=60 update && apt-get -o DPkg::Lock::Timeout=60 install -yq curl software-properties-common dirmngr")
logger.debug("".join(stdout.readlines()))
if stdout.channel.recv_exit_status() > 0: logger.critical("STDERR of setup command: {}".format(stderr.read()))

logger.info("setting up docker")
stdin, stdout, stderr = ssh.exec_command("docker -v >/dev/null 2>&1 || curl https://get.docker.com | bash")
logger.debug("".join(stdout.readlines()))
if stdout.channel.recv_exit_status() > 0: logger.critical("STDERR of setup command: {}".format(stderr.read()))


printProgressBar(10)

stdin, stdout, stderr = ssh.exec_command("docker-compose -v >/dev/null || curl -L \"https://github.com/docker/compose/releases/download/{}/docker-compose-Linux-x86_64\" -o /usr/local/bin/docker-compose && \
Expand Down

0 comments on commit d233d30

Please sign in to comment.