Skip to content

Commit

Permalink
Wait for CJIs to be ready after deploy (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsquizz authored Dec 14, 2021
1 parent b748f49 commit 1667e2e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
28 changes: 23 additions & 5 deletions bonfire/openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ class StatusError(Exception):
"daemonset",
"clowdapp",
"clowdenvironment",
"clowdjobinvocation",
"kafka",
"kafkaconnect",
"pod",
Expand Down Expand Up @@ -312,6 +313,19 @@ def _get_name_for_kind(kind):
raise ValueError(f"unable to find resource name for kind '{kind}'")


def _check_status_condition(status, expected_type, expected_value):
conditions = status.get("conditions", [])
expected_type = str(expected_type).lower()
expected_value = str(expected_value).lower()

for c in conditions:
status_value = str(c.get("status")).lower()
status_type = str(c.get("type")).lower()
if status_value == expected_value and status_type == expected_type:
return True
return False


def _check_status_for_restype(restype, json_data):
"""
Depending on the resource type, check that it is "ready" or "complete"
Expand Down Expand Up @@ -360,13 +374,17 @@ def _check_status_for_restype(restype, json_data):
return True

elif restype in ("clowdenvironment", "clowdapp"):
return str(status.get("ready")).lower() == "true"
return _check_status_condition(
status, "DeploymentsReady", "true"
) and _check_status_condition(status, "ReconciliationSuccessful", "true")

elif restype == "clowdjobinvocation":
return _check_status_condition(
status, "JobInvocationComplete", "true"
) and _check_status_condition(status, "ReconciliationSuccessful", "true")

elif restype in ("kafka", "kafkaconnect"):
conditions = status.get("conditions", [])
for c in conditions:
if str(c.get("status")).lower() == "true" and c.get("type").lower() == "ready":
return True
return _check_status_condition(status, "ready", "true")


def _get_resource_info(item):
Expand Down
2 changes: 2 additions & 0 deletions bonfire/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ def _get_component_items(self, component_name):
# override any specific parameters on this component if requested
self._sub_params(component_name, params)

log.debug("parameters for component '%s': %s", component_name, params)

new_items = process_template(template, params)["items"]

# override the tags for all occurences of an image if requested
Expand Down
2 changes: 1 addition & 1 deletion cicd/iqe_pod/create_iqe_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


def _get_base_pod_cfg():
iqe_image = os.getenv('IQE_IMAGE', "quay.io/cloudservices/iqe-tests:latest")
iqe_image = os.getenv("IQE_IMAGE", "quay.io/cloudservices/iqe-tests:latest")
return {
"apiVersion": "v1",
"kind": "Pod",
Expand Down

0 comments on commit 1667e2e

Please sign in to comment.