Skip to content

Commit

Permalink
PLT-1112: Fixed GCP cluster day 2 operation for instance type change (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SivaanandM authored Mar 29, 2024
1 parent e461843 commit 2d2b217
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions spectrocloud/cluster_common_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}

Expand Down
4 changes: 2 additions & 2 deletions spectrocloud/cluster_common_hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2d2b217

Please sign in to comment.