-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…age-not-refresh ANPL-1258 The bug related to status and messages on tooling env and also performance of this page
- Loading branch information
Showing
24 changed files
with
287 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from rest_framework.response import Response | ||
from rest_framework.generics import GenericAPIView | ||
from rest_framework import status | ||
|
||
from controlpanel.frontend.consumers import start_background_task | ||
from controlpanel.api import serializers | ||
|
||
|
||
class ToolDeploymentAPIView(GenericAPIView): | ||
|
||
http_method_names = ['post'] | ||
serializer_class = serializers.ToolDeploymentSerializer | ||
|
||
def _deploy(self, chart_name, data): | ||
""" | ||
This is the most backwards thing you'll see for a while. The helm | ||
task to deploy the tool apparently must happen when the view class | ||
attempts to redirect to the target url. I'm sure there's a good | ||
reason why. | ||
""" | ||
# If there's already a tool deployed, we need to get this from a | ||
# hidden field posted back in the form. This is used by helm to delete | ||
# the currently installed chart for the tool before installing the | ||
# new chart. | ||
old_chart_name = data.get("deployed_chart_name", None) | ||
# The selected option from the "version" select control contains the | ||
# data we need. | ||
chart_info = data.get("version") | ||
# The tool name and version are stored in the selected option's value | ||
# attribute and then split on "__" to extract them. Why? Because we | ||
# need both pieces of information to kick off the background helm | ||
# deploy. | ||
tool_name, tool_version, tool_id = chart_info.split("__") | ||
|
||
# Kick off the helm chart as a background task. | ||
start_background_task( | ||
"tool.deploy", | ||
{ | ||
"tool_name": chart_name, | ||
"version": tool_version, | ||
"tool_id": tool_id, | ||
"user_id": self.request.user.id, | ||
"id_token": self.request.user.get_id_token(), | ||
"old_chart_name": old_chart_name, | ||
}, | ||
) | ||
|
||
def post(self, request, *args, **kwargs): | ||
serializer = self.get_serializer(data=request.data) | ||
serializer.is_valid(raise_exception=True) | ||
|
||
chart_name = self.kwargs["tool_name"] | ||
tool_action = self.kwargs["action"] | ||
tool_action_function = getattr(self, f"_{tool_action}", None) | ||
if tool_action_function and callable(tool_action_function): | ||
tool_action_function(chart_name, request.data) | ||
return Response(status=status.HTTP_200_OK) | ||
else: | ||
return Response(status=status.HTTP_400_BAD_REQUEST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -404,6 +404,7 @@ class Meta: | |
"values", | ||
"is_restricted", | ||
"tool_domain", | ||
"description" | ||
] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.