oneclick: Wait in a loop until the image build droplet gets an IP.

The script will fail if we process with a droplet object with no
.ip_address, which can sometimes happen if we just droplet.load().
Sometimes that gives droplet.ip_address set to None. If we wait in a
loop, we eventuall get the .ip_address set.
This commit is contained in:
Mateusz Mandera 2022-11-18 13:28:55 +01:00 committed by Tim Abbott
parent b8ab02022c
commit 51ed2442fa
1 changed files with 10 additions and 1 deletions

View File

@ -44,7 +44,16 @@ def sleep_until_droplet_action_is_completed(
break
if incomplete:
time.sleep(5)
droplet.load()
# Sometimes the droplet does not yet have an .ip_address value
# (the attribute is None) after .load()ing the droplet. We cannot
# proceed without the IP, so we wait in a loop until the IP is
# returned to us.
while True:
droplet.load()
if droplet.ip_address:
break
time.sleep(5)
def set_api_request_retry_limits(api_object: digitalocean.baseapi.BaseAPI) -> None: