Skip to content

Commit

Permalink
Fix min_node_cpus logic in GA (#4671) (#8865)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Apr 7, 2021
1 parent cfd1e36 commit 2ee5180
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/4671.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: fixed an issue in `google_compute_instance` where `min_node_cpus` could not be set
```
9 changes: 9 additions & 0 deletions google/compute_instance_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,18 @@ func expandScheduling(v interface{}) (*computeBeta.Scheduling, error) {
}
}

if v, ok := original["min_node_cpus"]; ok {
scheduling.MinNodeCpus = int64(v.(int))
}

return scheduling, nil
}

func flattenScheduling(resp *computeBeta.Scheduling) []map[string]interface{} {
schedulingMap := map[string]interface{}{
"on_host_maintenance": resp.OnHostMaintenance,
"preemptible": resp.Preemptible,
"min_node_cpus": resp.MinNodeCpus,
}

if resp.AutomaticRestart != nil {
Expand Down Expand Up @@ -398,5 +403,9 @@ func schedulingHasChange(d *schema.ResourceData) bool {
return true
}

if oScheduling["min_node_cpus"] != newScheduling["min_node_cpus"] {
return true
}

return reflect.DeepEqual(newNa, originalNa)
}

0 comments on commit 2ee5180

Please sign in to comment.