Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 22897c3bf5 | |||
|
|
bae25296bb |
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,23 +1,8 @@
|
||||
## Version 4.9.2
|
||||
|
||||
### Добавлено
|
||||
## Version 4.9.4
|
||||
|
||||
### Исправлено
|
||||
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-999 | Изменен тип поля `url` с optional на required в resource `decort_cb_image` в cloudbroker/image |
|
||||
|
||||
#### kvmvm
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1002 | Ошибка при смене `ip_address` в блоке `network` приводящаяя к смене MAC адрес сети в resource `decort_compute` и `decort_cb_compute` в cloupapi/kvmvm и cloudbroker/kvmvm |
|
||||
|
||||
### Удалено
|
||||
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-999 | Опциональное поле `file_path` в resource `decort_cb_image` в cloudbroker/image |
|
||||
|
||||
| BATF-1052 | Перезагрузка виртуальной машины при изменении полей `ram` и `cpu` в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/kvmvm и в cloudbroker/kvmvm |
|
||||
2
Makefile
2
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.2
|
||||
VERSION=4.9.4
|
||||
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
||||
|
||||
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
||||
|
||||
@@ -842,62 +842,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
doUpdate := false
|
||||
resizeReq := compute.ResizeRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
forceResize, ok := d.GetOk("force_resize")
|
||||
if ok {
|
||||
resizeReq.Force = forceResize.(bool)
|
||||
}
|
||||
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
oldCpu, newCpu := d.GetChange("cpu")
|
||||
if oldCpu.(int) > newCpu.(int) && !forceResize.(bool) {
|
||||
return diag.Errorf("Cannot resize compute ID %d: enable 'force_resize' to reduce compute vCPUs", computeRec.ID)
|
||||
}
|
||||
if oldCpu.(int) != newCpu.(int) {
|
||||
resizeReq.CPU = uint64(newCpu.(int))
|
||||
doUpdate = true
|
||||
} else {
|
||||
resizeReq.CPU = 0
|
||||
}
|
||||
|
||||
if resizeReq.CPU != 0 {
|
||||
if preferredCPU, ok := d.GetOk("preferred_cpu"); ok {
|
||||
preferredList := preferredCPU.([]interface{})
|
||||
if len(preferredList) > 0 {
|
||||
for _, v := range preferredList {
|
||||
cpuNum := v.(int)
|
||||
resizeReq.PreferredCPU = append(resizeReq.PreferredCPU, int64(cpuNum))
|
||||
}
|
||||
}
|
||||
}
|
||||
oldPCPU, newPCPU := d.GetChange("preferred_cpu")
|
||||
if len(oldPCPU.([]interface{})) != 0 && len(newPCPU.([]interface{})) == 0 {
|
||||
resizeReq.PreferredCPU = []int64{-1}
|
||||
}
|
||||
}
|
||||
|
||||
oldRam, newRam := d.GetChange("ram")
|
||||
if oldRam.(int) != newRam.(int) {
|
||||
resizeReq.RAM = uint64(newRam.(int))
|
||||
doUpdate = true
|
||||
} else {
|
||||
resizeReq.RAM = 0
|
||||
}
|
||||
|
||||
if doUpdate {
|
||||
log.Debugf("resourceComputeUpdate: changing CPU %d -> %d and/or RAM %d -> %d",
|
||||
oldCpu.(int), newCpu.(int),
|
||||
oldRam.(int), newRam.(int))
|
||||
_, err := c.CloudAPI().Compute().Resize(ctx, resizeReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
oldSize, newSize := d.GetChange("boot_disk_size")
|
||||
if oldSize.(int) < newSize.(int) {
|
||||
req := compute.DiskResizeRequest{ComputeID: computeRec.ID}
|
||||
@@ -957,6 +901,79 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
doUpdate := false
|
||||
resizeReq := compute.ResizeRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
forceResize, ok := d.GetOk("force_resize")
|
||||
if ok {
|
||||
resizeReq.Force = forceResize.(bool)
|
||||
}
|
||||
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
oldCpu, newCpu := d.GetChange("cpu")
|
||||
if oldCpu.(int) > newCpu.(int) && !forceResize.(bool) {
|
||||
return diag.Errorf("Cannot resize compute ID %d: enable 'force_resize' to reduce compute vCPUs", computeRec.ID)
|
||||
}
|
||||
if oldCpu.(int) != newCpu.(int) {
|
||||
resizeReq.CPU = uint64(newCpu.(int))
|
||||
doUpdate = true
|
||||
} else {
|
||||
resizeReq.CPU = 0
|
||||
}
|
||||
|
||||
if resizeReq.CPU != 0 {
|
||||
if preferredCPU, ok := d.GetOk("preferred_cpu"); ok {
|
||||
preferredList := preferredCPU.([]interface{})
|
||||
if len(preferredList) > 0 {
|
||||
for _, v := range preferredList {
|
||||
cpuNum := v.(int)
|
||||
resizeReq.PreferredCPU = append(resizeReq.PreferredCPU, int64(cpuNum))
|
||||
}
|
||||
}
|
||||
}
|
||||
oldPCPU, newPCPU := d.GetChange("preferred_cpu")
|
||||
if len(oldPCPU.([]interface{})) != 0 && len(newPCPU.([]interface{})) == 0 {
|
||||
resizeReq.PreferredCPU = []int64{-1}
|
||||
}
|
||||
}
|
||||
|
||||
oldRam, newRam := d.GetChange("ram")
|
||||
if oldRam.(int) != newRam.(int) {
|
||||
resizeReq.RAM = uint64(newRam.(int))
|
||||
doUpdate = true
|
||||
} else {
|
||||
resizeReq.RAM = 0
|
||||
}
|
||||
|
||||
if doUpdate {
|
||||
log.Debugf("resourceComputeUpdate: changing CPU %d -> %d and/or RAM %d -> %d",
|
||||
oldCpu.(int), newCpu.(int),
|
||||
oldRam.(int), newRam.(int))
|
||||
_, err := c.CloudAPI().Compute().Resize(ctx, resizeReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChanges("description",
|
||||
"name",
|
||||
"numa_affinity",
|
||||
@@ -1020,28 +1037,17 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
req.NetworkInterfaceNaming = d.Get("network_interface_naming").(string)
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
if isStopRequired {
|
||||
if _, err := c.CloudAPI().Compute().Stop(ctx, compute.StopRequest{ComputeID: computeRec.ID}); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
// perform update
|
||||
if _, err := c.CloudAPI().Compute().Update(ctx, req); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
// If used to be STARTED, we need to start it after update
|
||||
if isStopRequired {
|
||||
if _, err := c.CloudAPI().Compute().Start(ctx, compute.StartRequest{ComputeID: computeRec.ID}); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
// If used to be STARTED, we need to start it after update
|
||||
if isStopRequired {
|
||||
if _, err := c.CloudAPI().Compute().Start(ctx, compute.StartRequest{ComputeID: computeRec.ID}); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1206,24 +1212,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("started") {
|
||||
if d.Get("started").(bool) {
|
||||
req := compute.StartRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
} else {
|
||||
req := compute.StopRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
if _, err := c.CloudAPI().Compute().Stop(ctx, req); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("affinity_label") {
|
||||
affinityLabel := d.Get("affinity_label").(string)
|
||||
if affinityLabel == "" {
|
||||
|
||||
@@ -111,6 +111,22 @@ func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
c := m.(*controller.ControllerCfg)
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
|
||||
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,
|
||||
}
|
||||
if _, err := c.CloudBroker().Compute().Stop(ctx, stopReq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
resizeReq := compute.ResizeRequest{
|
||||
ComputeID: computeId,
|
||||
}
|
||||
@@ -166,6 +182,12 @@ func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
}
|
||||
}
|
||||
|
||||
if isStopRequired {
|
||||
if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user