mirror of
https://github.com/XShengTech/MEGREZ.git
synced 2026-01-13 16:47:16 +08:00
[Fix] 🐛 PreCheck the Config if Instance has Changed #21
This commit is contained in:
parent
69554b5e39
commit
011827f5c7
@ -66,7 +66,17 @@ func modifyHandler(ctx iris.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.CpuOnly == instance.CpuOnly && req.CpuOnly {
|
hasChanges := false
|
||||||
|
if req.CpuOnly != instance.CpuOnly {
|
||||||
|
hasChanges = true
|
||||||
|
}
|
||||||
|
if req.GpuCount != nil && *req.GpuCount != instance.GpuCount {
|
||||||
|
hasChanges = true
|
||||||
|
}
|
||||||
|
if req.VolumeSize != nil && *req.VolumeSize != instance.VolumeSize {
|
||||||
|
hasChanges = true
|
||||||
|
}
|
||||||
|
if !hasChanges {
|
||||||
middleware.Error(ctx, middleware.CodeBadRequest, iris.StatusBadRequest)
|
middleware.Error(ctx, middleware.CodeBadRequest, iris.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,7 +72,17 @@ func modifyHandler(ctx iris.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.CpuOnly == instance.CpuOnly && req.CpuOnly {
|
hasChanges := false
|
||||||
|
if req.CpuOnly != instance.CpuOnly {
|
||||||
|
hasChanges = true
|
||||||
|
}
|
||||||
|
if req.GpuCount != nil && *req.GpuCount != instance.GpuCount {
|
||||||
|
hasChanges = true
|
||||||
|
}
|
||||||
|
if req.VolumeSize != nil && *req.VolumeSize != instance.VolumeSize {
|
||||||
|
hasChanges = true
|
||||||
|
}
|
||||||
|
if !hasChanges {
|
||||||
middleware.Error(ctx, middleware.CodeBadRequest, iris.StatusBadRequest)
|
middleware.Error(ctx, middleware.CodeBadRequest, iris.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,9 +43,19 @@ func modify(serverID uint, data Data) (err error) {
|
|||||||
return errors.New("instance status error")
|
return errors.New("instance status error")
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.CpuOnly == instance.CpuOnly && data.CpuOnly {
|
hasChanges := false
|
||||||
lc.Error("instance already cpu_only mode")
|
if data.CpuOnly != instance.CpuOnly {
|
||||||
return errors.New("instance already cpu_only mode")
|
hasChanges = true
|
||||||
|
}
|
||||||
|
if data.GpuCount != nil && *data.GpuCount != instance.GpuCount {
|
||||||
|
hasChanges = true
|
||||||
|
}
|
||||||
|
if data.VolumeSize != nil && *data.VolumeSize != instance.VolumeSize {
|
||||||
|
hasChanges = true
|
||||||
|
}
|
||||||
|
if !hasChanges {
|
||||||
|
lc.Error("no changes")
|
||||||
|
return errors.New("no changes")
|
||||||
}
|
}
|
||||||
|
|
||||||
oldVolumeSize := instance.VolumeSize
|
oldVolumeSize := instance.VolumeSize
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user