Skip to content

Commit 9f4b6fc

Browse files
modular-magicianzli82016
authored andcommitted
Do not force send insecure_kubelet_readonly_port_enabled during creation (#11688) (#19543)
[upstream:c1708c6853d43c42f2cd1f4d227deed799f34c23] Signed-off-by: Modular Magician <[email protected]>
1 parent 8710525 commit 9f4b6fc

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

.changelog/11688.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
container: fixed a bug where specifying `node_pool_defaults.node_config_defaults` with `enable_autopilot = true` will cause `google_container_cluster` resource creation failure
3+
```

google/services/container/node_config.go

-1
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,6 @@ func expandNodeConfigDefaults(configured interface{}) *container.NodeConfigDefau
766766
if v, ok := config["insecure_kubelet_readonly_port_enabled"]; ok {
767767
nodeConfigDefaults.NodeKubeletConfig = &container.NodeKubeletConfig{
768768
InsecureKubeletReadonlyPortEnabled: expandInsecureKubeletReadonlyPortEnabled(v),
769-
ForceSendFields: []string{"InsecureKubeletReadonlyPortEnabled"},
770769
}
771770
}
772771
if variant, ok := config["logging_variant"]; ok {

google/services/container/resource_container_cluster_test.go

+45
Original file line numberDiff line numberDiff line change
@@ -3072,6 +3072,32 @@ func TestAccContainerCluster_withAutopilotKubeletConfig(t *testing.T) {
30723072
})
30733073
}
30743074

3075+
func TestAccContainerCluster_withAutopilot_withNodePoolDefaults(t *testing.T) {
3076+
t.Parallel()
3077+
3078+
randomSuffix := acctest.RandString(t, 10)
3079+
clusterName := fmt.Sprintf("tf-test-cluster-%s", randomSuffix)
3080+
networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster")
3081+
subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName)
3082+
3083+
acctest.VcrTest(t, resource.TestCase{
3084+
PreCheck: func() { acctest.AccTestPreCheck(t) },
3085+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
3086+
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
3087+
Steps: []resource.TestStep{
3088+
{
3089+
Config: testAccContainerCluster_withAutopilot_withNodePoolDefaults(clusterName, networkName, subnetworkName),
3090+
},
3091+
{
3092+
ResourceName: "google_container_cluster.primary",
3093+
ImportState: true,
3094+
ImportStateVerify: true,
3095+
ImportStateVerifyIgnore: []string{"deletion_protection"},
3096+
},
3097+
},
3098+
})
3099+
}
3100+
30753101
func TestAccContainerCluster_withAutopilotResourceManagerTags(t *testing.T) {
30763102
t.Parallel()
30773103

@@ -9542,6 +9568,25 @@ func testAccContainerCluster_withAutopilotKubeletConfigUpdates(name, insecureKub
95429568
`, name, insecureKubeletReadonlyPortEnabled)
95439569
}
95449570

9571+
func testAccContainerCluster_withAutopilot_withNodePoolDefaults(name, networkName, subnetworkName string) string {
9572+
return fmt.Sprintf(`
9573+
resource "google_container_cluster" "primary" {
9574+
name = "%s"
9575+
location = "us-central1"
9576+
enable_autopilot = true
9577+
9578+
node_pool_defaults {
9579+
node_config_defaults {
9580+
}
9581+
}
9582+
9583+
deletion_protection = false
9584+
network = "%s"
9585+
subnetwork = "%s"
9586+
}
9587+
`, name, networkName, subnetworkName)
9588+
}
9589+
95459590
func testAccContainerCluster_resourceManagerTags(projectID, clusterName, networkName, subnetworkName, randomSuffix string) string {
95469591
return fmt.Sprintf(`
95479592
data "google_project" "project" {

0 commit comments

Comments
 (0)