terraform-provider-google
terraform-provider-google copied to clipboard
"Either maxRate or maxRatePerEndpoint should be set with RATE mode" when maxRate=0
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
- Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
- If you are interested in working on this issue or have submitted a pull request, please leave a comment.
- If an issue is assigned to the
modular-magician
user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot
, a community member has claimed the issue already.
Terraform Version
Terraform v0.13.5
+ provider registry.terraform.io/hashicorp/google v4.35.0
+ provider registry.terraform.io/hashicorp/google-beta v4.35.0
Affected Resource(s)
- google_compute_backend_service
Terraform Configuration Files
data "google_compute_network_endpoint_group" "backend_1" {
name = "k8s1-primary"
zone = "europe-west3-b"
}
data "google_compute_network_endpoint_group" "backend_2" {
name = "backup"
zone = "us-central1-b"
}
resource "google_compute_backend_service" "test" {
name = "test"
health_checks = [
google_compute_health_check.test.self_link,
]
backend {
group = data.google_compute_network_endpoint_group.backend_1.self_link
balancing_mode = "RATE"
max_rate = 100
capacity_scaler = 1.0
}
backend {
group = data.google_compute_network_endpoint_group.backend_2.self_link
balancing_mode = "RATE"
max_rate = 0
capacity_scaler = 1.0
}
}
resource "google_compute_health_check" "test" {
name = "test-healthcheck"
http_health_check {
request_path = "/healthcheck"
port = 80
}
}
Debug Output
https://gist.github.com/oioki/38256544918caac701f4934fd74c68eb
Expected Behavior
A new HTTP backend service is created with Maximum RPS set to 0.
Actual Behavior
The creation request fails with this error:
Error: Error creating BackendService: googleapi: Error 400: Invalid value for field 'resource.backends[0].balancingMode': 'RATE'. Either maxRate or maxRatePerEndpoint should be set with RATE mode., invalid
Steps to Reproduce
- Set
max_rate
to 0 for one of thebackend
sections ofgoogle_compute_backend_service
resource. - Run
terraform apply
either for resource creation or update.
Important Factoids
Setting max_rate to 0 for a specific backend is valid and ensures no requests are routed to this backend. It is possible to set max_rate to 0 via the Google Cloud console. In the case of the Google Cloud console, the critical part of the request looks like this (captured with Developer Tools):
[
{
"description": "",
"groupUrl": "projects/my-project/zones/europe-west3-b/networkEndpointGroups/k8s1-primary",
"balancingModeType": "MAX_RPS",
"maxRate": {
"intValue": 100000,
"scope": "PER_TARGET"
},
"capacityScaler": 1
},
{
"description": "",
"groupUrl": "projects/my-project/zones/us-central1-b/networkEndpointGroups/backup",
"balancingModeType": "MAX_RPS",
"maxRate": {
"intValue": 0,
"scope": "PER_TARGET"
},
"capacityScaler": 1
}
]
In the case of Terraform, this part looks like this:
{
"balancingMode": "RATE",
"capacityScaler": 1,
"group": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-b/networkEndpointGroups/backup"
},
{
"balancingMode": "RATE",
"capacityScaler": 1,
"group": "https://www.googleapis.com/compute/v1/projects/my-project/zones/europe-west3-b/networkEndpointGroups/k8s1-primary",
"maxRate": 100
}
References
Seems like the behavior of removing "maxRate" field when it's set to "0" value was added in:
- #1053
@oioki it looks like this is the rule for balancing_mode . Did you set it the same for the case of the Google Cloud console?
resource "google_compute_backend_service" "test" {
...
backend {
balancing_mode = "RATE"
...
}
}
Yes, I am keeping "Rate" balancing mode when updating via the Google Cloud console:
@oioki I don't see the balancing_mode in below call. It looks like its default value is UTILIZATION, Can you try sending Rate mode to see what you get?
{
"description": "",
"groupUrl": "projects/my-project/zones/us-central1-b/networkEndpointGroups/backup",
"balancingModeType": "MAX_RPS",
"maxRate": {
"intValue": 0,
"scope": "PER_TARGET"
},
"capacityScaler": 1
}
I have tried setting maxRate = 0 and got the response from api None of the backends have a valid capacity
{
"backends": [
{
"balancingMode": "RATE",
"capacityScaler": 1,
"group": "https://www.googleapis.com/compute/v1/projects/myproject/us-central1-a/networkEndpointGroups/issue12537",
"maxRate": 0
}
],
"connectionDraining": {
"drainingTimeoutSec": 300
},
"healthChecks": [
"projects/myproject/global/healthChecks/issue12537"
],
"iap": {
"enabled": false,
"oauth2ClientId": "",
"oauth2ClientSecret": ""
},
"loadBalancingScheme": "EXTERNAL",
"name": "issue12537"
}
Please provide the debug log that works for you
@oioki is this still an issue?
@oioki I am closing this now, assuming it is no longer an issue.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.