Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions cli/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,27 +218,11 @@ var _clusterUpCmd = &cobra.Command{
exit.Error(err)
}

if clusterConfig.APIGatewaySetting == clusterconfig.PublicAPIGatewaySetting {
err = createOrReplaceAPIGateway(awsClient, clusterConfig.ClusterName, clusterConfig.Tags)
if err != nil {
exit.Error(err)
}
}

out, exitCode, err := runManagerWithClusterConfig("/root/install.sh", clusterConfig, awsCreds, nil, nil)
if err != nil {
if clusterConfig.APIGatewaySetting == clusterconfig.PublicAPIGatewaySetting {
awsClient.DeleteAPIGatewayByTag(clusterconfig.ClusterNameTag, clusterConfig.ClusterName) // best effort deletion
awsClient.DeleteVPCLinkByTag(clusterconfig.ClusterNameTag, clusterConfig.ClusterName) // best effort deletion
}
exit.Error(err)
}
if exitCode == nil || *exitCode != 0 {
if clusterConfig.APIGatewaySetting == clusterconfig.PublicAPIGatewaySetting {
awsClient.DeleteAPIGatewayByTag(clusterconfig.ClusterNameTag, clusterConfig.ClusterName) // best effort deletion
awsClient.DeleteVPCLinkByTag(clusterconfig.ClusterNameTag, clusterConfig.ClusterName) // best effort deletion
}

eksCluster, err := awsClient.EKSClusterOrNil(clusterConfig.ClusterName)
if err != nil {
helpStr := "\ndebugging tips (may or may not apply to this error):"
Expand Down Expand Up @@ -512,27 +496,6 @@ var _clusterDownCmd = &cobra.Command{
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), "", "")
}

fmt.Print("○ deleting api gateway ")
deletedAPIGateway, errAPIGateway := awsClient.DeleteAPIGatewayByTag(clusterconfig.ClusterNameTag, *accessConfig.ClusterName)
_, errVPCLink := awsClient.DeleteVPCLinkByTag(clusterconfig.ClusterNameTag, *accessConfig.ClusterName)
if errAPIGateway != nil {
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)
errors.PrintError(errAPIGateway)
}
if errVPCLink != nil {
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)
errors.PrintError(errVPCLink)
}
if errAPIGateway == nil && errVPCLink == nil {
if deletedAPIGateway != nil {
fmt.Println("✓")
} else {
fmt.Println("(n/a)")
}
} else {
fmt.Println()
}

fmt.Print("○ deleting dashboard ")
err = awsClient.DeleteDashboard(*accessConfig.ClusterName)
if err != nil {
Expand Down Expand Up @@ -1107,32 +1070,6 @@ func createOrClearDashboard(awsClient *aws.Client, dashboardName string) error {
return nil
}

// createOrReplaceAPIGateway creates an API gateway for the cluster (or clears an existing one if it already exists)
func createOrReplaceAPIGateway(awsClient *aws.Client, clusterName string, tags map[string]string) error {
fmt.Print("○ creating api gateway: ", clusterName)

_, err := awsClient.DeleteVPCLinkByTag(clusterconfig.ClusterNameTag, clusterName)
if err != nil {
fmt.Print("\n\n")
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))
}

_, err = awsClient.DeleteAPIGatewayByTag(clusterconfig.ClusterNameTag, clusterName)
if err != nil {
fmt.Print("\n\n")
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))
}

_, err = awsClient.CreateAPIGateway(clusterName, tags)
if err != nil {
fmt.Print("\n\n")
return err
}

fmt.Println(" ✓")
return nil
}

