Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EdgeCacheOrigin resources to reflect current API #5776

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
49 changes: 40 additions & 9 deletions mmv1/products/networkservices/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ objects:
description: |
A fully qualified domain name (FQDN) or IP address reachable over the public Internet, or the address of a Google Cloud Storage bucket.

This address will be used as the origin for cache requests - e.g. FQDN: media-backend.example.com IPv4:35.218.1.1 IPv6:[2607:f8b0:4012:809::200e] Cloud Storage: gs://bucketname
This address will be used as the origin for cache requests - e.g. FQDN: media-backend.example.com, IPv4: 35.218.1.1, IPv6: 2607:f8b0:4012:809::200e, Cloud Storage: gs://bucketname

When providing an FQDN (hostname), it must be publicly resolvable (e.g. via Google public DNS) and IP addresses must be publicly routable.
When providing an FQDN (hostname), it must be publicly resolvable (e.g. via Google public DNS) and IP addresses must be publicly routable. It must not contain a protocol (e.g., https://) and it must not contain any slashes.
If a Cloud Storage bucket is provided, it must be in the canonical "gs://bucketname" format. Other forms, such as "storage.googleapis.com", will be rejected.
- !ruby/object:Api::Type::Enum
name: 'protocol' # default http2 from api
Expand Down Expand Up @@ -183,8 +183,8 @@ objects:
The total number of allowed attempts to cache fill across this and failover origins is limited to four.
The total time allowed for cache fill attempts across this and failover origins can be controlled with maxAttemptsTimeout.

The last valid response from an origin will be returned to the client.
If no origin returns a valid response, an HTTP 503 will be returned to the client.
The last valid, non-retried response from all origins will be returned to the client.
If no origin returns a valid response, an HTTP 502 will be returned to the client.

Defaults to 1. Must be a value greater than 0 and less than 4.
- !ruby/object:Api::Type::String
Expand Down Expand Up @@ -215,6 +215,7 @@ objects:
- GATEWAY_ERROR: Similar to 5xx, but only applies to response codes 502, 503 or 504.
- RETRIABLE_4XX: Retry for retriable 4xx response codes, which include HTTP 409 (Conflict) and HTTP 429 (Too Many Requests)
- NOT_FOUND: Retry if the origin returns a HTTP 404 (Not Found). This can be useful when generating video content, and the segment is not available yet.
- FORBIDDEN: Retry if the origin returns a HTTP 403 (Forbidden).
item_type: !ruby/object:Api::Type::Enum
name: 'undefined'
description: |
Expand All @@ -226,6 +227,7 @@ objects:
- :GATEWAY_ERROR
- :RETRIABLE_4XX
- :NOT_FOUND
- :FORBIDDEN
- !ruby/object:Api::Type::NestedObject
name: 'timeout'
description: |
Expand All @@ -234,33 +236,62 @@ objects:
- !ruby/object:Api::Type::String
name: 'connectTimeout'
description: |
The maximum duration to wait for the origin connection to be established, including DNS lookup, TLS handshake and TCP/QUIC connection establishment.
The maximum duration to wait for a single origin connection to be established, including DNS lookup, TLS handshake and TCP/QUIC connection establishment.

Defaults to 5 seconds. The timeout must be a value between 1s and 15s.

The connectTimeout capped by the deadline set by the request's maxAttemptsTimeout. The last connection attempt may have a smaller connectTimeout in order to adhere to the overall maxAttemptsTimeout.

at_least_one_of:
- timeout.0.connect_timeout
- timeout.0.max_attempts_timeout
- timeout.0.response_timeout
- timeout.0.read_timeout
- !ruby/object:Api::Type::String
name: 'maxAttemptsTimeout'
description: |
The maximum time across all connection attempts to the origin, including failover origins, before returning an error to the client. A HTTP 503 will be returned if the timeout is reached before a response is returned.
The maximum time across all connection attempts to the origin, including failover origins, before returning an error to the client. A HTTP 504 will be returned if the timeout is reached before a response is returned.

Defaults to 5 seconds. The timeout must be a value between 1s and 15s.
Defaults to 15 seconds. The timeout must be a value between 1s and 30s.

If a failoverOrigin is specified, the maxAttemptsTimeout of the first configured origin sets the deadline for all connection attempts across all failoverOrigins.
at_least_one_of:
- timeout.0.connect_timeout
- timeout.0.max_attempts_timeout
- timeout.0.response_timeout
- timeout.0.read_timeout
- !ruby/object:Api::Type::String
name: 'responseTimeout'
description: |
The maximum duration to wait for data to arrive when reading from the HTTP connection/stream.
The maximum duration to wait for the last byte of a response to arrive when reading from the HTTP connection/stream.

Defaults to 30 seconds. The timeout must be a value between 1s and 120s.

The responseTimeout starts after the connection has been established.

This also applies to HTTP Chunked Transfer Encoding responses, and/or when an open-ended Range request is made to the origin. Origins that take longer to write additional bytes to the response than the configured responseTimeout will result in an error being returned to the client.

If the response headers have already been written to the connection, the response will be truncated and logged.
at_least_one_of:
- timeout.0.connect_timeout
- timeout.0.max_attempts_timeout
- timeout.0.response_timeout
- timeout.0.read_timeout
- !ruby/object:Api::Type::String
name: 'readTimeout'
description: |
The maximum duration to wait between reads of a single HTTP connection/stream.

Defaults to 15 seconds. The timeout must be a value between 1s and 30s.

The readTimeout is capped by the responseTimeout. All reads of the HTTP connection/stream must be completed by the deadline set by the responseTimeout.

Defaults to 5 seconds. The timeout must be a value between 1s and 30s.
If the response headers have already been written to the connection, the response will be truncated and logged.
at_least_one_of:
- timeout.0.connect_timeout
- timeout.0.max_attempts_timeout
- timeout.0.response_timeout
- timeout.0.read_timeout
- !ruby/object:Api::Resource
name: 'EdgeCacheService'
base_url: 'projects/{{project}}/locations/global/edgeCacheServices'
Expand Down
4 changes: 1 addition & 3 deletions mmv1/products/networkservices/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
retryConditions: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
timeout: !ruby/object:Overrides::Terraform::PropertyOverride
# We don't support ignore_read on nested fields
ignore_read: true # b/192698242
custom_flatten: "templates/terraform/custom_flatten/network_services_timeout_mirror.go.erb"
EdgeCacheService: !ruby/object:Overrides::Terraform::ResourceOverride
docs: !ruby/object:Provider::Terraform::Docs #
Expand Down Expand Up @@ -143,4 +141,4 @@ overrides: !ruby/object:Overrides::ResourceOverrides
routing.pathMatchers.routeRules.urlRedirect.stripQuery: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
logConfig.enable: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
default_from_api: true
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,22 @@
# limitations under the License.
-%>
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} {
out := make(map[string]interface{})
out["connect_timeout"] = d.Get("timeout.0.connect_timeout")
out["max_attempts_timeout"] = d.Get("timeout.0.max_attempts_timeout")
out["responseTimeout"] = d.Get("timeout.0.responseTimeout")
out := make(map[string]string)

if v == nil {
return nil
}

in := v.(map[string]interface{})
for _, names := range []struct{ in, out string }{
{"connectTimeout", "connect_timeout"},
{"maxAttemptsTimeout", "max_attempts_timeout"},
{"responseTimeout", "response_timeout"},
{"readTimeout", "read_timeout"},
} {
if e, ok := in[names.in]; ok {
out[names.out] = e.(string)
}
}
justin-mp marked this conversation as resolved.
Show resolved Hide resolved
return []interface{}{out}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ resource "google_network_services_edge_cache_origin" "fallback" {
retry_conditions = [
"CONNECT_FAILURE",
"NOT_FOUND",
"HTTP_5XX"
"HTTP_5XX",
"FORBIDDEN",
]
timeout {
connect_timeout = "10s"
max_attempts_timeout = "10s"
response_timeout = "10s"
max_attempts_timeout = "20s"
response_timeout = "60s"
read_timeout = "5s"
}
}

Expand All @@ -32,4 +34,4 @@ resource "google_network_services_edge_cache_origin" "<%= ctx[:primary_resource_
timeout {
connect_timeout = "10s"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestAccNetworkServicesEdgeCacheOrigin_updateAndImport(t *testing.T) {
ResourceName: "google_network_services_edge_cache_origin.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "timeout"},
ImportStateVerifyIgnore: []string{"name"},
},
{
Config: testAccNetworkServicesEdgeCacheOrigin_update_1(name),
Expand All @@ -31,7 +31,7 @@ func TestAccNetworkServicesEdgeCacheOrigin_updateAndImport(t *testing.T) {
ResourceName: "google_network_services_edge_cache_origin.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "timeout"},
ImportStateVerifyIgnore: []string{"name"},
},
},
})
Expand All @@ -46,6 +46,7 @@ func testAccNetworkServicesEdgeCacheOrigin_update_0(name string) string {
labels = {
a = "b"
}
retry_conditions = ["NOT_FOUND"]
timeout {
connect_timeout = "10s"
}
Expand All @@ -59,8 +60,12 @@ func testAccNetworkServicesEdgeCacheOrigin_update_1(name string) string {
origin_address = "gs://media-edge-fallback"
description = "The default bucket for media edge test"
max_attempts = 3
retry_conditions = ["FORBIDDEN"]
timeout {
connect_timeout = "9s"
max_attempts_timeout = "14s"
response_timeout = "29s"
read_timeout = "13s"
}
}
`, name)
Expand Down