Skip to content

Commit 629088f

Browse files
container: bump gcsfs to GA (hashicorp#11542) (hashicorp#19617)
[upstream:a85530e20d0cb0739e0f209112b90d4ad3578eba] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 6554ab1 commit 629088f

File tree

5 files changed

+115
-1
lines changed

5 files changed

+115
-1
lines changed

.changelog/11542.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
conatainer: bump `gcfs_config` to GA
3+
```

google/services/container/node_config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,14 @@ func expandNodeConfigDefaults(configured interface{}) *container.NodeConfigDefau
795795
},
796796
}
797797
}
798+
799+
if v, ok := config["gcfs_config"]; ok && len(v.([]interface{})) > 0 {
800+
gcfsConfig := v.([]interface{})[0].(map[string]interface{})
801+
nodeConfigDefaults.GcfsConfig = &container.GcfsConfig{
802+
Enabled: gcfsConfig["enabled"].(bool),
803+
}
804+
}
805+
798806
return nodeConfigDefaults
799807
}
800808

@@ -1379,6 +1387,8 @@ func flattenNodeConfigDefaults(c *container.NodeConfigDefaults) []map[string]int
13791387

13801388
result[0]["logging_variant"] = flattenLoggingVariant(c.LoggingConfig)
13811389

1390+
result[0]["gcfs_config"] = flattenGcfsConfig(c.GcfsConfig)
1391+
13821392
return result
13831393
}
13841394

google/services/container/resource_container_cluster.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ func clusterSchemaNodePoolDefaults() *schema.Schema {
152152
Elem: &schema.Resource{
153153
Schema: map[string]*schema.Schema{
154154
"containerd_config": schemaContainerdConfig(),
155+
"gcfs_config": schemaGcfsConfig(),
155156
"insecure_kubelet_readonly_port_enabled": schemaInsecureKubeletReadonlyPortEnabled(),
156157
"logging_variant": schemaLoggingVariant(),
157158
},
@@ -4085,6 +4086,27 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
40854086
}
40864087
}
40874088

4089+
if d.HasChange("node_pool_defaults") && d.HasChange("node_pool_defaults.0.node_config_defaults.0.gcfs_config") {
4090+
if v, ok := d.GetOk("node_pool_defaults.0.node_config_defaults.0.gcfs_config"); ok {
4091+
gcfsConfig := v.([]interface{})[0].(map[string]interface{})
4092+
req := &container.UpdateClusterRequest{
4093+
Update: &container.ClusterUpdate{
4094+
DesiredGcfsConfig: &container.GcfsConfig{
4095+
Enabled: gcfsConfig["enabled"].(bool),
4096+
},
4097+
},
4098+
}
4099+
4100+
updateF := updateFunc(req, "updating GKE cluster desired gcfs config.")
4101+
// Call update serially.
4102+
if err := transport_tpg.LockedCall(lockKey, updateF); err != nil {
4103+
return err
4104+
}
4105+
4106+
log.Printf("[INFO] GKE cluster %s default gcfs config has been updated", d.Id())
4107+
}
4108+
}
4109+
40884110
if d.HasChange("security_posture_config") {
40894111
req := &container.UpdateClusterRequest{
40904112
Update: &container.ClusterUpdate{

google/services/container/resource_container_cluster_test.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,64 @@ func TestAccContainerCluster_withAdvancedMachineFeaturesInNodePool(t *testing.T)
16751675
})
16761676
}
16771677

1678+
func TestAccContainerCluster_withNodePoolDefaults(t *testing.T) {
1679+
t.Parallel()
1680+
clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
1681+
networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster")
1682+
subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName)
1683+
acctest.VcrTest(t, resource.TestCase{
1684+
PreCheck: func() { acctest.AccTestPreCheck(t) },
1685+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
1686+
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
1687+
Steps: []resource.TestStep{
1688+
{
1689+
Config: testAccContainerCluster_basic(clusterName, networkName, subnetworkName),
1690+
Check: resource.ComposeTestCheckFunc(
1691+
resource.TestCheckNoResourceAttr("google_container_cluster.primary",
1692+
"node_pool_defaults.0.node_config_defaults.0.gcfs_config.0.enabled"),
1693+
),
1694+
},
1695+
{
1696+
ResourceName: "google_container_cluster.primary",
1697+
ImportStateId: fmt.Sprintf("us-central1-a/%s", clusterName),
1698+
ImportState: true,
1699+
ImportStateVerify: true,
1700+
ImportStateVerifyIgnore: []string{"deletion_protection"},
1701+
},
1702+
{
1703+
Config: testAccContainerCluster_withNodePoolDefaults(clusterName, "true", networkName, subnetworkName),
1704+
Check: resource.ComposeAggregateTestCheckFunc(
1705+
resource.TestCheckResourceAttr("google_container_cluster.with_node_pool_defaults",
1706+
"node_pool_defaults.0.node_config_defaults.0.gcfs_config.#", "1"),
1707+
resource.TestCheckResourceAttr("google_container_cluster.with_node_pool_defaults",
1708+
"node_pool_defaults.0.node_config_defaults.0.gcfs_config.0.enabled", "true"),
1709+
),
1710+
},
1711+
{
1712+
ResourceName: "google_container_cluster.with_node_pool_defaults",
1713+
ImportState: true,
1714+
ImportStateVerify: true,
1715+
ImportStateVerifyIgnore: []string{"deletion_protection"},
1716+
},
1717+
{
1718+
Config: testAccContainerCluster_withNodePoolDefaults(clusterName, "false", networkName, subnetworkName),
1719+
Check: resource.ComposeAggregateTestCheckFunc(
1720+
resource.TestCheckResourceAttr("google_container_cluster.with_node_pool_defaults",
1721+
"node_pool_defaults.0.node_config_defaults.0.gcfs_config.#", "1"),
1722+
resource.TestCheckResourceAttr("google_container_cluster.with_node_pool_defaults",
1723+
"node_pool_defaults.0.node_config_defaults.0.gcfs_config.0.enabled", "false"),
1724+
),
1725+
},
1726+
{
1727+
ResourceName: "google_container_cluster.with_node_pool_defaults",
1728+
ImportState: true,
1729+
ImportStateVerify: true,
1730+
ImportStateVerifyIgnore: []string{"deletion_protection"},
1731+
},
1732+
},
1733+
})
1734+
}
1735+
16781736
func TestAccContainerCluster_withNodeConfigScopeAlias(t *testing.T) {
16791737
t.Parallel()
16801738

@@ -6256,6 +6314,27 @@ resource "google_container_cluster" "with_advanced_machine_features_in_node_pool
62566314
`, clusterName, nodePoolName, nvEnabled, networkName, subnetworkName)
62576315
}
62586316