// Will return error if load balancer can't be found
func getAWSOperatorLoadBalancer(clusterName string, awsClient *aws.Client) (*elbv2.LoadBalancer, error) {
loadBalancer, err := awsClient.FindLoadBalancer(map[string]string{
Expand Down
19 changes: 2 additions & 17 deletions cli/cmd/lib_cluster_config_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,6 @@ func setConfigFieldsFromCached(userClusterConfig *clusterconfig.Config, cachedCl
}
userClusterConfig.OperatorLoadBalancerScheme = cachedClusterConfig.OperatorLoadBalancerScheme

if userClusterConfig.APIGatewaySetting != cachedClusterConfig.APIGatewaySetting {
return clusterconfig.ErrorConfigCannotBeChangedOnUpdate(clusterconfig.APIGatewaySettingKey, cachedClusterConfig.APIGatewaySetting)
}
userClusterConfig.APIGatewaySetting = cachedClusterConfig.APIGatewaySetting

if s.Obj(cachedClusterConfig.VPCCIDR) != s.Obj(userClusterConfig.VPCCIDR) {
return clusterconfig.ErrorConfigCannotBeChangedOnUpdate(clusterconfig.VPCCIDRKey, cachedClusterConfig.VPCCIDR)
}
Expand Down Expand Up @@ -404,10 +399,7 @@ func setConfigFieldsFromCached(userClusterConfig *clusterconfig.Config, cachedCl
userClusterConfig.Spot = cachedClusterConfig.Spot

if userClusterConfig.Spot != nil && *userClusterConfig.Spot {
err := userClusterConfig.FillEmptySpotFields(awsClient)
if err != nil {
return err
}
userClusterConfig.FillEmptySpotFields()
}

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

if clusterConfig.APIGatewaySetting == clusterconfig.NoneAPIGatewaySetting {
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))
}

if clusterConfig.OperatorLoadBalancerScheme == clusterconfig.InternalLoadBalancerScheme {
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))
}
Expand Down Expand Up @@ -618,16 +606,13 @@ func clusterConfigConfirmationStr(clusterConfig clusterconfig.Config, awsCreds A
if clusterConfig.OperatorLoadBalancerScheme != defaultConfig.OperatorLoadBalancerScheme {
items.Add(clusterconfig.OperatorLoadBalancerSchemeUserKey, clusterConfig.OperatorLoadBalancerScheme)
}
if clusterConfig.APIGatewaySetting != defaultConfig.APIGatewaySetting {
items.Add(clusterconfig.APIGatewaySettingUserKey, clusterConfig.APIGatewaySetting)
}

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

if clusterConfig.SpotConfig != nil {
defaultSpotConfig := clusterconfig.SpotConfig{}
clusterconfig.AutoGenerateSpotConfig(awsClient, &defaultSpotConfig, *clusterConfig.Region, *clusterConfig.InstanceType)
clusterconfig.AutoGenerateSpotConfig(&defaultSpotConfig, *clusterConfig.Region, *clusterConfig.InstanceType)

if !strset.New(clusterConfig.SpotConfig.InstanceDistribution...).IsEqual(strset.New(defaultSpotConfig.InstanceDistribution...)) {
items.Add(clusterconfig.InstanceDistributionUserKey, clusterConfig.SpotConfig.InstanceDistribution)
Expand Down
8 changes: 6 additions & 2 deletions dev/find_missing_docs_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_links_from_file(file):
with open(file) as f:
for line in f:
for link in re.findall(r"\]\((.+?)\)", line):
if link.startswith("http"):
if is_external_link(link):
link_infos.append((file, n, link, None, None))
continue
if link.startswith("#"):
Expand Down Expand Up @@ -87,7 +87,7 @@ def check_links(link_infos):

for link_info in link_infos:
src_file, line_num, original_link_text, target_file, header = link_info
if original_link_text.startswith("http"):
if is_external_link(original_link_text):
http_link_infos.append(link_info)
continue

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


def is_external_link(link):
return link.startswith("http://") or link.startswith("https://")


if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions dev/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ xargs -0 -L1 bash -c 'test "$(tail -c 1 "$0")" && echo "" >> "$0"' || true)
! -path "./.git/*" \
! -name ".*" \
-print0 | \
xargs -0 -L1 bash -c 'test "$(tail -c 2 "$0")" || (trimmed=$(printf "%s" "$(< $0)") && echo "$trimmed" > "$0")' || true)
xargs -0 -L1 bash -c 'test "$(tail -c 2 "$0")" || [ ! -s "$0" ] || (trimmed=$(printf "%s" "$(< $0)") && echo "$trimmed" > "$0")' || true)

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