Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions openshift/helper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time

import string_utils
from urllib3.exceptions import MaxRetryError

from logging import config as logging_config

Expand Down Expand Up @@ -134,6 +135,9 @@ def get_object(self, name, namespace=None):
else:
msg = json.loads(exc.body).get('message', exc.reason) if exc.body.startswith('{') else exc.body
raise OpenShiftException(msg, status=exc.status)
except MaxRetryError as ex:
raise OpenShiftException(str(ex.reason))

return k8s_obj

def patch_object(self, name, namespace, k8s_obj):
Expand Down Expand Up @@ -174,6 +178,8 @@ def create_project(self, metadata, display_name=None, description=None):
except ApiException as exc:
msg = json.loads(exc.body).get('message', exc.reason) if exc.body.startswith('{') else exc.body
raise OpenShiftException(msg, status=exc.status)
except MaxRetryError as ex:
raise OpenShiftException(str(ex.reason))

self.__read_stream(w, stream, metadata.name, 'create')

Expand Down Expand Up @@ -209,6 +215,8 @@ def create_object(self, namespace, k8s_obj=None, body=None):
except ApiException as exc:
msg = json.loads(exc.body).get('message', exc.reason) if exc.body.startswith('{') else exc.body
raise OpenShiftException(msg, status=exc.status)
except MaxRetryError as ex:
raise OpenShiftException(str(ex.reason))

return_obj = self.__read_stream(w, stream, name, 'create')

Expand All @@ -233,6 +241,8 @@ def delete_object(self, name, namespace):
except ApiException as exc:
msg = json.loads(exc.body).get('message', exc.reason)
raise OpenShiftException(msg, status=exc.status)
except MaxRetryError as ex:
raise OpenShiftException(str(ex.reason))
else:
try:
if 'body' in inspect.getargspec(delete_method).args:
Expand All @@ -242,6 +252,8 @@ def delete_object(self, name, namespace):
except ApiException as exc:
msg = json.loads(exc.body).get('message', exc.reason) if exc.body.startswith('{') else exc.body
raise OpenShiftException(msg, status=exc.status)
except MaxRetryError as ex:
raise OpenShiftException(str(ex.reason))

if status_obj is None or status_obj.status == 'Failure':
msg = 'Failed to delete {}'.format(name)
Expand Down Expand Up @@ -286,6 +298,8 @@ def replace_object(self, name, namespace, k8s_obj=None, body=None):
except ApiException as exc:
msg = json.loads(exc.body).get('message', exc.reason) if exc.body.startswith('{') else exc.body
raise OpenShiftException(msg, status=exc.status)
except MaxRetryError as ex:
raise OpenShiftException(str(ex.reason))

return_obj = self.__read_stream(w, stream, name, 'replace')

Expand Down