Skip to content

Commit

Permalink
set optional computed on fields that are conditional to balancing_mode (
Browse files Browse the repository at this point in the history
#4975) (#9587)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jul 19, 2021
1 parent 6cac4b0 commit 3b33d94
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/4975.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: removed default value of `0.8` from `google_backend_service.backend.max_utilization` and it will now default from API. All `max_connections_xxx` and `max_rate_xxx` will also default from API as these are all conditional on balancing mode.
```
13 changes: 9 additions & 4 deletions google/resource_compute_backend_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ Provide this property when you create the resource.`,
},
"max_connections": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `The max number of simultaneous connections for the group. Can
be used with either CONNECTION or UTILIZATION balancing modes.
Expand All @@ -942,6 +943,7 @@ as appropriate for group type, must be set.`,
},
"max_connections_per_endpoint": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `The max number of simultaneous connections that a single backend
network endpoint can handle. This is used to calculate the
Expand All @@ -953,6 +955,7 @@ maxConnections or maxConnectionsPerEndpoint must be set.`,
},
"max_connections_per_instance": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `The max number of simultaneous connections that a single
backend instance can handle. This is used to calculate the
Expand All @@ -964,6 +967,7 @@ maxConnectionsPerInstance must be set.`,
},
"max_rate": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `The max requests per second (RPS) of the group.
Expand All @@ -974,6 +978,7 @@ group type, must be set.`,
},
"max_rate_per_endpoint": {
Type: schema.TypeFloat,
Computed: true,
Optional: true,
Description: `The max requests per second (RPS) that a single backend network
endpoint can handle. This is used to calculate the capacity of
Expand All @@ -982,6 +987,7 @@ either maxRate or maxRatePerEndpoint must be set.`,
},
"max_rate_per_instance": {
Type: schema.TypeFloat,
Computed: true,
Optional: true,
Description: `The max requests per second (RPS) that a single backend
instance can handle. This is used to calculate the capacity of
Expand All @@ -990,11 +996,10 @@ either maxRate or maxRatePerInstance must be set.`,
},
"max_utilization": {
Type: schema.TypeFloat,
Computed: true,
Optional: true,
Description: `Used when balancingMode is UTILIZATION. This ratio defines the
CPU utilization target for the group. The default is 0.8. Valid
range is [0.0, 1.0].`,
Default: 0.8,
CPU utilization target for the group. Valid range is [0.0, 1.0].`,
},
},
}
Expand Down Expand Up @@ -2750,7 +2755,7 @@ func expandComputeBackendServiceBackend(v interface{}, d TerraformResourceData,
transformedMaxUtilization, err := expandComputeBackendServiceBackendMaxUtilization(original["max_utilization"], d, config)
if err != nil {
return nil, err
} else {
} else if val := reflect.ValueOf(transformedMaxUtilization); val.IsValid() && !isEmptyValue(val) {
transformed["maxUtilization"] = transformedMaxUtilization
}

Expand Down
3 changes: 1 addition & 2 deletions website/docs/r/compute_backend_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,7 @@ The `backend` block supports:
* `max_utilization` -
(Optional)
Used when balancingMode is UTILIZATION. This ratio defines the
CPU utilization target for the group. The default is 0.8. Valid
range is [0.0, 1.0].
CPU utilization target for the group. Valid range is [0.0, 1.0].

The `circuit_breakers` block supports:

Expand Down

0 comments on commit 3b33d94

Please sign in to comment.