Skip to content

Commit 8315900

Browse files
committed
fix: GKE cluster update behavior (rancher#1518)
1 parent 6127f2d commit 8315900

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

rancher2/resource_rancher2_cluster.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ func resourceRancher2Cluster() *schema.Resource {
3535
d.SetNew("eks_config_v2", flattenClusterEKSConfigV2(newObj, []interface{}{}))
3636
}
3737
}
38+
39+
if d.Get("driver") == clusterDriverGKEV2 && d.HasChange("gke_config_v2") {
40+
old, new := d.GetChange("gke_config_v2")
41+
oldObj := expandClusterGKEConfigV2(old.([]interface{}))
42+
newObj := expandClusterGKEConfigV2(new.([]interface{}))
43+
44+
if reflect.DeepEqual(oldObj, newObj) {
45+
d.Clear("gke_config_v2")
46+
} else {
47+
d.SetNew("gke_config_v2", flattenClusterGKEConfigV2(newObj, []interface{}{}))
48+
}
49+
}
50+
3851
return nil
3952
},
4053
Schema: clusterFields(),

rancher2/schema_cluster_gke_config_v2.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ func clusterGKEConfigV2NodePoolConfigFields() map[string]*schema.Schema {
303303
Type: schema.TypeList,
304304
Optional: true,
305305
Computed: true,
306-
ForceNew: true,
307306
MaxItems: 1,
308307
Description: "The GKE node pool node config",
309308
Elem: &schema.Resource{
@@ -360,7 +359,6 @@ func clusterGKEConfigV2Fields() map[string]*schema.Schema {
360359
"name": {
361360
Type: schema.TypeString,
362361
Required: true,
363-
ForceNew: true,
364362
Description: "The GKE cluster name",
365363
},
366364
"google_credential_secret": {
@@ -372,7 +370,6 @@ func clusterGKEConfigV2Fields() map[string]*schema.Schema {
372370
"project_id": {
373371
Type: schema.TypeString,
374372
Required: true,
375-
ForceNew: true,
376373
Description: "The GKE project id",
377374
},
378375
"cluster_addons": {
@@ -389,28 +386,24 @@ func clusterGKEConfigV2Fields() map[string]*schema.Schema {
389386
Type: schema.TypeString,
390387
Optional: true,
391388
Computed: true,
392-
ForceNew: true,
393389
Description: "The GKE ip v4 cidr block",
394390
},
395391
"description": {
396392
Type: schema.TypeString,
397393
Optional: true,
398394
Computed: true,
399-
ForceNew: true,
400395
Description: "The GKE cluster description",
401396
},
402397
"enable_kubernetes_alpha": {
403398
Type: schema.TypeBool,
404399
Optional: true,
405400
Computed: true,
406-
ForceNew: true,
407401
Description: "Enable Kubernetes alpha",
408402
},
409403
"ip_allocation_policy": {
410404
Type: schema.TypeList,
411405
Optional: true,
412406
Computed: true,
413-
ForceNew: true,
414407
MaxItems: 1,
415408
Description: "The GKE ip allocation policy",
416409
Elem: &schema.Resource{
@@ -421,7 +414,6 @@ func clusterGKEConfigV2Fields() map[string]*schema.Schema {
421414
Type: schema.TypeBool,
422415
Optional: true,
423416
Default: false,
424-
ForceNew: true,
425417
Description: "Is GKE cluster imported?",
426418
},
427419
"kubernetes_version": {
@@ -461,7 +453,6 @@ func clusterGKEConfigV2Fields() map[string]*schema.Schema {
461453
Type: schema.TypeList,
462454
Optional: true,
463455
Computed: true,
464-
ForceNew: true,
465456
MaxItems: 1,
466457
Description: "The GKE cluster master authorized networks config",
467458
Elem: &schema.Resource{
@@ -478,7 +469,6 @@ func clusterGKEConfigV2Fields() map[string]*schema.Schema {
478469
Type: schema.TypeString,
479470
Optional: true,
480471
Computed: true,
481-
ForceNew: true,
482472
Description: "The GKE cluster network",
483473
},
484474
"network_policy_enabled": {
@@ -500,7 +490,6 @@ func clusterGKEConfigV2Fields() map[string]*schema.Schema {
500490
Type: schema.TypeList,
501491
Optional: true,
502492
Computed: true,
503-
ForceNew: true,
504493
MaxItems: 1,
505494
Description: "The GKE private cluster config",
506495
Elem: &schema.Resource{
@@ -511,21 +500,18 @@ func clusterGKEConfigV2Fields() map[string]*schema.Schema {
511500
Type: schema.TypeString,
512501
Optional: true,
513502
Computed: true,
514-
ForceNew: true,
515503
Description: "The GKE cluster region. Required if `zone` is empty",
516504
},
517505
"subnetwork": {
518506
Type: schema.TypeString,
519507
Optional: true,
520508
Computed: true,
521-
ForceNew: true,
522509
Description: "The GKE cluster subnetwork",
523510
},
524511
"zone": {
525512
Type: schema.TypeString,
526513
Optional: true,
527514
Computed: true,
528-
ForceNew: true,
529515
Description: "The GKE cluster zone. Required if `region` is empty",
530516
},
531517
}

0 commit comments

Comments
 (0)