Skip to content

Commit

Permalink
[CC-30766] disallow 0 as a value for disk_iops
Browse files Browse the repository at this point in the history
0 is a valid value to pass into the api for disk_iops.  That, along with
omitting the value in the api call results in the default iops value.
However, the api returns the actual value for the iops that was chosen.
This results in a configuration conflict with the set value of 0 and the
actual value that was returned from the server.  For this reason we now
disallow 0 from being set and we clarify in the docs that omitting the
value is the correct way to ask for the default.
  • Loading branch information
fantapop committed Dec 9, 2024
1 parent 9a6df25 commit 28c8af9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Disallow 0 from being passed for disk_iops and update the docs to indicate
that omitting the attribute is the correct way to get the default behavior.

- Validate that `node_count` is not passed in with serverless cluster regions.
Also, clear up in the documentation that this is not allowed.

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Optional:
Optional:

- `cidr_range` (String) The IPv4 range in CIDR format that will be used by the cluster. This is supported only on GCP, and must have a subnet mask no larger than /19. Defaults to "172.28.0.0/14". This cannot be changed after cluster creation.
- `disk_iops` (Number) Number of disk I/O operations per second that are permitted on each node in the cluster. Zero indicates the cloud provider-specific default.
- `disk_iops` (Number) Number of disk I/O operations per second that are permitted on each node in the cluster. Omitting this attribute will result in the cloud provider-specific default.
- `machine_type` (String) Machine type identifier within the given cloud provider, e.g., m6.xlarge, n2-standard-4.
- `num_virtual_cpus` (Number) Number of virtual CPUs per node in the cluster.
- `private_network_visibility` (Boolean) Set to true to assign private IP addresses to nodes. Required for CMEK and other advanced networking features. Clusters created with this flag will have advanced security features enabled. This cannot be changed after cluster creation and incurs additional charges. See [Create an Advanced Cluster](https://www.cockroachlabs.com/docs/cockroachcloud/create-an-advanced-cluster.html#step-6-configure-advanced-security-features) and [Pricing](https://www.cockroachlabs.com/pricing/) for more information.
Expand Down
9 changes: 8 additions & 1 deletion internal/provider/cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/cockroachdb/cockroach-cloud-sdk-go/v5/pkg/client"
"github.com/cockroachdb/terraform-provider-cockroach/internal/validators"
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
"github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/attr"
Expand Down Expand Up @@ -218,7 +219,13 @@ func (r *clusterResource) Schema(
"disk_iops": schema.Int64Attribute{
Optional: true,
Computed: true,
Description: "Number of disk I/O operations per second that are permitted on each node in the cluster. Zero indicates the cloud provider-specific default.",
Validators: []validator.Int64{
// If supplied this value must be non-zero. 0 is a
// valid api value indicating the default being
// returned but it causes a provider inconsistency.
int64validator.AtLeast(1),
},
Description: "Number of disk I/O operations per second that are permitted on each node in the cluster. Omitting this attribute will result in the cloud provider-specific default.",
},
"memory_gib": schema.Float64Attribute{
Computed: true,
Expand Down

0 comments on commit 28c8af9

Please sign in to comment.