just warn if Heapster is not deployed (Minikube is missing it)

This commit is contained in:
Henning Jacobs
2017-01-15 18:36:49 +01:00
parent 49b150ef10
commit 5dc172e2fa
4 changed files with 24 additions and 21 deletions

14
kube_ops_view/utils.py Normal file
View File

@@ -0,0 +1,14 @@
import requests.exceptions
def get_short_error_message(e: Exception):
'''Generate a reasonable short message why the HTTP request failed'''
if isinstance(e, requests.exceptions.RequestException) and e.response is not None:
# e.g. "401 Unauthorized"
return '{} {}'.format(e.response.status_code, e.response.reason)
elif isinstance(e, requests.exceptions.ConnectionError):
# e.g. "ConnectionError" or "ConnectTimeout"
return e.__class__.__name__
else:
return str(e)