6317+
func testAccContainerCluster_withNodePoolDefaults(clusterName, enabled, networkName, subnetworkName string) string {
6318+
return fmt.Sprintf(`
6319+
resource "google_container_cluster" "with_node_pool_defaults" {
6320+
name = "%s"
6321+
location = "us-central1-f"
6322+
initial_node_count = 1
6323+
6324+
node_pool_defaults {
6325+
node_config_defaults {
6326+
gcfs_config {
6327+
enabled = "%s"
6328+
}
6329+
}
6330+
}
6331+
deletion_protection = false
6332+
network = "%s"
6333+
subnetwork = "%s"
6334+
}
6335+
`, clusterName, enabled, networkName, subnetworkName)
6336+
}
6337+
62596338
func testAccContainerCluster_withNodeConfigUpdate(clusterName, networkName, subnetworkName string) string {
62606339
return fmt.Sprintf(`
62616340
resource "google_container_cluster" "with_node_config" {

website/docs/r/container_cluster.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ The `node_config_defaults` block supports:
11181118

11191119
* `logging_variant` (Optional) The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. See [Increasing logging agent throughput](https://cloud.google.com/stackdriver/docs/solutions/gke/managing-logs#throughput) for more information.
11201120

1121-
* `gcfs_config` (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) The default Google Container Filesystem (GCFS) configuration at the cluster level. e.g. enable [image streaming](https://cloud.google.com/kubernetes-engine/docs/how-to/image-streaming) across all the node pools within the cluster. Structure is [documented below](#nested_gcfs_config).
1121+
* `gcfs_config` (Optional) The default Google Container Filesystem (GCFS) configuration at the cluster level. e.g. enable [image streaming](https://cloud.google.com/kubernetes-engine/docs/how-to/image-streaming) across all the node pools within the cluster. Structure is [documented below](#nested_gcfs_config).
11221122

11231123
<a name="nested_notification_config"></a>The `notification_config` block supports:
11241124

0 commit comments

Comments
 (0)