mirror of
https://github.com/XShengTech/MEGREZ.git
synced 2026-05-03 13:02:38 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e54fa18283 |
@@ -10,12 +10,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type modifyDataStruct struct {
|
|
||||||
CpuOnly bool `json:"cpu_only"`
|
|
||||||
GpuCount *int `json:"gpu_count"`
|
|
||||||
VolumeSize *int `json:"volume_size"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func modify(serverID uint, data Data) (err error) {
|
func modify(serverID uint, data Data) (err error) {
|
||||||
lc := l.Clone()
|
lc := l.Clone()
|
||||||
lc.SetFunction("modify")
|
lc.SetFunction("modify")
|
||||||
@@ -71,6 +65,7 @@ func modify(serverID uint, data Data) (err error) {
|
|||||||
err = instanceController.Patch(&instance, gpuCount, volumeSize, data.CpuOnly)
|
err = instanceController.Patch(&instance, gpuCount, volumeSize, data.CpuOnly)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
redis.RawDB.IncrBy(ctx, "remain_gpu:server:"+strconv.Itoa(int(serverID)), int64(gpuCount))
|
||||||
redis.RawDB.IncrBy(ctx, "remain_volume:server:"+strconv.Itoa(int(serverID)), int64(volumeSize-oldVolumeSize))
|
redis.RawDB.IncrBy(ctx, "remain_volume:server:"+strconv.Itoa(int(serverID)), int64(volumeSize-oldVolumeSize))
|
||||||
database.DB.Model(&instance).Update("status", models.InstanceStatusFail).Update("from_action", models.InstanceActionModify)
|
database.DB.Model(&instance).Update("status", models.InstanceStatusFail).Update("from_action", models.InstanceActionModify)
|
||||||
lc.Error("patch instance error: %v", err)
|
lc.Error("patch instance error: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user