mirror of
https://github.com/XShengTech/MEGREZ.git
synced 2026-01-14 00:57:17 +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
|
||||
}
|
||||
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
||||
@ -72,7 +72,17 @@ func modifyHandler(ctx iris.Context) {
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
||||
@ -43,9 +43,19 @@ func modify(serverID uint, data Data) (err error) {
|
||||
return errors.New("instance status error")
|
||||
}
|
||||
|
||||
if data.CpuOnly == instance.CpuOnly && data.CpuOnly {
|
||||
lc.Error("instance already cpu_only mode")
|
||||
return errors.New("instance already cpu_only mode")
|
||||
hasChanges := false
|
||||
if data.CpuOnly != instance.CpuOnly {
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user