Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,15 @@ var schemaNodePool = map[string]*schema.Schema{
Optional: true,
Computed: true,
ForceNew: true,
Description: `Creates a unique name for the node pool beginning with the specified prefix. Conflicts with name.`,
Description: `Creates a unique name for the node pool beginning with the specified prefix. Conflicts with name. Max length is 31 characters. Prefixes with lengths longer than 14 characters will use a shortened UUID that will be more prone to collisions.`,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if len(value) > 31 {
errors = append(errors, fmt.Errorf(
"%q cannot be longer than 31 characters, name is limited to 40", k))
}
return
},
},

"node_config": schemaNodeConfig(),
Expand Down Expand Up @@ -1209,7 +1217,12 @@ func expandNodePool(d *schema.ResourceData, prefix string) (*container.NodePool,
}
name = v.(string)
} else if v, ok := d.GetOk(prefix + "name_prefix"); ok {
name = id.PrefixedUniqueId(v.(string))
p := v.(string)
if len(p) > 14 {
name = tpgresource.ReducedPrefixedUniqueId(p)
} else {
name = id.PrefixedUniqueId(p)
}
} else {
name = id.UniqueId()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,33 @@ func TestAccContainerNodePool_namePrefix(t *testing.T) {
})
}

func TestAccContainerNodePool_namePrefix_long(t *testing.T) {
// Randomness
acctest.SkipIfVcr(t)
t.Parallel()

cluster := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
networkName := tpgcompute.BootstrapSharedTestNetwork(t, "gke-cluster")
subnetworkName := tpgcompute.BootstrapSubnet(t, "gke-cluster", networkName)

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckContainerNodePoolDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccContainerNodePool_namePrefix(cluster, "tf-np-long-prefix-", networkName, subnetworkName),
},
{
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name_prefix"},
},
},
})
}

func TestAccContainerNodePool_noName(t *testing.T) {
// Randomness
acctest.SkipIfVcr(t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ terraform {

## Resources

## Resource: `google_container_node_pool` and `google_container_cluster`

### `name_prefix` max length has been extended from 14 to 31 characters

Previously, the max length of `name_prefix` for `google_container_node_pool` and `google_container_cluster.node_pool` was 14 characters since the autogenerated UUID suffix was 26 characters which combined to 40 characters (the max limit for GKE node pool names).

In 8.0.0, providing a `name_prefix` larger than 14 characters will prompt the provider to use a shortened suffix of only 9 characters, leading to a new max of 31 characters for `name_prefix`. This shortened suffix is inevitably more prone to collisions, so use the longer max `name_prefix` length with caution.

## Resource: `google_cloud_run_v2_worker_pool`

### `custom_audiences` is now removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,14 @@ cluster.
auto-generate a unique name.

* `name_prefix` - (Optional) Creates a unique name for the node pool beginning
with the specified prefix. Conflicts with `name`.
with the specified prefix. Conflicts with `name`. Max length is 31 characters.
Prefixes with lengths longer than 14 characters will use a shortened
UUID that will be more prone to collisions.

Resulting name for a `name_prefix` <= 14 characters:
`name_prefix` + YYYYmmddHHSSssss + 8 digit incremental counter
Resulting name for a `name_prefix` 15 - 31 characters:
`name_prefix` + YYmmdd + 3 digit incremental counter

* `node_config` - (Optional) Parameters used in creating the node pool. Structure is [documented below](#nested_node_config). See [google_container_cluster](container_cluster.html#nested_node_config) for exact schema.

Expand Down