Skip to content

Commit 1fed73f

Browse files
author
Miguel Varela Ramos
authored
Remove API Gateway (#1751)
1 parent 81e3bc1 commit 1fed73f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+357
-1499
lines changed

cli/cmd/cluster.go

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -218,27 +218,11 @@ var _clusterUpCmd = &cobra.Command{
218218
exit.Error(err)
219219
}
220220

221-
if clusterConfig.APIGatewaySetting == clusterconfig.PublicAPIGatewaySetting {
222-
err = createOrReplaceAPIGateway(awsClient, clusterConfig.ClusterName, clusterConfig.Tags)
223-
if err != nil {
224-
exit.Error(err)
225-
}
226-
}
227-
228221
out, exitCode, err := runManagerWithClusterConfig("/root/install.sh", clusterConfig, awsCreds, nil, nil)
229222
if err != nil {
230-
if clusterConfig.APIGatewaySetting == clusterconfig.PublicAPIGatewaySetting {
231-
awsClient.DeleteAPIGatewayByTag(clusterconfig.ClusterNameTag, clusterConfig.ClusterName) // best effort deletion
232-
awsClient.DeleteVPCLinkByTag(clusterconfig.ClusterNameTag, clusterConfig.ClusterName) // best effort deletion
233-
}
234223
exit.Error(err)
235224
}
236225
if exitCode == nil || *exitCode != 0 {
237-
if clusterConfig.APIGatewaySetting == clusterconfig.PublicAPIGatewaySetting {
238-
awsClient.DeleteAPIGatewayByTag(clusterconfig.ClusterNameTag, clusterConfig.ClusterName) // best effort deletion
239-
awsClient.DeleteVPCLinkByTag(clusterconfig.ClusterNameTag, clusterConfig.ClusterName) // best effort deletion
240-
}
241-
242226
eksCluster, err := awsClient.EKSClusterOrNil(clusterConfig.ClusterName)
243227
if err != nil {
244228
helpStr := "\ndebugging tips (may or may not apply to this error):"
@@ -512,27 +496,6 @@ var _clusterDownCmd = &cobra.Command{
512496
prompt.YesOrExit(fmt.Sprintf("your cluster named \"%s\" in %s will be spun down and all apis will be deleted, are you sure you want to continue?", *accessConfig.ClusterName, *accessConfig.Region), "", "")
513497
}
514498

515-
fmt.Print("○ deleting api gateway ")
516-
deletedAPIGateway, errAPIGateway := awsClient.DeleteAPIGatewayByTag(clusterconfig.ClusterNameTag, *accessConfig.ClusterName)
517-
_, errVPCLink := awsClient.DeleteVPCLinkByTag(clusterconfig.ClusterNameTag, *accessConfig.ClusterName)
518-
if errAPIGateway != nil {
519-
fmt.Printf("\n\nunable to delete cortex's api gateway (see error below); if it still exists after the cluster has been deleted, please delete it via the api gateway console: https://%s.console.aws.amazon.com/apigateway/main/apis\n", *accessConfig.Region)
520-
errors.PrintError(errAPIGateway)
521-
}
522-
if errVPCLink != nil {
523-
fmt.Printf("\n\nunable to delete cortex's vpc link (see error below); if it still exists after the cluster has been deleted, please delete it via the api gateway console: https://%s.console.aws.amazon.com/apigateway/main/vpc-links\n", *accessConfig.Region)
524-
errors.PrintError(errVPCLink)
525-
}
526-
if errAPIGateway == nil && errVPCLink == nil {
527-
if deletedAPIGateway != nil {
528-
fmt.Println("✓")
529-
} else {
530-
fmt.Println("(n/a)")
531-
}
532-
} else {
533-
fmt.Println()
534-
}
535-
536499
fmt.Print("○ deleting dashboard ")
537500
err = awsClient.DeleteDashboard(*accessConfig.ClusterName)
538501
if err != nil {
@@ -1107,32 +1070,6 @@ func createOrClearDashboard(awsClient *aws.Client, dashboardName string) error {
11071070
return nil
11081071
}
11091072

1110-
// createOrReplaceAPIGateway creates an API gateway for the cluster (or clears an existing one if it already exists)
1111-
func createOrReplaceAPIGateway(awsClient *aws.Client, clusterName string, tags map[string]string) error {
1112-
fmt.Print("○ creating api gateway: ", clusterName)
1113-
1114-
_, err := awsClient.DeleteVPCLinkByTag(clusterconfig.ClusterNameTag, clusterName)
1115-
if err != nil {
1116-
fmt.Print("\n\n")
1117-
return errors.Append(err, fmt.Sprintf("\n\nunable to delete existing vpc link with tag %s=%s; please delete it via the api gateway console: https://%s.console.aws.amazon.com/apigateway/main/vpc-links", clusterconfig.ClusterNameTag, clusterName, awsClient.Region))
1118-
}
1119-
1120-
_, err = awsClient.DeleteAPIGatewayByTag(clusterconfig.ClusterNameTag, clusterName)
1121-
if err != nil {
1122-
fmt.Print("\n\n")
1123-
return errors.Append(err, fmt.Sprintf("\n\nunable to delete existing api gateway with tag %s=%s; please delete it via the api gateway console: https://%s.console.aws.amazon.com/apigateway/main/apis", clusterconfig.ClusterNameTag, clusterName, awsClient.Region))
1124-
}
1125-
1126-
_, err = awsClient.CreateAPIGateway(clusterName, tags)
1127-
if err != nil {
1128-
fmt.Print("\n\n")
1129-
return err
1130-
}
1131-
1132-
fmt.Println(" ✓")
1133-
return nil
1134-
}
1135-
11361073
// Will return error if load balancer can't be found
11371074
func getAWSOperatorLoadBalancer(clusterName string, awsClient *aws.Client) (*elbv2.LoadBalancer, error) {
11381075
loadBalancer, err := awsClient.FindLoadBalancer(map[string]string{

cli/cmd/lib_cluster_config_aws.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,6 @@ func setConfigFieldsFromCached(userClusterConfig *clusterconfig.Config, cachedCl
333333
}
334334
userClusterConfig.OperatorLoadBalancerScheme = cachedClusterConfig.OperatorLoadBalancerScheme
335335

336-
if userClusterConfig.APIGatewaySetting != cachedClusterConfig.APIGatewaySetting {
337-
return clusterconfig.ErrorConfigCannotBeChangedOnUpdate(clusterconfig.APIGatewaySettingKey, cachedClusterConfig.APIGatewaySetting)
338-
}
339-
userClusterConfig.APIGatewaySetting = cachedClusterConfig.APIGatewaySetting
340-
341336
if s.Obj(cachedClusterConfig.VPCCIDR) != s.Obj(userClusterConfig.VPCCIDR) {
342337
return clusterconfig.ErrorConfigCannotBeChangedOnUpdate(clusterconfig.VPCCIDRKey, cachedClusterConfig.VPCCIDR)
343338
}
@@ -404,10 +399,7 @@ func setConfigFieldsFromCached(userClusterConfig *clusterconfig.Config, cachedCl
404399
userClusterConfig.Spot = cachedClusterConfig.Spot
405400

406401
if userClusterConfig.Spot != nil && *userClusterConfig.Spot {
407-
err := userClusterConfig.FillEmptySpotFields(awsClient)
408-
if err != nil {
409-
return err
410-
}
402+
userClusterConfig.FillEmptySpotFields()
411403
}
412404

413405
if userClusterConfig.SpotConfig != nil && s.Obj(userClusterConfig.SpotConfig) != s.Obj(cachedClusterConfig.SpotConfig) {
@@ -541,10 +533,6 @@ func confirmInstallClusterConfig(clusterConfig *clusterconfig.Config, awsCreds A
541533
}
542534
fmt.Printf("cortex will also create an s3 bucket (%s) and a cloudwatch log group (%s)%s\n\n", clusterConfig.Bucket, clusterConfig.ClusterName, privateSubnetMsg)
543535

544-
if clusterConfig.APIGatewaySetting == clusterconfig.NoneAPIGatewaySetting {
545-
fmt.Print(fmt.Sprintf("warning: you've disabled API Gateway cluster-wide, so APIs will not be able to create API Gateway endpoints (they will still be reachable via the API load balancer; see https://docs.cortex.dev/v/%s/ for more information)\n\n", consts.CortexVersionMinor))
546-
}
547-
548536
if clusterConfig.OperatorLoadBalancerScheme == clusterconfig.InternalLoadBalancerScheme {
549537
fmt.Print(fmt.Sprintf("warning: you've configured the operator load balancer to be internal; you must configure VPC Peering to connect your CLI to your cluster operator (see https://docs.cortex.dev/v/%s/)\n\n", consts.CortexVersionMinor))
550538
}
@@ -618,16 +606,13 @@ func clusterConfigConfirmationStr(clusterConfig clusterconfig.Config, awsCreds A
618606
if clusterConfig.OperatorLoadBalancerScheme != defaultConfig.OperatorLoadBalancerScheme {
619607
items.Add(clusterconfig.OperatorLoadBalancerSchemeUserKey, clusterConfig.OperatorLoadBalancerScheme)
620608
}
621-
if clusterConfig.APIGatewaySetting != defaultConfig.APIGatewaySetting {
622-
items.Add(clusterconfig.APIGatewaySettingUserKey, clusterConfig.APIGatewaySetting)
623-
}
624609

625610
if clusterConfig.Spot != nil && *clusterConfig.Spot != *defaultConfig.Spot {
626611
items.Add(clusterconfig.SpotUserKey, s.YesNo(clusterConfig.Spot != nil && *clusterConfig.Spot))
627612

628613
if clusterConfig.SpotConfig != nil {
629614
defaultSpotConfig := clusterconfig.SpotConfig{}
630-
clusterconfig.AutoGenerateSpotConfig(awsClient, &defaultSpotConfig, *clusterConfig.Region, *clusterConfig.InstanceType)
615+
clusterconfig.AutoGenerateSpotConfig(&defaultSpotConfig, *clusterConfig.Region, *clusterConfig.InstanceType)
631616

632617
if !strset.New(clusterConfig.SpotConfig.InstanceDistribution...).IsEqual(strset.New(defaultSpotConfig.InstanceDistribution...)) {
633618
items.Add(clusterconfig.InstanceDistributionUserKey, clusterConfig.SpotConfig.InstanceDistribution)

dev/find_missing_docs_links.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_links_from_file(file):
5656
with open(file) as f:
5757
for line in f:
5858
for link in re.findall(r"\]\((.+?)\)", line):
59-
if link.startswith("http"):
59+
if is_external_link(link):
6060
link_infos.append((file, n, link, None, None))
6161
continue
6262
if link.startswith("#"):
@@ -87,7 +87,7 @@ def check_links(link_infos):
8787

8888
for link_info in link_infos:
8989
src_file, line_num, original_link_text, target_file, header = link_info
90-
if original_link_text.startswith("http"):
90+
if is_external_link(original_link_text):
9191
http_link_infos.append(link_info)
9292
continue
9393

@@ -174,5 +174,9 @@ def err_str(src_file, line_num, original_link_text, reason):
174174
return f"{clean_src_file}:{line_num}: {original_link_text} ({reason})"
175175

176176

177+
def is_external_link(link):
178+
return link.startswith("http://") or link.startswith("https://")
179+
180+
177181
if __name__ == "__main__":
178182
main()

dev/format.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ xargs -0 -L1 bash -c 'test "$(tail -c 1 "$0")" && echo "" >> "$0"' || true)
6868
! -path "./.git/*" \
6969
! -name ".*" \
7070
-print0 | \
71-
xargs -0 -L1 bash -c 'test "$(tail -c 2 "$0")" || (trimmed=$(printf "%s" "$(< $0)") && echo "$trimmed" > "$0")' || true)
71+
xargs -0 -L1 bash -c 'test "$(tail -c 2 "$0")" || [ ! -s "$0" ] || (trimmed=$(printf "%s" "$(< $0)") && echo "$trimmed" > "$0")' || true)
7272

7373
# Remove new lines at beginning of file
7474
(cd "$ROOT" && find . -type f \
@@ -77,4 +77,4 @@ xargs -0 -L1 bash -c 'test "$(tail -c 2 "$0")" || (trimmed=$(printf "%s" "$(< $0
7777
! -path "./.git/*" \
7878
! -name ".*" \
7979
-print0 | \
80-
xargs -0 -L1 bash -c 'test "$(head -c 1 "$0")" || (trimmed=$(sed '"'"'/./,$!d'"'"' "$0") && echo "$trimmed" > "$0")' || true)
80+
xargs -0 -L1 bash -c 'test "$(head -c 1 "$0")" || [ ! -s "$0" ] || (trimmed=$(sed '"'"'/./,$!d'"'"' "$0") && echo "$trimmed" > "$0")' || true)

0 commit comments

Comments
 (0)