From 5f381508082f415a0c842a9a12777aea9f564919 Mon Sep 17 00:00:00 2001 From: Naor Livne Date: Mon, 14 Jan 2019 13:41:19 +0200 Subject: [PATCH] edge case protection against starting a worker as part of a device_group that does not exist yet --- worker.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/worker.py b/worker.py index 75a3080..d98bc10 100644 --- a/worker.py +++ b/worker.py @@ -249,6 +249,12 @@ def get_device_group_info(nebula_connection_object, device_group_to_get_info): # get the initial device_group configuration and store it in memory local_device_group_info = get_device_group_info(nebula_connection, device_group) + # make sure the device_group exists in the nebula cluster + while local_device_group_info["status_code"] == 403 and \ + local_device_group_info["reply"]["device_group_exists"] is False: + print("device_group " + device_group + " doesn't exist in nebula cluster, waiting for it to be created") + time.sleep(5) + # start all apps that are set to running on boot for nebula_app in local_device_group_info["reply"]["apps"]: if nebula_app["running"] is True: