diff --git a/spectrocloud/cluster_common_hash.go b/spectrocloud/cluster_common_hash.go index 179f7fc0..cb194257 100644 --- a/spectrocloud/cluster_common_hash.go +++ b/spectrocloud/cluster_common_hash.go @@ -96,7 +96,24 @@ func resourceMachinePoolAksHash(v interface{}) int { func resourceMachinePoolGcpHash(v interface{}) int { m := v.(map[string]interface{}) buf := CommonHash(m) + if _, ok := m["disk_size_gb"]; ok { + buf.WriteString(fmt.Sprintf("%d-", m["disk_size_gb"].(int))) + } + buf.WriteString(fmt.Sprintf("%s-", m["instance_type"].(string))) + if _, ok := m["azs"]; ok { + if m["azs"] != nil { + azsSet := m["azs"].(*schema.Set) + azsList := azsSet.List() + azsListStr := make([]string, len(azsList)) + for i, v := range azsList { + azsListStr[i] = v.(string) + } + sort.Strings(azsListStr) + azsStr := strings.Join(azsListStr, "-") + buf.WriteString(fmt.Sprintf("%s-", azsStr)) + } + } return int(hash(buf.String())) } diff --git a/spectrocloud/cluster_common_hash_test.go b/spectrocloud/cluster_common_hash_test.go index 6231c75f..c87e917e 100644 --- a/spectrocloud/cluster_common_hash_test.go +++ b/spectrocloud/cluster_common_hash_test.go @@ -140,13 +140,13 @@ func TestResourceMachinePoolGcpHash(t *testing.T) { "max": 3, "capacity_type": "ON_DEMAND", "max_price": "0.12", - "azs": []string{"us-central1-a", "us-central1-b"}, + "azs": schema.NewSet(schema.HashString, []interface{}{"us-central1-a", "us-central1-b"}), "az_subnets": map[string]interface{}{ "us-central1-a": "subnet-1", "us-central1-b": "subnet-2", }, }, - expected: 1198721703, + expected: 2586515099, }, } for _, tc := range testCases {