Minor changes for code review suggestions.

This commit is contained in:
Wesley Hartford 2018-12-18 22:24:48 -05:00
parent 060c78fd91
commit e7313da03e
1 changed files with 5 additions and 11 deletions

View File

@ -35,14 +35,8 @@ def ensure_resource(k8s_api, k8s_base_uri, namespace, kind, name, data):
if 200 <= create_resp.status_code <= 299: if 200 <= create_resp.status_code <= 299:
return None return None
elif create_resp.json().get('reason', '') != 'AlreadyExists':
else: return create_resp.content
json = create_resp.json()
if 'reason' in json:
if json['reason'] != 'AlreadyExists':
return create_resp.content
else:
return create_resp.content
url = _resolve_uri(k8s_base_uri, namespace, kind, name) url = _resolve_uri(k8s_base_uri, namespace, kind, name)
current_app.logger.debug("K8S PUT request URL: %s", url) current_app.logger.debug("K8S PUT request URL: %s", url)
@ -53,7 +47,7 @@ def ensure_resource(k8s_api, k8s_base_uri, namespace, kind, name, data):
if not 200 <= update_resp.status_code <= 299: if not 200 <= update_resp.status_code <= 299:
return update_resp.content return update_resp.content
return None return
def _resolve_ns(k8s_base_uri, namespace, api_ver=DEFAULT_API_VERSION,): def _resolve_ns(k8s_base_uri, namespace, api_ver=DEFAULT_API_VERSION,):
@ -152,8 +146,8 @@ class KubernetesDestinationPlugin(DestinationPlugin):
} }
}) })
except Exception as e: except Exception as e:
current_app.logger.exception("Exception in upload") current_app.logger.exception("Exception in upload: {}".format(e), exc_info=True)
raise e raise
if err is not None: if err is not None:
current_app.logger.debug("Error deploying resource: %s", err) current_app.logger.debug("Error deploying resource: %s", err)