Skip to content

Commit

Permalink
Do not force send insecure_kubelet_readonly_port_enabled during creat…
Browse files Browse the repository at this point in the history
…ion (#11688) (#19543)

[upstream:c1708c6853d43c42f2cd1f4d227deed799f34c23]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and zli82016 committed Sep 19, 2024
1 parent 8710525 commit 9f4b6fc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/11688.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
container: fixed a bug where specifying `node_pool_defaults.node_config_defaults` with `enable_autopilot = true` will cause `google_container_cluster` resource creation failure
```
1 change: 0 additions & 1 deletion google/services/container/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,6 @@ func expandNodeConfigDefaults(configured interface{}) *container.NodeConfigDefau
if v, ok := config["insecure_kubelet_readonly_port_enabled"]; ok {
nodeConfigDefaults.NodeKubeletConfig = &container.NodeKubeletConfig{
InsecureKubeletReadonlyPortEnabled: expandInsecureKubeletReadonlyPortEnabled(v),
ForceSendFields: []string{"InsecureKubeletReadonlyPortEnabled"},
}
}
if variant, ok := config["logging_variant"]; ok {
Expand Down
45 changes: 45 additions & 0 deletions google/services/container/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3072,6 +3072,32 @@ func TestAccContainerCluster_withAutopilotKubeletConfig(t *testing.T) {
})
}

func TestAccContainerCluster_withAutopilot_withNodePoolDefaults(t *testing.T) {
t.Parallel()

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

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccContainerCluster_withAutopilot_withNodePoolDefaults(clusterName, networkName, subnetworkName),
},
{
ResourceName: "google_container_cluster.primary",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
},
})
}

func TestAccContainerCluster_withAutopilotResourceManagerTags(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -9542,6 +9568,25 @@ func testAccContainerCluster_withAutopilotKubeletConfigUpdates(name, insecureKub
`, name, insecureKubeletReadonlyPortEnabled)
}

func testAccContainerCluster_withAutopilot_withNodePoolDefaults(name, networkName, subnetworkName string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "primary" {
name = "%s"
location = "us-central1"
enable_autopilot = true
node_pool_defaults {
node_config_defaults {
}
}
deletion_protection = false
network = "%s"
subnetwork = "%s"
}
`, name, networkName, subnetworkName)
}

func testAccContainerCluster_resourceManagerTags(projectID, clusterName, networkName, subnetworkName, randomSuffix string) string {
return fmt.Sprintf(`
data "google_project" "project" {
Expand Down

0 comments on commit 9f4b6fc

Please sign in to comment.