瀏覽代碼

Remove Legacy Preflight Checks (#3828)

sdess09 2 年之前
父節點
當前提交
dfee8e2c24

+ 0 - 61
api/server/handlers/project_integration/preflight_check_aws_usage.go

@@ -1,61 +0,0 @@
-package project_integration
-
-import (
-	"fmt"
-	"net/http"
-
-	"connectrpc.com/connect"
-	porterv1 "github.com/porter-dev/api-contracts/generated/go/porter/v1"
-	"github.com/porter-dev/porter/api/server/handlers"
-	"github.com/porter-dev/porter/api/server/shared"
-	"github.com/porter-dev/porter/api/server/shared/apierrors"
-	"github.com/porter-dev/porter/api/server/shared/config"
-	"github.com/porter-dev/porter/api/types"
-	"github.com/porter-dev/porter/internal/models"
-)
-
-type CreatePreflightCheckAWSUsageHandler struct {
-	handlers.PorterHandlerReadWriter
-}
-
-func NewCreatePreflightCheckAWSUsageHandler(
-	config *config.Config,
-	decoderValidator shared.RequestDecoderValidator,
-	writer shared.ResultWriter,
-) *CreatePreflightCheckAWSUsageHandler {
-	return &CreatePreflightCheckAWSUsageHandler{
-		PorterHandlerReadWriter: handlers.NewDefaultPorterHandler(config, decoderValidator, writer),
-	}
-}
-
-func (p *CreatePreflightCheckAWSUsageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
-	ctx := r.Context()
-	project, _ := ctx.Value(types.ProjectScope).(*models.Project)
-
-	if !p.Config().EnableCAPIProvisioner {
-		message := "Trying to run preflight checks but CAPI Provisioner is disabled. If you want to provision through CAPI, make sure that the environment variable ENABLE_CAPI_PROVISIONER is set to true"
-		e := fmt.Errorf(message)
-		p.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(e, http.StatusServiceUnavailable, message))
-		return
-	}
-
-	request := &types.QuotaPreflightCheckRequest{}
-	if ok := p.DecodeAndValidate(w, r, request); !ok {
-		return
-	}
-
-	checkReq := porterv1.QuotaPreflightCheckRequest{
-		ProjectId: int64(project.ID),
-		TargetArn: request.TargetARN,
-		Region:    request.Region,
-	}
-
-	checkResp, err := p.Config().ClusterControlPlaneClient.QuotaPreflightCheck(ctx, connect.NewRequest(&checkReq))
-	if err != nil {
-		e := fmt.Errorf("Pre-provision check failed: %w", err)
-		p.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(e, http.StatusPreconditionFailed, err.Error()))
-		return
-	}
-
-	p.WriteResult(w, r, checkResp)
-}

+ 0 - 28
api/server/router/project_integration.go

@@ -220,34 +220,6 @@ func getProjectIntegrationRoutes(
 		Router:   r,
 	})
 
-	// POST /api/projects/{project_id}/integrations/aws/preflightcheck/usage -> project_integration.NewCreatePreflightCheckAWSHandler
-	preflightCheckAWSUsageEndpoint := factory.NewAPIEndpoint(
-		&types.APIRequestMetadata{
-			Verb:   types.APIVerbCreate,
-			Method: types.HTTPVerbPost,
-			Path: &types.Path{
-				Parent:       basePath,
-				RelativePath: relPath + "/aws/preflight/usage",
-			},
-			Scopes: []types.PermissionScope{
-				types.UserScope,
-				types.ProjectScope,
-			},
-		},
-	)
-
-	preflightCheckAWSUsageHandler := project_integration.NewCreatePreflightCheckAWSUsageHandler(
-		config,
-		factory.GetDecoderValidator(),
-		factory.GetResultWriter(),
-	)
-
-	routes = append(routes, &router.Route{
-		Endpoint: preflightCheckAWSUsageEndpoint,
-		Handler:  preflightCheckAWSUsageHandler,
-		Router:   r,
-	})
-
 	// POST /api/projects/{project_id}/integrations/preflightcheck -> project_integration.NewCreatePreflightCheckHandler
 	preflightCheckEndpoint := factory.NewAPIEndpoint(
 		&types.APIRequestMetadata{

+ 0 - 11
dashboard/src/components/ProvisionerSettings.tsx

@@ -350,17 +350,6 @@ const ProvisionerSettings: React.FC<Props> = (props) => {
 
       if (!props.clusterId) {
         markStepStarted("pre-provisioning-check-started");
-
-        await api.preflightCheckAWSUsage(
-          "<token>",
-          {
-            target_arn: props.credentialId,
-            region: awsRegion,
-          },
-          {
-            id: currentProject.id,
-          }
-        );
       }
 
       const res = await api.createContract("<token>", data, {

+ 21 - 31
dashboard/src/shared/api.tsx

@@ -82,15 +82,6 @@ const preflightCheck = baseApi<PreflightCheckRequest, { id: number }>(
   }
 );
 
-const preflightCheckAWSUsage = baseApi<
-  {
-    target_arn: string;
-    region: string;
-  },
-  { id: number }
->("POST", (pathParams) => {
-  return `/api/projects/${pathParams.id}/integrations/aws/preflight/usage`;
-});
 
 const createAWSIntegration = baseApi<
   {
@@ -302,20 +293,20 @@ const appLogs = baseApi<
 );
 
 const appHelmValues = baseApi<
-    {
-        app_id: number;
-        deployment_target_id: string;
-        with_defaults: boolean;
-    },
-    {
-        project_id: number;
-        cluster_id: number;
-        porter_app_name: string;
-    }
+  {
+    app_id: number;
+    deployment_target_id: string;
+    with_defaults: boolean;
+  },
+  {
+    project_id: number;
+    cluster_id: number;
+    porter_app_name: string;
+  }
 >(
-    "GET",
-    ({ project_id, cluster_id, porter_app_name }) =>
-        `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/helm-values`
+  "GET",
+  ({ project_id, cluster_id, porter_app_name }) =>
+    `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/helm-values`
 );
 
 const appJobs = baseApi<
@@ -1950,15 +1941,15 @@ const getAllEnvGroups = baseApi<
 });
 
 const updateAppsLinkedToEnvironmentGroup = baseApi<
-    {
-        name: string;
-    },
-    {
-        id: number;
-        cluster_id: number;
-    }
+  {
+    name: string;
+  },
+  {
+    id: number;
+    cluster_id: number;
+  }
 >("POST", (pathParams) => {
-    return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/environment-groups/update-linked-apps`;
+  return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/environment-groups/update-linked-apps`;
 });
 
 const updateEnvironmentGroupV2 = baseApi<
@@ -3314,7 +3305,6 @@ export default {
   removeApplicationFromEnvGroup,
   provisionDatabase,
   preflightCheck,
-  preflightCheckAWSUsage,
   getDatabases,
   getPreviousLogsForContainer,
   upgradePorterAgent,