From 5d3e392fdf1f87b49c8b9df31324c61e88152716 Mon Sep 17 00:00:00 2001 From: dfx1971 Date: Thu, 16 Jan 2020 09:55:27 +0200 Subject: OOM-2261 readiness-check does not track DaemonSet Issue-ID: OOM-2261 Signed-off-by: Avi Ziv Change-Id: I7f220f8b6b64165c33ed8d707834091240136199 Signed-off-by: Avi Ziv Change-Id: I7f220f8b6b64165c33ed8d707834091240136199 --- kubernetes/readiness/src/main/scripts/ready.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'kubernetes/readiness/src/main/scripts') diff --git a/kubernetes/readiness/src/main/scripts/ready.py b/kubernetes/readiness/src/main/scripts/ready.py index 3f76d10395..93932073cd 100644 --- a/kubernetes/readiness/src/main/scripts/ready.py +++ b/kubernetes/readiness/src/main/scripts/ready.py @@ -92,6 +92,20 @@ def wait_for_deployment_complete(deployment_name): log.error("Exception when waiting for deployment status: %s\n" % e) +def wait_for_daemonset_complete(daemonset_name): + try: + response = api_instance.read_namespaced_daemon_set(daemonset_name, namespace) + s = response.status + if s.desired_number_scheduled == s.number_ready: + log.info("DaemonSet: " + str(s.number_ready) + "/" + str(s.desired_number_scheduled) + " nodes ready --> " + daemonset_name + " is ready") + return True + else: + log.info("DaemonSet: " + str(s.number_ready) + "/" + str(s.desired_number_scheduled) + " nodes ready --> " + daemonset_name + " is not ready") + return False + except Exception as e: + log.error("Exception when waiting for DaemonSet status: %s\n" % e) + + def is_ready(container_name): ready = False log.info("Checking if " + container_name + " is ready") @@ -112,6 +126,8 @@ def is_ready(container_name): ready = wait_for_deployment_complete(deployment_name) elif i.metadata.owner_references[0].kind == "Job": ready = is_job_complete(name) + elif i.metadata.owner_references[0].kind == "DaemonSet": + ready = wait_for_daemonset_complete(i.metadata.owner_references[0].name) return ready @@ -123,7 +139,7 @@ def is_ready(container_name): def read_name(item): - return item.metadata.owner_reference[0].name + return item.metadata.owner_references[0].name def get_deployment_name(replicaset): -- cgit 1.2.3-korg