瀏覽代碼

add suggestion for next cidr range (#4359)

Stefan McShane 2 年之前
父節點
當前提交
f4b4c726b2

+ 0 - 24
api/server/handlers/api_contract/preflight.go

@@ -47,17 +47,6 @@ type PreflightCheckResponse struct {
 	Errors []PreflightCheckError `json:"errors"`
 }
 
-var recognizedPreflightCheckTypes = []string{
-	"eip",
-	"vcpu",
-	"vpc",
-	"natGateway",
-	"apiEnabled",
-	"cidrAvailability",
-	"iamPermissions",
-	"authz",
-}
-
 func (p *PreflightCheckHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	ctx, span := telemetry.NewSpan(r.Context(), "serve-preflight-checks")
 	defer span.End()
@@ -92,10 +81,6 @@ func (p *PreflightCheckHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
 
 	errors := []PreflightCheckError{}
 	for _, check := range checkResp.Msg.FailingPreflightChecks {
-		if check.Message == "" || !contains(recognizedPreflightCheckTypes, check.Type) {
-			continue
-		}
-
 		errors = append(errors, PreflightCheckError{
 			Name: check.Type,
 			Error: PorterError{
@@ -107,12 +92,3 @@ func (p *PreflightCheckHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
 	resp.Errors = errors
 	p.WriteResult(w, r, resp)
 }
-
-func contains(slice []string, elem string) bool {
-	for _, item := range slice {
-		if item == elem {
-			return true
-		}
-	}
-	return false
-}

+ 35 - 0
dashboard/src/lib/clusters/constants.ts

@@ -1128,6 +1128,26 @@ const AWS_VCPUS_QUOTA_RESOLUTION: PreflightCheckResolution = {
     },
   ],
 };
+const OVERLAPPING_CIDR_RESOLUTION: PreflightCheckResolution = {
+  title: "Preventing Overlapping CIDR Blocks",
+  subtitle:
+    "You will need to select an unused CIDR Block in order to provision in the region specified.",
+  steps: [
+    {
+      text: "Change the CIDR blocks on this page to be unique and not overlap with any other CIDR blocks in your account.",
+    },
+    {
+      text: "The VPC CIDR block should be a /16 in the 10.0.0.0/8 range",
+    },
+    {
+      text: "The Service CIDR block should be a /16 in the 172.16.0.0/12 range in accordanc with RFC 1918",
+      externalLink: "https://datatracker.ietf.org/doc/html/rfc1918",
+    },
+    {
+      text: "Once you have selected unique CIDR blocks, return to Porter and retry the provision. If you have any issues or questions, please reach out to Porter support",
+    },
+  ],
+};
 const AZURE_AUTHZ_RESOLUTION: PreflightCheckResolution = {
   title: "Granting your service principal authorization to your subscription",
   subtitle:
@@ -1220,6 +1240,11 @@ const SUPPORTED_AWS_PREFLIGHT_CHECKS: PreflightCheck[] = [
     name: "cidrAvailability",
     displayName: "CIDR availability",
   },
+  {
+    name: "enforceCidrUniqueness",
+    displayName: "Overlapping CIDR blocks",
+    resolution: OVERLAPPING_CIDR_RESOLUTION,
+  },
 ];
 
 const SUPPORTED_AZURE_PREFLIGHT_CHECKS: PreflightCheck[] = [
@@ -1238,6 +1263,11 @@ const SUPPORTED_AZURE_PREFLIGHT_CHECKS: PreflightCheck[] = [
     displayName: "vCPU availability",
     resolution: AZURE_VCPUS_QUOTA_RESOLUTION,
   },
+  {
+    name: "enforceCidrUniqueness",
+    displayName: "Overlapping CIDR blocks",
+    resolution: OVERLAPPING_CIDR_RESOLUTION,
+  },
 ];
 
 const SUPPORTED_GCP_PREFLIGHT_CHECKS: PreflightCheck[] = [
@@ -1253,6 +1283,11 @@ const SUPPORTED_GCP_PREFLIGHT_CHECKS: PreflightCheck[] = [
     name: "iamPermissions",
     displayName: "IAM permissions",
   },
+  {
+    name: "enforceCidrUniqueness",
+    displayName: "Overlapping CIDR blocks",
+    resolution: OVERLAPPING_CIDR_RESOLUTION,
+  },
 ];
 
 const DEFAULT_EKS_CONTRACT = new Contract({

+ 1 - 0
dashboard/src/lib/clusters/types.ts

@@ -510,6 +510,7 @@ const preflightCheckKeyValidator = z.enum([
   "cidrAvailability",
   "iamPermissions",
   "authz",
+  "enforceCidrUniqueness",
 ]);
 type PreflightCheckKey = z.infer<typeof preflightCheckKeyValidator>;
 export const preflightCheckValidator = z.object({