From 0d0a7e62efe795eaa03a0f2dab1143ee3d82df15 Mon Sep 17 00:00:00 2001 From: David Eliahu Date: Sun, 6 Sep 2020 20:42:38 -0700 Subject: [PATCH 1/4] Rename cluster api_gateway config values to match API config --- cli/cmd/cluster.go | 6 +++--- cli/cmd/lib_cluster_config.go | 2 +- docs/cluster-management/config.md | 6 +++--- docs/deployments/networking.md | 2 +- manager/info.sh | 4 ++-- manager/install.sh | 4 ++-- pkg/operator/config/config.go | 2 +- pkg/operator/resources/validations.go | 2 +- pkg/types/clusterconfig/api_gateway_setting.go | 8 ++++---- pkg/types/clusterconfig/clusterconfig.go | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/cli/cmd/cluster.go b/cli/cmd/cluster.go index 84b5069d06..4fdde8f707 100644 --- a/cli/cmd/cluster.go +++ b/cli/cmd/cluster.go @@ -153,7 +153,7 @@ var _upCmd = &cobra.Command{ exit.Error(err) } - if clusterConfig.APIGatewaySetting == clusterconfig.EnabledAPIGatewaySetting { + if clusterConfig.APIGatewaySetting == clusterconfig.PublicAPIGatewaySetting { err = createOrReplaceAPIGateway(awsClient, clusterConfig.ClusterName, clusterConfig.Tags) if err != nil { exit.Error(err) @@ -162,14 +162,14 @@ var _upCmd = &cobra.Command{ out, exitCode, err := runManagerWithClusterConfig("/root/install.sh", clusterConfig, awsCreds, _flagClusterEnv) if err != nil { - if clusterConfig.APIGatewaySetting == clusterconfig.EnabledAPIGatewaySetting { + 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.EnabledAPIGatewaySetting { + if clusterConfig.APIGatewaySetting == clusterconfig.PublicAPIGatewaySetting { awsClient.DeleteAPIGatewayByTag(clusterconfig.ClusterNameTag, clusterConfig.ClusterName) // best effort deletion awsClient.DeleteVPCLinkByTag(clusterconfig.ClusterNameTag, clusterConfig.ClusterName) // best effort deletion } diff --git a/cli/cmd/lib_cluster_config.go b/cli/cmd/lib_cluster_config.go index bf67d051f7..4ac470adce 100644 --- a/cli/cmd/lib_cluster_config.go +++ b/cli/cmd/lib_cluster_config.go @@ -464,7 +464,7 @@ 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.LogGroup, privateSubnetMsg) - if clusterConfig.APIGatewaySetting == clusterconfig.DisabledAPIGatewaySetting { + if clusterConfig.APIGatewaySetting == clusterconfig.NoneAPIGatewaySetting { fmt.Print("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/deployments/networking for more information)\n\n") } diff --git a/docs/cluster-management/config.md b/docs/cluster-management/config.md index f38c077851..2ecc1ee344 100644 --- a/docs/cluster-management/config.md +++ b/docs/cluster-management/config.md @@ -67,9 +67,9 @@ api_load_balancer_scheme: internet-facing # must be "internet-facing" or "inter operator_load_balancer_scheme: internet-facing # must be "internet-facing" or "internal" # whether to disable API gateway cluster-wide -# if set to "enabled" (the default), each API can specify whether to use API Gateway -# if set to "disabled", no APIs will be allowed to use API Gateway -api_gateway: enabled # must be "enabled" or "disabled" +# if set to "public" (the default), each API can specify whether to use API Gateway +# if set to "none", no APIs will be allowed to use API Gateway +api_gateway: public # must be "public" or "none" # CloudWatch log group for cortex (default: ) log_group: cortex diff --git a/docs/deployments/networking.md b/docs/deployments/networking.md index 1f75d80f77..a67d81ae63 100644 --- a/docs/deployments/networking.md +++ b/docs/deployments/networking.md @@ -4,7 +4,7 @@ _WARNING: you are on the master branch, please refer to the docs on the branch t ![api architecture diagram](https://user-images.githubusercontent.com/808475/84695323-8507dd00-aeff-11ea-8b32-5a55cef76c79.png) -APIs are deployed with a public API Gateway by default (the API Gateway forwards requests to the API load balancer). Each API can be independently configured to not create the API Gateway endpoint by setting `api_gateway: none` in the `networking` field of the [Realtime API configuration](realtime-api/api-configuration.md) and [Batch API configuration](batch-api/api-configuration.md). If the API Gateway endpoint is not created, your API can still be accessed via the API load balancer; `cortex get API_NAME` will show the load balancer endpoint if API Gateway is disabled. API Gateway is enabled by default, and is generally recommended unless it doesn't support your use case due to limitations such as the 29 second request timeout, or if you are keeping your APIs private to your VPC. See below for common configurations. To disable API Gateway cluster-wide (thereby enforcing that all APIs cannot create API Gateway endpoints), set `api_gateway: disabled` in your [cluster configuration](../cluster-management/config.md) file (before creating your cluster). +APIs are deployed with a public API Gateway by default (the API Gateway forwards requests to the API load balancer). Each API can be independently configured to not create the API Gateway endpoint by setting `api_gateway: none` in the `networking` field of the [Realtime API configuration](realtime-api/api-configuration.md) and [Batch API configuration](batch-api/api-configuration.md). If the API Gateway endpoint is not created, your API can still be accessed via the API load balancer; `cortex get API_NAME` will show the load balancer endpoint if API Gateway is disabled. API Gateway is enabled by default, and is generally recommended unless it doesn't support your use case due to limitations such as the 29 second request timeout, or if you are keeping your APIs private to your VPC. See below for common configurations. To disable API Gateway cluster-wide (thereby enforcing that all APIs cannot create API Gateway endpoints), set `api_gateway: none` in your [cluster configuration](../cluster-management/config.md) file (before creating your cluster). By default, the API load balancer is public. You can configure your API load balancer to be private by setting `api_load_balancer_scheme: internal` in your [cluster configuration](../cluster-management/config.md) file (before creating your cluster). This will force external traffic to go through your API Gateway endpoint, or if you disabled API Gateway for your API, it will make your API only accessible through VPC Peering. Note that if API Gateway is used, endpoints will be public regardless of `api_load_balancer_scheme`. See below for common configurations. diff --git a/manager/info.sh b/manager/info.sh index 142cb64297..4b92e6730d 100755 --- a/manager/info.sh +++ b/manager/info.sh @@ -37,13 +37,13 @@ eksctl utils write-kubeconfig --cluster=$CORTEX_CLUSTER_NAME --region=$CORTEX_RE operator_endpoint=$(get_operator_endpoint) api_load_balancer_endpoint=$(get_api_load_balancer_endpoint) -if [ "$CORTEX_API_GATEWAY" == "enabled" ]; then +if [ "$CORTEX_API_GATEWAY" == "public" ]; then api_gateway_endpoint=$(get_api_gateway_endpoint) fi echo -e "\033[1mendpoints:\033[0m" echo "operator: $operator_endpoint" # before modifying this, search for this prefix echo "api load balancer: $api_load_balancer_endpoint" -if [ "$CORTEX_API_GATEWAY" == "enabled" ]; then +if [ "$CORTEX_API_GATEWAY" == "public" ]; then echo "api gateway: $api_gateway_endpoint" fi diff --git a/manager/install.sh b/manager/install.sh index 210bcb67c7..775dae479b 100755 --- a/manager/install.sh +++ b/manager/install.sh @@ -167,7 +167,7 @@ function main() { ensure_eks # create VPC Link for API Gateway - if [ "$arg1" != "--update" ] && [ "$CORTEX_API_LOAD_BALANCER_SCHEME" == "internal" ] && [ "$CORTEX_API_GATEWAY" == "enabled" ]; then + if [ "$arg1" != "--update" ] && [ "$CORTEX_API_LOAD_BALANCER_SCHEME" == "internal" ] && [ "$CORTEX_API_GATEWAY" == "public" ]; then vpc_id=$(aws ec2 describe-vpcs --region $CORTEX_REGION --filters Name=tag:eksctl.cluster.k8s.io/v1alpha1/cluster-name,Values=$CORTEX_CLUSTER_NAME | jq .Vpcs[0].VpcId | tr -d '"') if [ "$vpc_id" = "" ] || [ "$vpc_id" = "null" ]; then echo "unable to find cortex vpc" @@ -247,7 +247,7 @@ function main() { fi # add VPC Link integration to API Gateway - if [ "$arg1" != "--update" ] && [ "$CORTEX_API_LOAD_BALANCER_SCHEME" == "internal" ] && [ "$CORTEX_API_GATEWAY" == "enabled" ]; then + if [ "$arg1" != "--update" ] && [ "$CORTEX_API_LOAD_BALANCER_SCHEME" == "internal" ] && [ "$CORTEX_API_GATEWAY" == "public" ]; then echo -n "○ creating api gateway vpc link integration " api_id=$(python get_api_gateway_id.py) python create_gateway_integration.py $api_id $vpc_link_id diff --git a/pkg/operator/config/config.go b/pkg/operator/config/config.go index f9423fe17b..4859fc4c46 100644 --- a/pkg/operator/config/config.go +++ b/pkg/operator/config/config.go @@ -86,7 +86,7 @@ func Init() error { fmt.Println(errors.Message(err)) } - if Cluster.APIGatewaySetting == clusterconfig.EnabledAPIGatewaySetting { + if Cluster.APIGatewaySetting == clusterconfig.PublicAPIGatewaySetting { apiGateway, err := AWS.GetAPIGatewayByTag(clusterconfig.ClusterNameTag, Cluster.ClusterName) if err != nil { return err diff --git a/pkg/operator/resources/validations.go b/pkg/operator/resources/validations.go index c8265ff97d..c4e7c89844 100644 --- a/pkg/operator/resources/validations.go +++ b/pkg/operator/resources/validations.go @@ -127,7 +127,7 @@ func ValidateClusterAPIs(apis []userconfig.API, projectFiles spec.ProjectFiles) } } - if api.Networking.APIGateway != userconfig.NoneAPIGatewayType && config.Cluster.APIGatewaySetting == clusterconfig.DisabledAPIGatewaySetting { + if api.Networking.APIGateway != userconfig.NoneAPIGatewayType && config.Cluster.APIGatewaySetting == clusterconfig.NoneAPIGatewaySetting { return errors.Wrap(ErrorAPIGatewayDisabled(api.Networking.APIGateway), api.Identify(), userconfig.NetworkingKey, userconfig.APIGatewayKey) } } diff --git a/pkg/types/clusterconfig/api_gateway_setting.go b/pkg/types/clusterconfig/api_gateway_setting.go index 3892f6ec3b..2546bbd612 100644 --- a/pkg/types/clusterconfig/api_gateway_setting.go +++ b/pkg/types/clusterconfig/api_gateway_setting.go @@ -17,14 +17,14 @@ type APIGatewaySetting int const ( UnknownAPIGatewaySetting APIGatewaySetting = iota - EnabledAPIGatewaySetting - DisabledAPIGatewaySetting + PublicAPIGatewaySetting + NoneAPIGatewaySetting ) var _apiGatewaySettings = []string{ "unknown", - "enabled", - "disabled", + "public", + "none", } func APIGatewaySettingFromString(s string) APIGatewaySetting { diff --git a/pkg/types/clusterconfig/clusterconfig.go b/pkg/types/clusterconfig/clusterconfig.go index 02df5e5cd6..8021adb3f3 100644 --- a/pkg/types/clusterconfig/clusterconfig.go +++ b/pkg/types/clusterconfig/clusterconfig.go @@ -322,7 +322,7 @@ var UserValidation = &cr.StructValidation{ StructField: "APIGatewaySetting", StringValidation: &cr.StringValidation{ AllowedValues: APIGatewaySettingStrings(), - Default: EnabledAPIGatewaySetting.String(), + Default: PublicAPIGatewaySetting.String(), }, Parser: func(str string) (interface{}, error) { return APIGatewaySettingFromString(str), nil From b12b1c7afb886f3dc8506c7e2db0c0c1e930dc3b Mon Sep 17 00:00:00 2001 From: David Eliahu Date: Sun, 6 Sep 2020 20:58:19 -0700 Subject: [PATCH 2/4] Set default api gateway value to none if disabled cluster-wide --- cli/local/deploy.go | 2 +- .../batch-api/api-configuration.md | 6 +-- .../realtime-api/api-configuration.md | 6 +-- .../realtime-api/traffic-splitter.md | 2 +- pkg/operator/resources/resources.go | 2 +- pkg/types/spec/validations.go | 37 +++++++++++++++---- 6 files changed, 38 insertions(+), 17 deletions(-) diff --git a/cli/local/deploy.go b/cli/local/deploy.go index 75daa45214..ff9a091491 100644 --- a/cli/local/deploy.go +++ b/cli/local/deploy.go @@ -62,7 +62,7 @@ func Deploy(env cliconfig.Environment, configPath string, projectFileList []stri } } - apiConfigs, err := spec.ExtractAPIConfigs(configBytes, types.LocalProviderType, configFileName) + apiConfigs, err := spec.ExtractAPIConfigs(configBytes, types.LocalProviderType, configFileName, nil) if err != nil { return schema.DeployResponse{}, err } diff --git a/docs/deployments/batch-api/api-configuration.md b/docs/deployments/batch-api/api-configuration.md index b914205935..744e41233d 100644 --- a/docs/deployments/batch-api/api-configuration.md +++ b/docs/deployments/batch-api/api-configuration.md @@ -20,7 +20,7 @@ Reference the section below which corresponds to your Predictor type: [Python](# env: # dictionary of environment variables networking: endpoint: # the endpoint for the API (default: ) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per worker, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per worker (default: 0) @@ -55,7 +55,7 @@ See additional documentation for [compute](../compute.md), [networking](../netwo env: # dictionary of environment variables networking: endpoint: # the endpoint for the API (default: ) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per worker, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per worker (default: 0) @@ -85,7 +85,7 @@ See additional documentation for [compute](../compute.md), [networking](../netwo env: # dictionary of environment variables networking: endpoint: # the endpoint for the API (default: ) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per worker, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per worker (default: 0) diff --git a/docs/deployments/realtime-api/api-configuration.md b/docs/deployments/realtime-api/api-configuration.md index 792a7ef701..a9d2ab3c82 100644 --- a/docs/deployments/realtime-api/api-configuration.md +++ b/docs/deployments/realtime-api/api-configuration.md @@ -23,7 +23,7 @@ Reference the section below which corresponds to your Predictor type: [Python](# networking: endpoint: # the endpoint for the API (aws only) (default: ) local_port: # specify the port for API (local only) (default: 8888) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per replica, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per replica (default: 0) @@ -80,7 +80,7 @@ See additional documentation for [parallelism](parallelism.md), [autoscaling](au networking: endpoint: # the endpoint for the API (aws only) (default: ) local_port: # specify the port for API (local only) (default: 8888) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per replica, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per replica (default: 0) @@ -132,7 +132,7 @@ See additional documentation for [parallelism](parallelism.md), [autoscaling](au networking: endpoint: # the endpoint for the API (aws only) (default: ) local_port: # specify the port for API (local only) (default: 8888) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per replica, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per replica (default: 0) diff --git a/docs/deployments/realtime-api/traffic-splitter.md b/docs/deployments/realtime-api/traffic-splitter.md index e2522f1b65..daf50be4a0 100644 --- a/docs/deployments/realtime-api/traffic-splitter.md +++ b/docs/deployments/realtime-api/traffic-splitter.md @@ -17,7 +17,7 @@ Traffic Splitter expects the target Realtime APIs to already be running or be in kind: TrafficSplitter # must be "TrafficSplitter", create an Traffic Splitter which routes traffic to multiple Realtime APIs networking: endpoint: # the endpoint for the Traffic Splitter (default: ) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) apis: # list of Realtime APIs to target - name: # name of a Realtime API that is already running or is included in the same configuration file (required) weight: # percentage of traffic to route to the Realtime API (all weights must sum to 100) (required) diff --git a/pkg/operator/resources/resources.go b/pkg/operator/resources/resources.go index d28a5150c5..6fa5506a4b 100644 --- a/pkg/operator/resources/resources.go +++ b/pkg/operator/resources/resources.go @@ -86,7 +86,7 @@ func Deploy(projectBytes []byte, configFileName string, configBytes []byte, forc ConfigFileName: configFileName, } - apiConfigs, err := spec.ExtractAPIConfigs(configBytes, types.AWSProviderType, configFileName) + apiConfigs, err := spec.ExtractAPIConfigs(configBytes, types.AWSProviderType, configFileName, &config.Cluster.Config) if err != nil { return nil, err } diff --git a/pkg/types/spec/validations.go b/pkg/types/spec/validations.go index 1dd27515b2..91aea7c514 100644 --- a/pkg/types/spec/validations.go +++ b/pkg/types/spec/validations.go @@ -41,19 +41,25 @@ import ( libtime "github.com/cortexlabs/cortex/pkg/lib/time" "github.com/cortexlabs/cortex/pkg/lib/urls" "github.com/cortexlabs/cortex/pkg/types" + "github.com/cortexlabs/cortex/pkg/types/clusterconfig" "github.com/cortexlabs/cortex/pkg/types/userconfig" kresource "k8s.io/apimachinery/pkg/api/resource" ) var AutoscalingTickInterval = 10 * time.Second -func apiValidation(provider types.ProviderType, resource userconfig.Resource) *cr.StructValidation { +func apiValidation( + provider types.ProviderType, + resource userconfig.Resource, + clusterConfig *clusterconfig.Config, // should be omitted if running locally +) *cr.StructValidation { + structFieldValidations := []*cr.StructFieldValidation{} switch resource.Kind { case userconfig.RealtimeAPIKind: structFieldValidations = append(resourceStructValidations, predictorValidation(), - networkingValidation(resource.Kind), + networkingValidation(resource.Kind, clusterConfig), computeValidation(provider), monitoringValidation(), autoscalingValidation(provider), @@ -62,13 +68,13 @@ func apiValidation(provider types.ProviderType, resource userconfig.Resource) *c case userconfig.BatchAPIKind: structFieldValidations = append(resourceStructValidations, predictorValidation(), - networkingValidation(resource.Kind), + networkingValidation(resource.Kind, clusterConfig), computeValidation(provider), ) case userconfig.TrafficSplitterKind: structFieldValidations = append(resourceStructValidations, multiAPIsValidation(), - networkingValidation(resource.Kind), + networkingValidation(resource.Kind, clusterConfig), ) } return &cr.StructValidation{ @@ -253,7 +259,16 @@ func monitoringValidation() *cr.StructFieldValidation { } } -func networkingValidation(kind userconfig.Kind) *cr.StructFieldValidation { +func networkingValidation( + kind userconfig.Kind, + clusterConfig *clusterconfig.Config, // should be omitted if running locally +) *cr.StructFieldValidation { + + defaultAPIGatewayType := userconfig.PublicAPIGatewayType + if clusterConfig != nil && clusterConfig.APIGatewaySetting == clusterconfig.NoneAPIGatewaySetting { + defaultAPIGatewayType = userconfig.NoneAPIGatewayType + } + structFieldValidation := []*cr.StructFieldValidation{ { StructField: "Endpoint", @@ -266,7 +281,7 @@ func networkingValidation(kind userconfig.Kind) *cr.StructFieldValidation { StructField: "APIGateway", StringValidation: &cr.StringValidation{ AllowedValues: userconfig.APIGatewayTypeStrings(), - Default: userconfig.PublicAPIGatewayType.String(), + Default: defaultAPIGatewayType.String(), }, Parser: func(str string) (interface{}, error) { return userconfig.APIGatewayTypeFromString(str), nil @@ -570,7 +585,13 @@ var resourceStructValidation = cr.StructValidation{ StructFieldValidations: resourceStructValidations, } -func ExtractAPIConfigs(configBytes []byte, provider types.ProviderType, configFileName string) ([]userconfig.API, error) { +func ExtractAPIConfigs( + configBytes []byte, + provider types.ProviderType, + configFileName string, + clusterConfig *clusterconfig.Config, // should be omitted if running locally +) ([]userconfig.API, error) { + var err error configData, err := cr.ReadYAMLBytes(configBytes) @@ -607,7 +628,7 @@ func ExtractAPIConfigs(configBytes []byte, provider types.ProviderType, configFi } } - errs = cr.Struct(&api, data, apiValidation(provider, resourceStruct)) + errs = cr.Struct(&api, data, apiValidation(provider, resourceStruct, clusterConfig)) if errors.HasError(errs) { name, _ := data[userconfig.NameKey].(string) kindString, _ := data[userconfig.KindKey].(string) From fa073864d25857007cecd137ad7b642613e03fc9 Mon Sep 17 00:00:00 2001 From: David Eliahu Date: Sun, 6 Sep 2020 21:03:53 -0700 Subject: [PATCH 3/4] Update error message --- pkg/operator/resources/errors.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/operator/resources/errors.go b/pkg/operator/resources/errors.go index cd96120f92..435460f3a4 100644 --- a/pkg/operator/resources/errors.go +++ b/pkg/operator/resources/errors.go @@ -95,13 +95,8 @@ func ErrorAPIsNotDeployed(notDeployedAPIs []string) error { } func ErrorAPIGatewayDisabled(apiGatewayType userconfig.APIGatewayType) error { - msg := fmt.Sprintf("%s is not permitted because api gateway is disabled cluster-wide", s.UserStr(apiGatewayType)) - if apiGatewayType == userconfig.PublicAPIGatewayType { - msg += fmt.Sprintf(" (%s is the default value, and the valid values are %s)", s.UserStr(userconfig.PublicAPIGatewayType), s.UserStrsAnd(userconfig.APIGatewayTypeStrings())) - } - return errors.WithStack(&errors.Error{ Kind: ErrAPIGatewayDisabled, - Message: msg, + Message: fmt.Sprintf("%s is not permitted because api gateway is disabled cluster-wide (valid values are %s)", s.UserStr(apiGatewayType), s.UserStrsAnd(userconfig.APIGatewayTypeStrings())), }) } From 73ab64488f6b928d55ed58e5f72930b7f979ea95 Mon Sep 17 00:00:00 2001 From: David Eliahu Date: Thu, 10 Sep 2020 15:43:52 -0700 Subject: [PATCH 4/4] Address PR comment --- docs/deployments/batch-api/api-configuration.md | 6 +++--- docs/deployments/realtime-api/api-configuration.md | 6 +++--- docs/deployments/realtime-api/traffic-splitter.md | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/deployments/batch-api/api-configuration.md b/docs/deployments/batch-api/api-configuration.md index 744e41233d..e710298b58 100644 --- a/docs/deployments/batch-api/api-configuration.md +++ b/docs/deployments/batch-api/api-configuration.md @@ -20,7 +20,7 @@ Reference the section below which corresponds to your Predictor type: [Python](# env: # dictionary of environment variables networking: endpoint: # the endpoint for the API (default: ) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the API will still be accessible via the load balancer) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per worker, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per worker (default: 0) @@ -55,7 +55,7 @@ See additional documentation for [compute](../compute.md), [networking](../netwo env: # dictionary of environment variables networking: endpoint: # the endpoint for the API (default: ) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the API will still be accessible via the load balancer) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per worker, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per worker (default: 0) @@ -85,7 +85,7 @@ See additional documentation for [compute](../compute.md), [networking](../netwo env: # dictionary of environment variables networking: endpoint: # the endpoint for the API (default: ) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the API will still be accessible via the load balancer) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per worker, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per worker (default: 0) diff --git a/docs/deployments/realtime-api/api-configuration.md b/docs/deployments/realtime-api/api-configuration.md index a9d2ab3c82..577874f138 100644 --- a/docs/deployments/realtime-api/api-configuration.md +++ b/docs/deployments/realtime-api/api-configuration.md @@ -23,7 +23,7 @@ Reference the section below which corresponds to your Predictor type: [Python](# networking: endpoint: # the endpoint for the API (aws only) (default: ) local_port: # specify the port for API (local only) (default: 8888) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the API will still be accessible via the load balancer) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per replica, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per replica (default: 0) @@ -80,7 +80,7 @@ See additional documentation for [parallelism](parallelism.md), [autoscaling](au networking: endpoint: # the endpoint for the API (aws only) (default: ) local_port: # specify the port for API (local only) (default: 8888) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the API will still be accessible via the load balancer) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per replica, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per replica (default: 0) @@ -132,7 +132,7 @@ See additional documentation for [parallelism](parallelism.md), [autoscaling](au networking: endpoint: # the endpoint for the API (aws only) (default: ) local_port: # specify the port for API (local only) (default: 8888) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the API will still be accessible via the load balancer) (default: public, unless disabled cluster-wide) compute: cpu: # CPU request per replica, e.g. 200m or 1 (200m is equivalent to 0.2) (default: 200m) gpu: # GPU request per replica (default: 0) diff --git a/docs/deployments/realtime-api/traffic-splitter.md b/docs/deployments/realtime-api/traffic-splitter.md index daf50be4a0..74d27817cc 100644 --- a/docs/deployments/realtime-api/traffic-splitter.md +++ b/docs/deployments/realtime-api/traffic-splitter.md @@ -17,7 +17,7 @@ Traffic Splitter expects the target Realtime APIs to already be running or be in kind: TrafficSplitter # must be "TrafficSplitter", create an Traffic Splitter which routes traffic to multiple Realtime APIs networking: endpoint: # the endpoint for the Traffic Splitter (default: ) - api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the load balancer will be accessed directly) (default: public, unless disabled cluster-wide) + api_gateway: public | none # whether to create a public API Gateway endpoint for this API (if not, the API will still be accessible via the load balancer) (default: public, unless disabled cluster-wide) apis: # list of Realtime APIs to target - name: # name of a Realtime API that is already running or is included in the same configuration file (required) weight: # percentage of traffic to route to the Realtime API (all weights must sum to 100) (required)