This commit is contained in:
2025-08-12 12:30:26 +03:00
parent bae25296bb
commit 22897c3bf5
4 changed files with 17 additions and 7 deletions

View File

@@ -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)

View File

@@ -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
}