@@ -104,12 +104,6 @@ var (
104
104
"private_cluster_config.0.master_global_access_config",
105
105
}
106
106
107
- forceNewClusterNodeConfigFields = []string{
108
- "labels",
109
- "workload_metadata_config",
110
- "resource_manager_tags",
111
- }
112
-
113
107
suppressDiffForAutopilot = schema.SchemaDiffSuppressFunc(func(k, oldValue, newValue string, d *schema.ResourceData) bool {
114
108
if v, _ := d.Get("enable_autopilot").(bool); v {
115
109
return true
@@ -126,19 +120,6 @@ var (
126
120
})
127
121
)
128
122
129
- // This uses the node pool nodeConfig schema but sets
130
- // node-pool-only updatable fields to ForceNew
131
- func clusterSchemaNodeConfig() *schema.Schema {
132
- nodeConfigSch := schemaNodeConfig()
133
- schemaMap := nodeConfigSch.Elem.(*schema.Resource).Schema
134
- for _, k := range forceNewClusterNodeConfigFields {
135
- if sch, ok := schemaMap[k]; ok {
136
- tpgresource.ChangeFieldSchemaToForceNew(sch)
137
- }
138
- }
139
- return nodeConfigSch
140
- }
141
-
142
123
// Defines default nodel pool settings for the entire cluster. These settings are
143
124
// overridden if specified on the specific NodePool object.
144
125
func clusterSchemaNodePoolDefaults() *schema.Schema {
@@ -1477,7 +1458,7 @@ func ResourceContainerCluster() *schema.Resource {
1477
1458
},
1478
1459
},
1479
1460
1480
- "node_config": clusterSchemaNodeConfig (),
1461
+ "node_config": schemaNodeConfig (),
1481
1462
1482
1463
"node_pool": {
1483
1464
Type: schema.TypeList,
@@ -3812,133 +3793,15 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
3812
3793
}
3813
3794
3814
3795
if d.HasChange("node_config") {
3815
- if d.HasChange("node_config.0.image_type") {
3816
- it := d.Get("node_config.0.image_type").(string)
3817
- req := &container.UpdateClusterRequest{
3818
- Update: &container.ClusterUpdate{
3819
- DesiredImageType: it,
3820
- },
3821
- }
3822
-
3823
- updateF := func() error {
3824
- name := containerClusterFullName(project, location, clusterName)
3825
- clusterUpdateCall := config.NewContainerClient(userAgent).Projects.Locations.Clusters.Update(name, req)
3826
- if config.UserProjectOverride {
3827
- clusterUpdateCall.Header().Add("X-Goog-User-Project", project)
3828
- }
3829
- op, err := clusterUpdateCall.Do()
3830
- if err != nil {
3831
- return err
3832
- }
3833
-
3834
- // Wait until it's updated
3835
- return ContainerOperationWait(config, op, project, location, "updating GKE image type", userAgent, d.Timeout(schema.TimeoutUpdate))
3836
- }
3837
3796
3838
- // Call update serially.
3839
- if err := transport_tpg.LockedCall(lockKey, updateF); err != nil {
3840
- return err
3841
- }
3842
-
3843
- log.Printf("[INFO] GKE cluster %s: image type has been updated to %s", d.Id(), it)
3844
- }
3845
-
3846
- if d.HasChange("node_config.0.kubelet_config") {
3847
-
3848
- defaultPool := "default-pool"
3849
-
3850
- timeout := d.Timeout(schema.TimeoutCreate)
3851
-
3852
- nodePoolInfo, err := extractNodePoolInformationFromCluster(d, config, clusterName)
3853
- if err != nil {
3854
- return err
3855
- }
3856
-
3857
- // Acquire write-lock on nodepool.
3858
- npLockKey := nodePoolInfo.nodePoolLockKey(defaultPool)
3859
-
3860
- // Still should be further consolidated / DRYed up
3861
- // See b/361634104
3862
- it := d.Get("node_config.0.kubelet_config")
3863
-
3864
- // While we're getting the value from fields in
3865
- // node_config.kubelet_config, the actual setting that needs to be
3866
- // updated is on the default nodepool.
3867
- req := &container.UpdateNodePoolRequest{
3868
- Name: defaultPool,
3869
- KubeletConfig: expandKubeletConfig(it),
3870
- }
3797
+ defaultPool := "default-pool"
3871
3798
3872
- updateF := func() error {
3873
- clusterNodePoolsUpdateCall := config.NewContainerClient(userAgent).Projects.Locations.Clusters.NodePools.Update(nodePoolInfo.fullyQualifiedName(defaultPool), req)
3874
- if config.UserProjectOverride {
3875
- clusterNodePoolsUpdateCall.Header().Add("X-Goog-User-Project", nodePoolInfo.project)
3876
- }
3877
- op, err := clusterNodePoolsUpdateCall.Do()
3878
- if err != nil {
3879
- return err
3880
- }
3881
-
3882
- // Wait until it's updated
3883
- return ContainerOperationWait(config, op, nodePoolInfo.project, nodePoolInfo.location,
3884
- "updating GKE node pool kubelet_config", userAgent, timeout)
3885
- }
3886
-
3887
- if err := retryWhileIncompatibleOperation(timeout, npLockKey, updateF); err != nil {
3888
- return err
3889
- }
3890
-
3891
- log.Printf("[INFO] GKE cluster %s: kubelet_config updated", d.Id())
3892
- }
3893
-
3894
- if d.HasChange("node_config.0.gcfs_config") {
3895
-
3896
- defaultPool := "default-pool"
3897
-
3898
- timeout := d.Timeout(schema.TimeoutCreate)
3899
-
3900
- nodePoolInfo, err := extractNodePoolInformationFromCluster(d, config, clusterName)
3901
- if err != nil {
3902
- return err
3903
- }
3904
-
3905
- // Acquire write-lock on nodepool.
3906
- npLockKey := nodePoolInfo.nodePoolLockKey(defaultPool)
3907
-
3908
- gcfsEnabled := d.Get("node_config.0.gcfs_config.0.enabled").(bool)
3909
-
3910
- // While we're getting the value from the drepcated field in
3911
- // node_config.kubelet_config, the actual setting that needs to be updated
3912
- // is on the default nodepool.
3913
- req := &container.UpdateNodePoolRequest{
3914
- Name: defaultPool,
3915
- GcfsConfig: &container.GcfsConfig{
3916
- Enabled: gcfsEnabled,
3917
- },
3918
- }
3919
-
3920
- updateF := func() error {
3921
- clusterNodePoolsUpdateCall := config.NewContainerClient(userAgent).Projects.Locations.Clusters.NodePools.Update(nodePoolInfo.fullyQualifiedName(defaultPool), req)
3922
- if config.UserProjectOverride {
3923
- clusterNodePoolsUpdateCall.Header().Add("X-Goog-User-Project", nodePoolInfo.project)
3924
- }
3925
- op, err := clusterNodePoolsUpdateCall.Do()
3926
- if err != nil {
3927
- return err
3928
- }
3929
-
3930
- // Wait until it's updated
3931
- return ContainerOperationWait(config, op, nodePoolInfo.project, nodePoolInfo.location,
3932
- "updating GKE node pool gcfs_config", userAgent, timeout)
3933
- }
3934
-
3935
- if err := retryWhileIncompatibleOperation(timeout, npLockKey, updateF); err != nil {
3936
- return err
3937
- }
3938
-
3939
- log.Printf("[INFO] GKE cluster %s: %s setting for gcfs_config updated to %t", d.Id(), defaultPool, gcfsEnabled)
3799
+ nodePoolInfo, err := extractNodePoolInformationFromCluster(d, config, clusterName)
3800
+ if err != nil {
3801
+ return err
3940
3802
}
3941
3803
3804
+ nodePoolNodeConfigUpdate(d, config, nodePoolInfo, "", defaultPool, d.Timeout(schema.TimeoutUpdate))
3942
3805
}
3943
3806
3944
3807
if d.HasChange("notification_config") {
0 commit comments