From f1c9ff5535460faa6ee20fbaeb1b7501c85f2be0 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Wed, 7 Apr 2021 18:58:45 +0000 Subject: [PATCH] Fix min_node_cpus logic in GA (#4671) Signed-off-by: Modular Magician --- .changelog/4671.txt | 3 +++ google/compute_instance_helpers.go | 9 +++++++++ 2 files changed, 12 insertions(+) create mode 100644 .changelog/4671.txt diff --git a/.changelog/4671.txt b/.changelog/4671.txt new file mode 100644 index 00000000000..f586333a85c --- /dev/null +++ b/.changelog/4671.txt @@ -0,0 +1,3 @@ +```release-note:bug +compute: fixed an issue in `google_compute_instance` where `min_node_cpus` could not be set +``` diff --git a/google/compute_instance_helpers.go b/google/compute_instance_helpers.go index ba89fd1973d..bdc1b46b947 100644 --- a/google/compute_instance_helpers.go +++ b/google/compute_instance_helpers.go @@ -117,6 +117,10 @@ func expandScheduling(v interface{}) (*computeBeta.Scheduling, error) { } } + if v, ok := original["min_node_cpus"]; ok { + scheduling.MinNodeCpus = int64(v.(int)) + } + return scheduling, nil } @@ -124,6 +128,7 @@ 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 { @@ -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) }