From 74543afa29d0760f0bfee625098423adcb429ae7 Mon Sep 17 00:00:00 2001 From: Ty Larrabee Date: Fri, 25 Oct 2019 11:20:01 -0700 Subject: [PATCH 1/2] Add L7 ILB fields to RegionBackendService --- products/compute/api.yaml | 551 +++++++++++++++--- products/compute/terraform.yaml | 18 + ...egion_backend_service_ilb_ring_hash.tf.erb | 35 ++ ...ion_backend_service_ilb_round_robin.tf.erb | 19 + ...compute_region_backend_service_test.go.erb | 274 +++++++++ 5 files changed, 821 insertions(+), 76 deletions(-) create mode 100644 templates/terraform/examples/region_backend_service_ilb_ring_hash.tf.erb create mode 100644 templates/terraform/examples/region_backend_service_ilb_round_robin.tf.erb diff --git a/products/compute/api.yaml b/products/compute/api.yaml index 5e5ae6d81725..23f74c6da36e 100644 --- a/products/compute/api.yaml +++ b/products/compute/api.yaml @@ -658,7 +658,7 @@ objects: endpoints of Network Endpoint Group must be hosted on instances located in the same zone as the Network Endpoint Group. - Backend service can not contain mix of Instance Group and + Backend services cannot mix Instance Group and Network Endpoint Group backends. Note that you must specify an Instance Group or Network Endpoint @@ -1231,9 +1231,6 @@ objects: description: | A Region Backend Service defines a regionally-scoped group of virtual machines that will serve traffic for load balancing. - - Region backend services can only be used when using internal load balancing. - For external load balancing, use a global backend service instead. references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Internal TCP/UDP Load Balancing': 'https://cloud.google.com/compute/docs/load-balancing/internal/' @@ -1256,60 +1253,278 @@ objects: error: !ruby/object:Api::Async::Error path: 'error/errors' message: 'message' - properties: - - !ruby/object:Api::Type::String - name: 'name' - required: true - input: true + parameters: + - !ruby/object:Api::Type::ResourceRef + name: 'region' + resource: 'Region' + imports: 'name' description: | - Name of the resource. Provided by the client when the resource is - created. The name must be 1-63 characters long, and comply with - RFC1035. Specifically, the name must be 1-63 characters long and match - the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the - first character must be a lowercase letter, and all following - characters must be a dash, lowercase letter, or digit, except the last - character, which cannot be a dash. - - !ruby/object:Api::Type::Array - name: 'healthChecks' - item_type: Api::Type::String + A reference to the region where the regional backend service resides. required: true - min_size: 1 - max_size: 1 + properties: + - !ruby/object:Api::Type::Integer + name: 'affinityCookieTtlSec' + min_version: beta description: | - The list of HealthChecks for checking the health of the backend service. - Currently at most one health check can be specified, and a health check - is required. + Lifetime of cookies in seconds if session_affinity is + GENERATED_COOKIE. If set to 0, the cookie is non-persistent and lasts + only until the end of the browser session (or equivalent). The + maximum allowed value for TTL is one day. + + When the load balancing scheme is INTERNAL, this field is not used. - !ruby/object:Api::Type::Array name: 'backends' description: | - The list of backends that serve this RegionBackendService. + The set of backends that serve this RegionBackendService. item_type: !ruby/object:Api::Type::NestedObject properties: + - !ruby/object:Api::Type::Enum + name: 'balancingMode' + default_value: :CONNECTION + values: + - :UTILIZATION + - :RATE + - :CONNECTION + description: | + Specifies the balancing mode for this backend. Defaults to CONNECTION. + - !ruby/object:Api::Type::Double + name: 'capacityScaler' + description: | + A multiplier applied to the group's maximum servicing capacity + (based on UTILIZATION, RATE or CONNECTION). + + A setting of 0 means the group is completely drained, offering + 0% of its available Capacity. Valid range is [0.0,1.0]. - !ruby/object:Api::Type::String name: 'description' description: | An optional description of this resource. Provide this property when you create the resource. + - !ruby/object:Api::Type::Boolean + name: 'failover' + description: | + This field designates whether this is a failover backend. More + than one failover backend can be configured for a given RegionBackendService. + min_version: beta - !ruby/object:Api::Type::String name: 'group' + required: true description: | - The fully-qualified URL of an Instance Group. This defines the list + The fully-qualified URL of an Instance Group or Network Endpoint + Group resource. In case of instance group this defines the list of instances that serve traffic. Member virtual machine instances from each instance group must live in the same zone as the instance group itself. No two backends in a backend service are allowed to use same Instance Group resource. - Note that you must specify an Instance Group - resource using the fully-qualified URL, rather than a + For Network Endpoint Groups this defines list of endpoints. All + endpoints of Network Endpoint Group must be hosted on instances + located in the same zone as the Network Endpoint Group. + + Backend services cannot mix Instance Group and + Network Endpoint Group backends. + + When the `load_balancing_scheme` is INTERNAL, only instance groups + are supported. + + Note that you must specify an Instance Group or Network Endpoint + Group resource using the fully-qualified URL, rather than a partial URL. + - !ruby/object:Api::Type::Integer + name: 'maxConnections' + description: | + The max number of simultaneous connections for the group. Can + be used with either CONNECTION or UTILIZATION balancing modes. - The instance group must be within the same region as the BackendService. - - !ruby/object:Api::Type::Boolean - name: 'failover' + For CONNECTION mode, either maxConnections or one + of maxConnectionsPerInstance or maxConnectionsPerEndpoint, + as appropriate for group type, must be set. + - !ruby/object:Api::Type::Integer + name: 'maxConnectionsPerInstance' description: | - This field designates whether this is a failover backend. More - than one failover backend can be configured for a given BackendService. - min_version: beta + The max number of simultaneous connections that a single + backend instance can handle. This is used to calculate the + capacity of the group. Can be used in either CONNECTION or + UTILIZATION balancing modes. + + For CONNECTION mode, either maxConnections or + maxConnectionsPerInstance must be set. + - !ruby/object:Api::Type::Integer + name: 'maxConnectionsPerEndpoint' + description: | + The max number of simultaneous connections that a single backend + network endpoint can handle. This is used to calculate the + capacity of the group. Can be used in either CONNECTION or + UTILIZATION balancing modes. + + For CONNECTION mode, either + maxConnections or maxConnectionsPerEndpoint must be set. + - !ruby/object:Api::Type::Integer + name: 'maxRate' + description: | + The max requests per second (RPS) of the group. + + Can be used with either RATE or UTILIZATION balancing modes, + but required if RATE mode. Either maxRate or one + of maxRatePerInstance or maxRatePerEndpoint, as appropriate for + group type, must be set. + - !ruby/object:Api::Type::Double + name: 'maxRatePerInstance' + description: | + The max requests per second (RPS) that a single backend + instance can handle. This is used to calculate the capacity of + the group. Can be used in either balancing mode. For RATE mode, + either maxRate or maxRatePerInstance must be set. + - !ruby/object:Api::Type::Double + name: 'maxRatePerEndpoint' + description: | + The max requests per second (RPS) that a single backend network + endpoint can handle. This is used to calculate the capacity of + the group. Can be used in either balancing mode. For RATE mode, + either maxRate or maxRatePerEndpoint must be set. + - !ruby/object:Api::Type::Double + name: 'maxUtilization' + description: | + Used when balancingMode is UTILIZATION. This ratio defines the + CPU utilization target for the group. Valid range is [0.0, 1.0]. + - !ruby/object:Api::Type::NestedObject + name: 'circuitBreakers' + description: | + Settings controlling the volume of connections to a backend service. This field + is applicable only when the `load_balancing_scheme` is set to INTERNAL_MANAGED + and the `protocol` is set to HTTP, HTTPS, or HTTP2. + min_version: beta + properties: + - !ruby/object:Api::Type::NestedObject + name: 'connectTimeout' + description: | + The timeout for new network connections to hosts. + properties: + - !ruby/object:Api::Type::Integer + name: 'seconds' + required: true + description: | + Span of time at a resolution of a second. + Must be from 0 to 315,576,000,000 inclusive. + - !ruby/object:Api::Type::Integer + name: 'nanos' + description: | + Span of time that's a fraction of a second at nanosecond + resolution. Durations less than one second are represented + with a 0 seconds field and a positive nanos field. Must + be from 0 to 999,999,999 inclusive. + - !ruby/object:Api::Type::Integer + name: 'maxRequestsPerConnection' + description: | + Maximum requests for a single backend connection. This parameter + is respected by both the HTTP/1.1 and HTTP/2 implementations. If + not specified, there is no limit. Setting this parameter to 1 + will effectively disable keep alive. + - !ruby/object:Api::Type::Integer + name: 'maxConnections' + default_value: 1024 + description: | + The maximum number of connections to the backend cluster. + Defaults to 1024. + - !ruby/object:Api::Type::Integer + name: 'maxPendingRequests' + default_value: 1024 + description: | + The maximum number of pending requests to the backend cluster. + Defaults to 1024. + - !ruby/object:Api::Type::Integer + name: 'maxRequests' + default_value: 1024 + description: | + The maximum number of parallel requests to the backend cluster. + Defaults to 1024. + - !ruby/object:Api::Type::Integer + name: 'maxRetries' + default_value: 3 + description: | + The maximum number of parallel retries to the backend cluster. + Defaults to 3. + - !ruby/object:Api::Type::NestedObject + name: 'consistentHash' + description: | + Consistent Hash-based load balancing can be used to provide soft session + affinity based on HTTP headers, cookies or other properties. This load balancing + policy is applicable only for HTTP connections. The affinity to a particular + destination host will be lost when one or more hosts are added/removed from the + destination service. This field specifies parameters that control consistent + hashing. + This field only applies when all of the following are true - + * `load_balancing_scheme` is set to INTERNAL_MANAGED + * `protocol` is set to HTTP, HTTPS, or HTTP2 + * `locality_lb_policy` is set to MAGLEV or RING_HASH + min_version: beta + properties: + - !ruby/object:Api::Type::NestedObject + name: 'httpCookie' + description: | + Hash is based on HTTP Cookie. This field describes a HTTP cookie + that will be used as the hash key for the consistent hash load + balancer. If the cookie is not present, it will be generated. + This field is applicable if the sessionAffinity is set to HTTP_COOKIE. + properties: + - !ruby/object:Api::Type::NestedObject + name: 'ttl' + description: | + Liftime of the cookie. + properties: + - !ruby/object:Api::Type::Integer + name: 'seconds' + required: true + description: | + Span of time at a resolution of a second. + Must be from 0 to 315,576,000,000 inclusive. + - !ruby/object:Api::Type::Integer + name: 'nanos' + description: | + Span of time that's a fraction of a second at nanosecond + resolution. Durations less than one second are represented + with a 0 seconds field and a positive nanos field. Must + be from 0 to 999,999,999 inclusive. + - !ruby/object:Api::Type::String + name: 'name' + description: | + Name of the cookie. + - !ruby/object:Api::Type::String + name: 'path' + description: | + Path to set for the cookie. + - !ruby/object:Api::Type::String + name: 'httpHeaderName' + description: | + The hash based on the value of the specified header field. + This field is applicable if the sessionAffinity is set to HEADER_FIELD. + - !ruby/object:Api::Type::Integer + name: 'minimumRingSize' + default_value: 1024 + description: | + The minimum number of virtual nodes to use for the hash ring. + Larger ring sizes result in more granular load + distributions. If the number of hosts in the load balancing pool + is larger than the ring size, each host will be assigned a single + virtual node. + Defaults to 1024. + - !ruby/object:Api::Type::NestedObject + name: 'connectionDraining' + description: | + Settings for connection draining + properties: + - !ruby/object:Api::Type::Integer + name: 'drainingTimeoutSec' + default_value: 300 + description: | + Time for which instance will be drained (not accept new + connections, but still work to finish started). + - !ruby/object:Api::Type::Time + name: 'creationTimestamp' + description: | + Creation timestamp in RFC3339 text format. + output: true + # customRequestHeaders only supported for EXTERNAL load balancing - !ruby/object:Api::Type::String name: 'description' description: | @@ -1329,9 +1544,7 @@ objects: use the timeout of 10 min (currently fixed). Setting to false has the following effect: both old and new connections will have a drain timeout of 10 min. - This can be set to true only if the protocol is TCP. - The default is false. - !ruby/object:Api::Type::Boolean name: 'dropTrafficIfUnhealthy' @@ -1339,7 +1552,6 @@ objects: This option is used only when no healthy VMs are detected in the primary and backup instance groups. When set to true, traffic is dropped. When set to false, new connections are sent across all VMs in the primary group. - The default is false. - !ruby/object:Api::Type::Double name: 'failoverRatio' @@ -1347,12 +1559,10 @@ objects: The value of the field must be in [0, 1]. If the ratio of the healthy VMs in the primary backend is at or below this number, traffic arriving at the load-balanced IP will be directed to the failover backend. - In case where 'failoverRatio' is not set or all the VMs in the backup backend are unhealthy, the traffic will be directed back to the primary backend in the "force" mode, where traffic will be spread to the healthy VMs with the best effort, or to all VMs when no VM is healthy. - This field is only used with l4 load balancing. - !ruby/object:Api::Type::Fingerprint name: 'fingerprint' @@ -1360,12 +1570,205 @@ objects: description: | Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. + - !ruby/object:Api::Type::Array + name: 'healthChecks' + item_type: Api::Type::String + required: true + min_size: 1 + max_size: 1 + description: | + The set of URLs to HealthCheck resources for health checking + this RegionBackendService. Currently at most one health + check can be specified, and a health check is required. + - !ruby/object:Api::Type::Integer + name: 'id' + description: 'The unique identifier for the resource.' + output: true - !ruby/object:Api::Type::Enum - name: 'protocol' + name: 'loadBalancingScheme' + input: true description: | - The protocol this BackendService uses to communicate with backends. + Indicates what kind of load balancing this regional backend service + will be used for. A backend service created for one type of load + balancing cannot be used with the other(s). Must be `INTERNAL` or + `INTERNAL_MANAGED`. Defaults to `INTERNAL`. + default_value: :INTERNAL + values: + - :INTERNAL + - :INTERNAL_MANAGED + - !ruby/object:Api::Type::Enum + name: 'localityLbPolicy' + input: true + min_version: beta + values: + - :ROUND_ROBIN + - :LEAST_REQUEST + - :RING_HASH + - :RANDOM + - :ORIGINAL_DESTINATION + - :MAGLEV + description: | + The load balancing algorithm used within the scope of the locality. + The possible values are - + + ROUND_ROBIN - This is a simple policy in which each healthy backend + is selected in round robin order. + + LEAST_REQUEST - An O(1) algorithm which selects two random healthy + hosts and picks the host which has fewer active requests. + + RING_HASH - The ring/modulo hash load balancer implements consistent + hashing to backends. The algorithm has the property that the + addition/removal of a host from a set of N hosts only affects + 1/N of the requests. + + RANDOM - The load balancer selects a random healthy host. + + ORIGINAL_DESTINATION - Backend host is selected based on the client + connection metadata, i.e., connections are opened + to the same address as the destination address of + the incoming connection before the connection + was redirected to the load balancer. + + MAGLEV - used as a drop in replacement for the ring hash load balancer. + Maglev is not as stable as ring hash but has faster table lookup + build times and host selection times. For more information about + Maglev, refer to https://ai.google/research/pubs/pub44824 - The possible values are TCP and UDP, and the default is TCP. + This field is applicable only when the `load_balancing_scheme` is set to + INTERNAL_MANAGED and the `protocol` is set to HTTP, HTTPS, or HTTP2. + - !ruby/object:Api::Type::String + name: 'name' + required: true + input: true + description: | + Name of the resource. Provided by the client when the resource is + created. The name must be 1-63 characters long, and comply with + RFC1035. Specifically, the name must be 1-63 characters long and match + the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the + first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last + character, which cannot be a dash. + - !ruby/object:Api::Type::NestedObject + name: 'outlierDetection' + min_version: beta + description: | + Settings controlling eviction of unhealthy hosts from the load balancing pool. + This field is applicable only when the `load_balancing_scheme` is set + to INTERNAL_MANAGED and the `protocol` is set to HTTP, HTTPS, or HTTP2. + properties: + - !ruby/object:Api::Type::NestedObject + name: 'baseEjectionTime' + description: | + The base time that a host is ejected for. The real time is equal to the base + time multiplied by the number of times the host has been ejected. Defaults to + 30000ms or 30s. + properties: + - !ruby/object:Api::Type::Integer + name: 'seconds' + required: true + description: | + Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 + inclusive. + - !ruby/object:Api::Type::Integer + name: 'nanos' + description: | + Span of time that's a fraction of a second at nanosecond resolution. Durations + less than one second are represented with a 0 `seconds` field and a positive + `nanos` field. Must be from 0 to 999,999,999 inclusive. + - !ruby/object:Api::Type::Integer + name: 'consecutiveErrors' + default_value: 5 + description: | + Number of errors before a host is ejected from the connection pool. When the + backend host is accessed over HTTP, a 5xx return code qualifies as an error. + Defaults to 5. + - !ruby/object:Api::Type::Integer + name: 'consecutiveGatewayFailure' + default_value: 5 + description: | + The number of consecutive gateway failures (502, 503, 504 status or connection + errors that are mapped to one of those status codes) before a consecutive + gateway failure ejection occurs. Defaults to 5. + - !ruby/object:Api::Type::Integer + name: 'enforcingConsecutiveErrors' + default_value: 100 + description: | + The percentage chance that a host will be actually ejected when an outlier + status is detected through consecutive 5xx. This setting can be used to disable + ejection or to ramp it up slowly. Defaults to 100. + - !ruby/object:Api::Type::Integer + name: 'enforcingConsecutiveGatewayFailure' + default_value: 0 + description: | + The percentage chance that a host will be actually ejected when an outlier + status is detected through consecutive gateway failures. This setting can be + used to disable ejection or to ramp it up slowly. Defaults to 0. + - !ruby/object:Api::Type::Integer + name: 'enforcingSuccessRate' + default_value: 100 + description: | + The percentage chance that a host will be actually ejected when an outlier + status is detected through success rate statistics. This setting can be used to + disable ejection or to ramp it up slowly. Defaults to 100. + - !ruby/object:Api::Type::NestedObject + name: 'interval' + description: | + Time interval between ejection sweep analysis. This can result in both new + ejections as well as hosts being returned to service. Defaults to 10 seconds. + properties: + - !ruby/object:Api::Type::Integer + name: 'seconds' + required: true + description: | + Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 + inclusive. + - !ruby/object:Api::Type::Integer + name: 'nanos' + description: | + Span of time that's a fraction of a second at nanosecond resolution. Durations + less than one second are represented with a 0 `seconds` field and a positive + `nanos` field. Must be from 0 to 999,999,999 inclusive. + - !ruby/object:Api::Type::Integer + name: 'maxEjectionPercent' + default_value: 10 + description: | + Maximum percentage of hosts in the load balancing pool for the backend service + that can be ejected. Defaults to 10%. + - !ruby/object:Api::Type::Integer + name: 'successRateMinimumHosts' + default_value: 5 + description: | + The number of hosts in a cluster that must have enough request volume to detect + success rate outliers. If the number of hosts is less than this setting, outlier + detection via success rate statistics is not performed for any host in the + cluster. Defaults to 5. + - !ruby/object:Api::Type::Integer + name: 'successRateRequestVolume' + default_value: 100 + description: | + The minimum number of total requests that must be collected in one interval (as + defined by the interval duration above) to include this host in success rate + based outlier detection. If the volume is lower than this setting, outlier + detection via success rate statistics is not performed for that host. Defaults + to 100. + - !ruby/object:Api::Type::Integer + name: 'successRateStdevFactor' + default_value: 1900 + description: | + This factor is used to determine the ejection threshold for success rate outlier + ejection. The ejection threshold is the difference between the mean success + rate, and the product of this factor and the standard deviation of the mean + success rate: mean - (stdev * success_rate_stdev_factor). This factor is divided + by a thousand to get a double. That is, if the desired factor is 1.9, the + runtime value should be 1900. Defaults to 1900. + - !ruby/object:Api::Type::Enum + name: 'protocol' + description: | + The protocol this RegionBackendService uses to communicate with backends. + Possible values are HTTP, HTTPS, HTTP2, SSL, TCP, and UDP. The default is + HTTP. **NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer + types and may result in errors if used with the GA API. # This is removed to avoid breaking terraform, as default values cannot be # unspecified. Providers should include this as needed via overrides # default_value: :TCP @@ -1379,46 +1782,39 @@ objects: - !ruby/object:Api::Type::Enum name: 'sessionAffinity' description: | - Type of session affinity to use. The default is NONE. - - Can be NONE, CLIENT_IP, CLIENT_IP_PROTO, or CLIENT_IP_PORT_PROTO. - - When the protocol is UDP, this field is not used. + Type of session affinity to use. The default is NONE. Session affinity is + not applicable if the protocol is UDP. values: - :NONE - :CLIENT_IP - - :CLIENT_IP_PROTO - :CLIENT_IP_PORT_PROTO - - !ruby/object:Api::Type::ResourceRef - name: 'region' - resource: 'Region' - imports: 'selfLink' - input: true - description: | - The region where the regional backend service resides. + - :CLIENT_IP_PROTO + - :GENERATED_COOKIE + - :HEADER_FIELD + - :HTTP_COOKIE - !ruby/object:Api::Type::Integer name: 'timeoutSec' description: | How many seconds to wait for the backend before considering it a failed request. Default is 30 seconds. Valid range is [1, 86400]. - !ruby/object:Api::Type::NestedObject - name: 'connectionDraining' + name: 'logConfig' + min_version: beta description: | - Settings for connection draining + This field denotes the logging options for the load balancer traffic served by this backend service. + If logging is enabled, logs will be exported to Stackdriver. properties: - - !ruby/object:Api::Type::Integer - name: 'drainingTimeoutSec' + - !ruby/object:Api::Type::Boolean + name: 'enable' description: | - Time for which instance will be drained (not accept new - connections, but still work to finish started). - - !ruby/object:Api::Type::Enum - name: 'loadBalancingScheme' - description: | - This signifies what the ForwardingRule will be used for and can only - be INTERNAL for RegionBackendServices - default_value: :INTERNAL - values: - - :INTERNAL + Whether to enable logging for the load balancer traffic served by this backend service. + - !ruby/object:Api::Type::Double + name: 'sampleRate' + description: | + This field can only be specified if logging is enabled for this backend service. The value of + the field must be in [0, 1]. This configures the sampling rate of requests to the load balancer + where 1.0 means all logged requests are reported and 0.0 means no logged requests are reported. + The default value is 1.0. - !ruby/object:Api::Resource name: 'BackendServiceSignedUrlKey' kind: 'compute#BackendServiceSignedUrlKey' @@ -2333,14 +2729,17 @@ objects: - !ruby/object:Api::Type::Enum name: 'loadBalancingScheme' description: | - This signifies what the ForwardingRule will be used for and can only - take the following values: INTERNAL, EXTERNAL The value of INTERNAL - means that this will be used for Internal Network Load Balancing (TCP, - UDP). The value of EXTERNAL means that this will be used for External - Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) + This signifies what the ForwardingRule will be used for and can be + EXTERNAL, INTERNAL, or INTERNAL_MANAGED. EXTERNAL is used for Classic + Cloud VPN gateways, protocol forwarding to VMs from an external IP address, + and HTTP(S), SSL Proxy, TCP Proxy, and Network TCP/UDP load balancers. + INTERNAL is used for protocol forwarding to VMs from an internal IP address, + and internal TCP/UDP load balancers. + INTERNAL_MANAGED is used for internal HTTP(S) load balancers. values: - - :INTERNAL - :EXTERNAL + - :INTERNAL + - :INTERNAL_MANAGED - !ruby/object:Api::Type::String name: 'name' description: | @@ -2742,8 +3141,8 @@ objects: load balancing. default_value: :EXTERNAL values: - - :INTERNAL_SELF_MANAGED - :EXTERNAL + - :INTERNAL_SELF_MANAGED - !ruby/object:Api::Type::Array name: 'metadataFilters' description: | diff --git a/products/compute/terraform.yaml b/products/compute/terraform.yaml index 26c7da3ec598..b64dd9fe7654 100644 --- a/products/compute/terraform.yaml +++ b/products/compute/terraform.yaml @@ -264,6 +264,20 @@ overrides: !ruby/object:Overrides::ResourceOverrides vars: region_backend_service_name: "region-backend-service" health_check_name: "health-check" + - !ruby/object:Provider::Terraform::Examples + name: "region_backend_service_ilb_round_robin" + min_version: beta + primary_resource_id: "default" + vars: + region_backend_service_name: "region-backend-service" + health_check_name: "health-check" + - !ruby/object:Provider::Terraform::Examples + name: "region_backend_service_ilb_ring_hash" + min_version: beta + primary_resource_id: "default" + vars: + region_backend_service_name: "region-backend-service" + health_check_name: "health-check" custom_code: !ruby/object:Provider::Terraform::CustomCode constants: 'templates/terraform/constants/migrate_state_noop.go.erb' resource_definition: 'templates/terraform/resource_definition/region_backend_service.go.erb' @@ -282,6 +296,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides backends.group: !ruby/object:Overrides::Terraform::PropertyOverride diff_suppress_func: 'compareSelfLinkRelativePaths' custom_flatten: templates/terraform/custom_flatten/guard_self_link.go.erb + backends.capacityScaler: !ruby/object:Overrides::Terraform::PropertyOverride + default_from_api: true connectionDraining: !ruby/object:Overrides::Terraform::PropertyOverride flatten_object: true connectionDraining.drainingTimeoutSec: !ruby/object:Overrides::Terraform::PropertyOverride @@ -292,6 +308,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides is_set: true set_hash_func: 'selfLinkRelativePathHash' custom_flatten: templates/terraform/custom_flatten/guard_self_link_array.go.erb + id: !ruby/object:Overrides::Terraform::PropertyOverride + exclude: true protocol: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true sessionAffinity: !ruby/object:Overrides::Terraform::PropertyOverride diff --git a/templates/terraform/examples/region_backend_service_ilb_ring_hash.tf.erb b/templates/terraform/examples/region_backend_service_ilb_ring_hash.tf.erb new file mode 100644 index 000000000000..b255aeee763b --- /dev/null +++ b/templates/terraform/examples/region_backend_service_ilb_ring_hash.tf.erb @@ -0,0 +1,35 @@ +resource "google_compute_region_backend_service" "<%= ctx[:primary_resource_id] %>" { + provider = "google-beta" + + region = "us-central1" + name = "<%= ctx[:vars]['region_backend_service_name'] %>" + health_checks = ["${google_compute_health_check.health_check.self_link}"] + load_balancing_scheme = "INTERNAL_MANAGED" + locality_lb_policy = "RING_HASH" + session_affinity = "HTTP_COOKIE" + protocol = "HTTP" + circuit_breakers { + max_connections = 10 + } + consistent_hash { + http_cookie { + ttl { + seconds = 11 + nanos = 1111 + } + name = "mycookie" + } + } + outlier_detection { + consecutive_errors = 2 + } +} + +resource "google_compute_health_check" "health_check" { + provider = "google-beta" + + name = "<%= ctx[:vars]['health_check_name'] %>" + http_health_check { + + } +} diff --git a/templates/terraform/examples/region_backend_service_ilb_round_robin.tf.erb b/templates/terraform/examples/region_backend_service_ilb_round_robin.tf.erb new file mode 100644 index 000000000000..00c4a38d7342 --- /dev/null +++ b/templates/terraform/examples/region_backend_service_ilb_round_robin.tf.erb @@ -0,0 +1,19 @@ +resource "google_compute_region_backend_service" "<%= ctx[:primary_resource_id] %>" { + provider = "google-beta" + + region = "us-central1" + name = "<%= ctx[:vars]['region_backend_service_name'] %>" + health_checks = ["${google_compute_health_check.health_check.self_link}"] + protocol = "HTTP" + load_balancing_scheme = "INTERNAL_MANAGED" + locality_lb_policy = "ROUND_ROBIN" +} + +resource "google_compute_health_check" "health_check" { + provider = "google-beta" + + name = "<%= ctx[:vars]['health_check_name'] %>" + http_health_check { + + } +} diff --git a/third_party/terraform/tests/resource_compute_region_backend_service_test.go.erb b/third_party/terraform/tests/resource_compute_region_backend_service_test.go.erb index 802f15f64b61..79eddd2d37b9 100644 --- a/third_party/terraform/tests/resource_compute_region_backend_service_test.go.erb +++ b/third_party/terraform/tests/resource_compute_region_backend_service_test.go.erb @@ -134,6 +134,280 @@ func TestAccComputeRegionBackendService_withConnectionDrainingAndUpdate(t *testi }) } +<% unless version == 'ga' -%> +func TestAccComputeRegionBackendService_ilbUpdateBasic(t *testing.T) { + t.Parallel() + + backendName := fmt.Sprintf("foo-%s", acctest.RandString(10)) + checkName := fmt.Sprintf("bar-%s", acctest.RandString(10)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckComputeRegionBackendServiceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccComputeRegionBackendService_ilbBasic(backendName, checkName), + }, + { + ResourceName: "google_compute_region_backend_service.foobar", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccComputeRegionBackendService_ilbUpdateBasic(backendName, checkName), + }, + { + ResourceName: "google_compute_region_backend_service.foobar", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} +<% end -%> + +<% unless version == 'ga' -%> +func TestAccComputeRegionBackendService_ilbUpdateFull(t *testing.T) { + t.Parallel() + + randString := acctest.RandString(10) + + backendName := fmt.Sprintf("foo-%s", randString) + checkName := fmt.Sprintf("bar-%s", randString) + igName := fmt.Sprintf("baz-%s", randString) + instanceName := fmt.Sprintf("boz-%s", randString) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckComputeRegionBackendServiceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccComputeRegionBackendService_ilbFull(backendName, checkName), + }, + { + ResourceName: "google_compute_region_backend_service.foobar", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccComputeRegionBackendService_ilbUpdateFull(backendName, igName, instanceName, checkName), + }, + { + ResourceName: "google_compute_region_backend_service.foobar", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} +<% end -%> + +<% unless version == 'ga' -%> +func testAccComputeRegionBackendService_ilbBasic(serviceName, checkName string) string { + return fmt.Sprintf(` +resource "google_compute_region_backend_service" "foobar" { + + name = "%s" + health_checks = ["${google_compute_health_check.health_check.self_link}"] + protocol = "HTTP" + load_balancing_scheme = "INTERNAL_MANAGED" + locality_lb_policy = "RING_HASH" + circuit_breakers { + max_connections = 10 + } + consistent_hash { + http_cookie { + ttl { + seconds = 11 + nanos = 1234 + } + name = "mycookie" + } + } + outlier_detection { + consecutive_errors = 2 + } +} + +resource "google_compute_health_check" "health_check" { + + name = "%s" + http_health_check { + + } +} +`, serviceName, checkName) +} +<% end -%> + +<% unless version == 'ga' -%> +func testAccComputeRegionBackendService_ilbUpdateBasic(serviceName, checkName string) string { + return fmt.Sprintf(` +resource "google_compute_region_backend_service" "foobar" { + + name = "%s" + health_checks = ["${google_compute_health_check.health_check.self_link}"] + protocol = "HTTP" + load_balancing_scheme = "INTERNAL_MANAGED" + locality_lb_policy = "RANDOM" + circuit_breakers { + max_connections = 10 + } + outlier_detection { + consecutive_errors = 2 + } +} + +resource "google_compute_health_check" "health_check" { + + name = "%s" + http_health_check { + + } +} +`, serviceName, checkName) +} +<% end -%> + +<% unless version == 'ga' -%> +func testAccComputeRegionBackendService_ilbFull(serviceName, checkName string) string { + return fmt.Sprintf(` +resource "google_compute_region_backend_service" "foobar" { + + name = "%s" + health_checks = ["${google_compute_health_check.health_check.self_link}"] + protocol = "HTTP" + load_balancing_scheme = "INTERNAL_MANAGED" + locality_lb_policy = "MAGLEV" + circuit_breakers { + max_connections = 10 + } + consistent_hash { + http_cookie { + ttl { + seconds = 11 + nanos = 1234 + } + name = "mycookie" + } + } + outlier_detection { + consecutive_errors = 2 + } +} + +resource "google_compute_health_check" "health_check" { + + name = "%s" + http_health_check { + + } +} +`, serviceName, checkName) +} +<% end -%> + +<% unless version == 'ga' -%> +func testAccComputeRegionBackendService_ilbUpdateFull(serviceName, igName, instanceName, checkName string) string { + return fmt.Sprintf(` +resource "google_compute_region_backend_service" "foobar" { + + name = "%s" + health_checks = ["${google_compute_health_check.health_check.self_link}"] + protocol = "HTTP" + load_balancing_scheme = "INTERNAL_MANAGED" + locality_lb_policy = "MAGLEV" + backend { + balancing_mode = "UTILIZATION" + capacity_scaler = 0.5 + description = "The backend" + group = google_compute_instance_group.group.self_link + max_rate = 6 + max_utilization = 0.5 + } + circuit_breakers { + connect_timeout { + seconds = 3 + nanos = 4 + } + max_connections = 11 + max_requests_per_connection = 12 + max_pending_requests = 13 + max_requests = 14 + max_retries = 15 + } + consistent_hash { + http_cookie { + ttl { + seconds = 12 + } + name = "mycookie2" + path = "mycookie2/path" + } + minimum_ring_size = 16 + } + log_config { + enable = true + sample_rate = 0.5 + } + outlier_detection { + base_ejection_time { + seconds = 0 + nanos = 5 + } + consecutive_errors = 1 + consecutive_gateway_failure = 3 + enforcing_consecutive_errors = 4 + enforcing_consecutive_gateway_failure = 5 + enforcing_success_rate = 6 + interval { + seconds = 7 + } + max_ejection_percent = 99 + success_rate_minimum_hosts = 98 + success_rate_request_volume = 97 + success_rate_stdev_factor = 1800 + } +} + +resource "google_compute_instance_group" "group" { + name = "%s" + instances = [ "${google_compute_instance.ig_instance.self_link}" ] +} + +data "google_compute_image" "my_image" { + family = "debian-9" + project = "debian-cloud" +} + +resource "google_compute_instance" "ig_instance" { + name = "%s" + machine_type = "n1-standard-1" + + boot_disk { + initialize_params { + image = "${data.google_compute_image.my_image.self_link}" + } + } + + network_interface { + network = "default" + } +} + +resource "google_compute_health_check" "health_check" { + + name = "%s" + http_health_check { + + } +} +`, serviceName, igName, instanceName, checkName) +} +<% end -%> + func testAccComputeRegionBackendService_basic(serviceName, checkName string) string { return fmt.Sprintf(` resource "google_compute_region_backend_service" "foobar" { From e9ac54c492640a0dd0c7a67629839b4a5100a1b2 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Tue, 5 Nov 2019 21:54:36 +0000 Subject: [PATCH 2/2] Update tracked submodules -> HEAD on Tue Nov 5 21:54:36 UTC 2019 Tracked submodules are build/terraform-beta build/terraform-mapper build/terraform build/ansible build/inspec. --- build/ansible | 2 +- build/inspec | 2 +- build/terraform | 2 +- build/terraform-beta | 2 +- build/terraform-mapper | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/ansible b/build/ansible index 4462502e9d31..1430a27759f6 160000 --- a/build/ansible +++ b/build/ansible @@ -1 +1 @@ -Subproject commit 4462502e9d3145a5e6b1a65ee860c0f8de1415f8 +Subproject commit 1430a27759f69ea20885c178526ed9b2908da656 diff --git a/build/inspec b/build/inspec index 12e04a04d6d0..04c0f74013da 160000 --- a/build/inspec +++ b/build/inspec @@ -1 +1 @@ -Subproject commit 12e04a04d6d0b232e7d68a08544bf5e5cfdd43bb +Subproject commit 04c0f74013da5df26f1c014091c61348a8bfe1b4 diff --git a/build/terraform b/build/terraform index 98ac61f9da25..c8773fcd69ce 160000 --- a/build/terraform +++ b/build/terraform @@ -1 +1 @@ -Subproject commit 98ac61f9da255256123a237d6c6333ea4aca47df +Subproject commit c8773fcd69ce6fc58380854bef2c672f879c8f0c diff --git a/build/terraform-beta b/build/terraform-beta index 90eb8eaafc78..0ed4068cfbde 160000 --- a/build/terraform-beta +++ b/build/terraform-beta @@ -1 +1 @@ -Subproject commit 90eb8eaafc781a8944df0113903defe95b78c3d5 +Subproject commit 0ed4068cfbdeef40bd065f853233aa6b0b4f90b4 diff --git a/build/terraform-mapper b/build/terraform-mapper index a53dc50a60dc..1dafb0c67f19 160000 --- a/build/terraform-mapper +++ b/build/terraform-mapper @@ -1 +1 @@ -Subproject commit a53dc50a60dc2e30c360a5e80209236c66842f34 +Subproject commit 1dafb0c67f196a235c79d16a3e0036b98f4cad51