diff --git a/CHANGELOG.md b/CHANGELOG.md index a49994e6..dfa668a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,8 @@ -## Version 4.9.3 +## Version 4.9.4 ### Исправлено #### kvmvm | Идентификатор
задачи | Описание | | --- | --- | -| BATF-1016 | Ошибка при изменении полей `ram` и `cpu`, приводящая к невозможности измения параметров виртуальной машины в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/kvmvm и в cloudbroker/kvmvm | -| BATF-1018 | Ошибка при изменении поля `started`, приводящая к невозможности запуска виртуальной машины в resources `decort_kvmvm` в cloudapi/kvmvm | +| BATF-1052 | Перезагрузка виртуальной машины при изменении полей `ram` и `cpu` в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/kvmvm и в cloudbroker/kvmvm | \ No newline at end of file diff --git a/Makefile b/Makefile index 52e3325d..11d4899e 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ ZIPDIR = ./zip BINARY=${NAME} WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH} MAINPATH = ./cmd/decort/ -VERSION=4.9.3 +VERSION=4.9.4 OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH) FILES = ${BINARY}_${VERSION}_darwin_amd64\ diff --git a/internal/service/cloudapi/kvmvm/resource_compute.go b/internal/service/cloudapi/kvmvm/resource_compute.go index 26999f43..ea480003 100644 --- a/internal/service/cloudapi/kvmvm/resource_compute.go +++ b/internal/service/cloudapi/kvmvm/resource_compute.go @@ -901,12 +901,17 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf } } - // Note bene: numa_affinity, cpu_pin and hp_backed, cpu, ram are not allowed to be changed for compute in STARTED tech status. + // Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status. // If STARTED, we need to stop it before update var isStopRequired bool if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed", "chipset", "preferred_cpu") && d.Get("started").(bool) { isStopRequired = true } + + old, new := d.GetChange("cpu") + if old.(int) > new.(int) && d.Get("started").(bool) { + isStopRequired = true + } if isStopRequired { if _, err := c.CloudAPI().Compute().Stop(ctx, compute.StopRequest{ComputeID: computeRec.ID}); err != nil { return diag.FromErr(err) diff --git a/internal/service/cloudbroker/kvmvm/utility_compute.go b/internal/service/cloudbroker/kvmvm/utility_compute.go index 5728ecce..908d588c 100644 --- a/internal/service/cloudbroker/kvmvm/utility_compute.go +++ b/internal/service/cloudbroker/kvmvm/utility_compute.go @@ -111,7 +111,13 @@ func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interfa c := m.(*controller.ControllerCfg) computeId, _ := strconv.ParseUint(d.Id(), 10, 64) - if d.Get("started").(bool) { + var isStopRequired bool + + old, new := d.GetChange("cpu") + if d.Get("started").(bool) && (old.(int) > new.(int)) { + isStopRequired = true + } + if isStopRequired { stopReq := compute.StopRequest{ ComputeID: computeId, Force: false, @@ -176,7 +182,7 @@ func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interfa } } - if d.Get("started").(bool) { + if isStopRequired { if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil { return err }