From f4b4c726b2bf4032f023006e5b74f0240e1496e3 Mon Sep 17 00:00:00 2001 From: Stefan McShane Date: Fri, 1 Mar 2024 18:02:20 -0500 Subject: [PATCH] add suggestion for next cidr range (#4359) --- api/server/handlers/api_contract/preflight.go | 24 ------------- dashboard/src/lib/clusters/constants.ts | 35 +++++++++++++++++++ dashboard/src/lib/clusters/types.ts | 1 + 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/api/server/handlers/api_contract/preflight.go b/api/server/handlers/api_contract/preflight.go index 7c1c444201..0cfae309ad 100644 --- a/api/server/handlers/api_contract/preflight.go +++ b/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 -} diff --git a/dashboard/src/lib/clusters/constants.ts b/dashboard/src/lib/clusters/constants.ts index 8b807af070..11df3fbc58 100644 --- a/dashboard/src/lib/clusters/constants.ts +++ b/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({ diff --git a/dashboard/src/lib/clusters/types.ts b/dashboard/src/lib/clusters/types.ts index f251658de7..1bcc661a0e 100644 --- a/dashboard/src/lib/clusters/types.ts +++ b/dashboard/src/lib/clusters/types.ts @@ -510,6 +510,7 @@ const preflightCheckKeyValidator = z.enum([ "cidrAvailability", "iamPermissions", "authz", + "enforceCidrUniqueness", ]); type PreflightCheckKey = z.infer; export const preflightCheckValidator = z.object({