Skip to content

Commit

Permalink
ch: prevent un authenticated cluster from returning a 401 (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
khalifan-kfan committed May 16, 2024
1 parent a3e0453 commit ad0fe85
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 57 deletions.
14 changes: 7 additions & 7 deletions app/controllers/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from app.helpers.admin import is_admin, is_authorised_project_user, is_owner_or_admin
from app.helpers.decorators import admin_required
from app.helpers.decorators import admin_required
from app.helpers.kube import create_kube_clients, delete_cluster_app, deploy_user_app
from app.helpers.kube import create_kube_clients, delete_cluster_app, deploy_user_app, check_kube_error_code
from app.helpers.url import get_app_subdomain
from app.models.app import App
from app.models.user import User
Expand Down Expand Up @@ -358,7 +358,7 @@ def get(self, project_id):
data=dict(pagination=pagination, apps=apps_data_list)), 200

except client.rest.ApiException as exc:
return dict(status='fail', message=exc.reason), exc.status
return dict(status='fail', message=exc.reason), check_kube_error_code(exc.status)

except Exception as exc:
return dict(status='fail', message=str(exc)), 500
Expand Down Expand Up @@ -490,7 +490,7 @@ def get(self, app_id):
if exc.status == 404:
return dict(status='fail', data=json.loads(app_data), message="Application does not exist on the cluster"), 404

return dict(status='fail', message=exc.reason), exc.status
return dict(status='fail', message=exc.reason), check_kube_error_code(exc.status)

except Exception as exc:
return dict(status='fail', message=str(exc)), 500
Expand Down Expand Up @@ -807,7 +807,7 @@ def patch(self, app_id):
a_project_id=project.id,
a_cluster_id=project.cluster_id,
a_app_id=app_id)
return dict(status='fail', message=exc.reason), exc.status
return dict(status='fail', message=exc.reason), check_kube_error_code(exc.status)

except Exception as exc:
log_activity('App', status='Failed',
Expand Down Expand Up @@ -917,7 +917,7 @@ def get(self, app_id):
if exc.status == 404:
return dict(status='fail', data=json.loads(app_data), message="Application does not exist on the cluster"), 404

return dict(status='fail', message=exc.reason), exc.status
return dict(status='fail', message=exc.reason), check_kube_error_code(exc.status)

except Exception as exc:
return dict(status='fail', message=str(exc)), 500
Expand Down Expand Up @@ -1048,7 +1048,7 @@ def patch(self, app_id):
), 200

except client.rest.ApiException as exc:
return dict(status='fail', message=exc.reason), exc.status
return dict(status='fail', message=exc.reason), check_kube_error_code(exc.status)

except Exception as exc:
return dict(status='fail', message=str(exc)), 500
Expand Down Expand Up @@ -1176,7 +1176,7 @@ def post(self, app_id, revision_id):
a_project_id=project.id,
a_cluster_id=project.cluster_id,
a_app_id=app_id)
return dict(status='fail', message=exc.reason), exc.status
return dict(status='fail', message=exc.reason), check_kube_error_code(exc.status)

except Exception as exc:
log_activity('App', status='Failed',
Expand Down
Loading

0 comments on commit ad0fe85

Please sign in to comment.