mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-29 18:27:58 +08:00
support set cpu value is zero
This commit is contained in:
parent
07dc0719b4
commit
78df4345b2
@ -328,10 +328,10 @@ func (p *PluginAction) buildPlugin(b *api_model.BuildPluginStruct, plugin *dbmod
|
||||
Info: b.Body.Info,
|
||||
Status: "building",
|
||||
}
|
||||
if b.Body.PluginCPU == 0 {
|
||||
if b.Body.PluginCPU < 0 {
|
||||
pbv.ContainerCPU = 125
|
||||
}
|
||||
if b.Body.PluginMemory == 0 {
|
||||
if b.Body.PluginMemory < 0 {
|
||||
pbv.ContainerMemory = 50
|
||||
}
|
||||
if err := db.GetManager().TenantPluginBuildVersionDao().AddModel(pbv); err != nil {
|
||||
|
@ -156,10 +156,10 @@ func (s *ServiceAction) SetTenantServicePluginRelation(tenantID, serviceID strin
|
||||
}
|
||||
tsprCPU := pluginversion.ContainerCPU
|
||||
tsprMemory := pluginversion.ContainerMemory
|
||||
if pss.Body.PluginCPU != 0 {
|
||||
if pss.Body.PluginCPU >= 0 {
|
||||
tsprCPU = pss.Body.PluginCPU
|
||||
}
|
||||
if pss.Body.PluginMemory != 0 {
|
||||
if pss.Body.PluginMemory >= 0 {
|
||||
tsprMemory = pss.Body.PluginMemory
|
||||
}
|
||||
relation := &dbmodel.TenantServicePluginRelation{
|
||||
@ -190,10 +190,10 @@ func (s *ServiceAction) UpdateTenantServicePluginRelation(serviceID string, pss
|
||||
}
|
||||
relation.VersionID = pss.Body.VersionID
|
||||
relation.Switch = pss.Body.Switch
|
||||
if pss.Body.PluginCPU != 0 {
|
||||
if pss.Body.PluginCPU >= 0 {
|
||||
relation.ContainerCPU = pss.Body.PluginCPU
|
||||
}
|
||||
if pss.Body.PluginMemory != 0 {
|
||||
if pss.Body.PluginMemory >= 0 {
|
||||
relation.ContainerMemory = pss.Body.PluginMemory
|
||||
}
|
||||
err = db.GetManager().TenantServicePluginRelationDao().UpdateModel(relation)
|
||||
|
@ -89,9 +89,9 @@ type TenantPluginBuildVersion struct {
|
||||
Info string `gorm:"column:info" json:"info"`
|
||||
Status string `gorm:"column:status;size:24" json:"status"`
|
||||
// container default cpu
|
||||
ContainerCPU int `gorm:"column:container_cpu;default:125" json:"container_cpu"`
|
||||
ContainerCPU int `gorm:"column:container_cpu;default:0" json:"container_cpu"`
|
||||
// container default memory
|
||||
ContainerMemory int `gorm:"column:container_memory;default:64" json:"container_memory"`
|
||||
ContainerMemory int `gorm:"column:container_memory;default:0" json:"container_memory"`
|
||||
// container args
|
||||
ContainerCMD string `gorm:"column:container_cmd;size:2048" json:"container_cmd"`
|
||||
}
|
||||
@ -155,9 +155,9 @@ type TenantServicePluginRelation struct {
|
||||
ServiceID string `gorm:"column:service_id;size:32" json:"service_id"`
|
||||
PluginModel string `gorm:"column:plugin_model;size:24" json:"plugin_model"`
|
||||
// container default cpu v3.5.1 add
|
||||
ContainerCPU int `gorm:"column:container_cpu;default:125" json:"container_cpu"`
|
||||
ContainerCPU int `gorm:"column:container_cpu;default:0" json:"container_cpu"`
|
||||
// container default memory v3.5.1 add
|
||||
ContainerMemory int `gorm:"column:container_memory;default:64" json:"container_memory"`
|
||||
ContainerMemory int `gorm:"column:container_memory;default:0" json:"container_memory"`
|
||||
Switch bool `gorm:"column:switch;default:0" json:"switch"`
|
||||
}
|
||||
|
||||
|
@ -165,9 +165,11 @@ type TenantServices struct {
|
||||
// 服务描述
|
||||
Comment string `gorm:"column:comment" json:"comment"`
|
||||
// 容器CPU权重
|
||||
ContainerCPU int `gorm:"column:container_cpu;default:500" json:"container_cpu"`
|
||||
// default is 0, This means that CPU resources are not limited
|
||||
ContainerCPU int `gorm:"column:container_cpu;default:0" json:"container_cpu"`
|
||||
// 容器最大内存
|
||||
ContainerMemory int `gorm:"column:container_memory;default:128" json:"container_memory"`
|
||||
// default is 0, This means that Memory resources are not limited
|
||||
ContainerMemory int `gorm:"column:container_memory;default:0" json:"container_memory"`
|
||||
// container GPU, The amount of video memory applied for GPU. The unit is MiB
|
||||
// default is 0, That means no GPU is required
|
||||
ContainerGPU int `gorm:"column:container_gpu;default:0" json:"container_gpu"`
|
||||
|
@ -30,17 +30,21 @@ func createResourcesByDefaultCPU(memory int, setCPURequest, setCPULimit int64) c
|
||||
if base <= 0 {
|
||||
base = 1
|
||||
}
|
||||
if memory < 512 {
|
||||
cpuRequest, cpuLimit = base*30, base*80
|
||||
} else if memory <= 1024 {
|
||||
cpuRequest, cpuLimit = base*30, base*160
|
||||
if memory > 0 {
|
||||
if memory < 512 {
|
||||
cpuRequest, cpuLimit = base*30, base*80
|
||||
} else if memory <= 1024 {
|
||||
cpuRequest, cpuLimit = base*30, base*160
|
||||
} else {
|
||||
cpuRequest, cpuLimit = base*30, (int64(memory)-1024)/1024*500+1280
|
||||
}
|
||||
} else {
|
||||
cpuRequest, cpuLimit = base*30, ((int64(memory)-1024)/1024*500 + 1280)
|
||||
memory = 0
|
||||
}
|
||||
if setCPULimit > 0 {
|
||||
if setCPULimit >= 0 {
|
||||
cpuLimit = setCPULimit
|
||||
}
|
||||
if setCPURequest > 0 {
|
||||
if setCPURequest >= 0 {
|
||||
cpuRequest = setCPURequest
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user