Skip to content

Commit

Permalink
container: bump gcsfs to GA (#11542) (#19617)
Browse files Browse the repository at this point in the history
[upstream:a85530e20d0cb0739e0f209112b90d4ad3578eba]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Sep 24, 2024
1 parent 6554ab1 commit 629088f
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/11542.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
conatainer: bump `gcfs_config` to GA
```
10 changes: 10 additions & 0 deletions google/services/container/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,14 @@ func expandNodeConfigDefaults(configured interface{}) *container.NodeConfigDefau
},
}
}

if v, ok := config["gcfs_config"]; ok && len(v.([]interface{})) > 0 {
gcfsConfig := v.([]interface{})[0].(map[string]interface{})
nodeConfigDefaults.GcfsConfig = &container.GcfsConfig{
Enabled: gcfsConfig["enabled"].(bool),
}
}

return nodeConfigDefaults
}

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

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

result[0]["gcfs_config"] = flattenGcfsConfig(c.GcfsConfig)

return result
}

Expand Down
22 changes: 22 additions & 0 deletions google/services/container/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func clusterSchemaNodePoolDefaults() *schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"containerd_config": schemaContainerdConfig(),
"gcfs_config": schemaGcfsConfig(),
"insecure_kubelet_readonly_port_enabled": schemaInsecureKubeletReadonlyPortEnabled(),
"logging_variant": schemaLoggingVariant(),
},
Expand Down Expand Up @@ -4085,6 +4086,27 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
}
}

if d.HasChange("node_pool_defaults") && d.HasChange("node_pool_defaults.0.node_config_defaults.0.gcfs_config") {
if v, ok := d.GetOk("node_pool_defaults.0.node_config_defaults.0.gcfs_config"); ok {
gcfsConfig := v.([]interface{})[0].(map[string]interface{})
req := &container.UpdateClusterRequest{
Update: &container.ClusterUpdate{
DesiredGcfsConfig: &container.GcfsConfig{
Enabled: gcfsConfig["enabled"].(bool),
},
},
}

updateF := updateFunc(req, "updating GKE cluster desired gcfs config.")
// Call update serially.
if err := transport_tpg.LockedCall(lockKey, updateF); err != nil {
return err
}

log.Printf("[INFO] GKE cluster %s default gcfs config has been updated", d.Id())
}
}

if d.HasChange("security_posture_config") {
req := &container.UpdateClusterRequest{
Update: &container.ClusterUpdate{
Expand Down
79 changes: 79 additions & 0 deletions google/services/container/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,64 @@ func TestAccContainerCluster_withAdvancedMachineFeaturesInNodePool(t *testing.T)
})
}

func TestAccContainerCluster_withNodePoolDefaults(t *testing.T) {
t.Parallel()
clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
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_basic(clusterName, networkName, subnetworkName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckNoResourceAttr("google_container_cluster.primary",
"node_pool_defaults.0.node_config_defaults.0.gcfs_config.0.enabled"),
),
},
{
ResourceName: "google_container_cluster.primary",
ImportStateId: fmt.Sprintf("us-central1-a/%s", clusterName),
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
{
Config: testAccContainerCluster_withNodePoolDefaults(clusterName, "true", networkName, subnetworkName),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("google_container_cluster.with_node_pool_defaults",
"node_pool_defaults.0.node_config_defaults.0.gcfs_config.#", "1"),
resource.TestCheckResourceAttr("google_container_cluster.with_node_pool_defaults",
"node_pool_defaults.0.node_config_defaults.0.gcfs_config.0.enabled", "true"),
),
},
{
ResourceName: "google_container_cluster.with_node_pool_defaults",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
{
Config: testAccContainerCluster_withNodePoolDefaults(clusterName, "false", networkName, subnetworkName),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("google_container_cluster.with_node_pool_defaults",
"node_pool_defaults.0.node_config_defaults.0.gcfs_config.#", "1"),
resource.TestCheckResourceAttr("google_container_cluster.with_node_pool_defaults",
"node_pool_defaults.0.node_config_defaults.0.gcfs_config.0.enabled", "false"),
),
},
{
ResourceName: "google_container_cluster.with_node_pool_defaults",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
},
})
}

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

Expand Down Expand Up @@ -6256,6 +6314,27 @@ resource "google_container_cluster" "with_advanced_machine_features_in_node_pool
`, clusterName, nodePoolName, nvEnabled, networkName, subnetworkName)
}

func testAccContainerCluster_withNodePoolDefaults(clusterName, enabled, networkName, subnetworkName string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "with_node_pool_defaults" {
name = "%s"
location = "us-central1-f"
initial_node_count = 1
node_pool_defaults {
node_config_defaults {
gcfs_config {
enabled = "%s"
}
}
}
deletion_protection = false
network = "%s"
subnetwork = "%s"
}
`, clusterName, enabled, networkName, subnetworkName)
}

func testAccContainerCluster_withNodeConfigUpdate(clusterName, networkName, subnetworkName string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "with_node_config" {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ The `node_config_defaults` block supports:

* `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.

* `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).
* `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).

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

Expand Down

0 comments on commit 629088f

Please sign in to comment.