From 332be1e7eb41322f0ec6c9de8e059ed55d99b9e5 Mon Sep 17 00:00:00 2001 From: Diego Rodriguez Date: Fri, 3 Jul 2020 15:38:00 +0200 Subject: [PATCH] tasks: skip client side node_list validation * Gets raw data from Kubernetes and avoids OpenAPI deserialization which fails due to https://github.com/kubernetes-client/gen/issues/52, even though [this fix](https://github.com/kubernetes/kubernetes/pull/85728) exists, the Python Kubernetes library is still not compatible with it. More information at https://github.com/kubernetes-client/python/issues/1174. --- reana_commons/tasks.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/reana_commons/tasks.py b/reana_commons/tasks.py index f1d77100..d72a82b1 100644 --- a/reana_commons/tasks.py +++ b/reana_commons/tasks.py @@ -8,6 +8,7 @@ """REANA common tasks.""" import importlib +import json import logging from kubernetes.client.rest import ApiException @@ -37,13 +38,17 @@ def reana_ready(): def check_predefined_conditions(): """Check k8s predefined conditions for the nodes.""" try: - node_info = current_k8s_corev1_api_client.list_node() - for node in node_info.items: + node_info = json.loads( + current_k8s_corev1_api_client.list_node( + _preload_content=False + ).data.decode() + ) + for node in node_info['items']: # check based on the predefined conditions about the # node status: MemoryPressure, OutOfDisk, KubeletReady # DiskPressure, PIDPressure, - for condition in node.status.conditions: - if not condition.status: + for condition in node.get('status', {}).get('conditions', {}): + if not condition.get('status'): return False except ApiException as e: log.error("Something went wrong while getting node information.")