Skip to content

Commit

Permalink
tasks: skip client side node_list validation
Browse files Browse the repository at this point in the history
* Gets raw data from Kubernetes and avoids OpenAPI deserialization which
  fails due to kubernetes-client/gen#52,
  even though [this fix](kubernetes/kubernetes#85728)
  exists, the Python Kubernetes library is still not compatible with it.
  More information at kubernetes-client/python#1174.
  • Loading branch information
Diego Rodriguez committed Jul 3, 2020
1 parent 6701851 commit 332be1e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions reana_commons/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""REANA common tasks."""

import importlib
import json
import logging

from kubernetes.client.rest import ApiException
Expand Down Expand Up @@ -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.")
Expand Down

0 comments on commit 332be1e

Please sign in to comment.