Skip to content

Commit 38239b0

Browse files
author
Roy
committed
feat(plugin): 修改插件启动参数cpu/mem获取方式
1 parent a853534 commit 38239b0

1 file changed

Lines changed: 23 additions & 20 deletions

File tree

platform-core/api/v1/plugin/package.go

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,8 @@ func LaunchPlugin(c *gin.Context) {
732732
pluginPackageId := c.Param("pluginPackageId")
733733
hostId := c.Param("hostId")
734734
portValue := c.Param("port")
735-
requestCpu := c.Param("requestCpu")
736-
requestMemory := c.Param("requestMemory")
735+
requestCpu := c.Query("requestCpu")
736+
requestMemory := c.Query("requestMemory")
737737
port, _ := strconv.Atoi(portValue)
738738
if port < 20000 {
739739
middleware.ReturnError(c, fmt.Errorf("param port %s illegal", portValue))
@@ -838,24 +838,27 @@ func LaunchPluginFunc(ctx context.Context, pluginPackageId string, resServer *mo
838838
InstanceName: pluginPackageObj.Name,
839839
}
840840
// 新增k8s资源限制支持
841-
if requestCpu == "" {
842-
if len(resources.Docker) > 0 {
843-
if resources.Docker[0].Cpu != "" {
844-
pluginInstance.Cpu = resources.Docker[0].Cpu
845-
}
846-
}
847-
} else {
848-
pluginInstance.Cpu = requestCpu
849-
}
850-
if requestMemory == "" {
851-
if len(resources.Docker) > 0 {
852-
if resources.Docker[0].Memory != "" {
853-
pluginInstance.Memory = resources.Docker[0].Memory
854-
}
855-
}
856-
} else {
857-
pluginInstance.Memory = requestMemory
858-
}
841+
pluginInstance.Cpu = requestCpu
842+
pluginInstance.Memory = requestMemory
843+
// 依赖前端传入插件声明的数据,此处不自动判定,否则无法区分是无限制还是需要自动取默认值
844+
// if requestCpu == "" {
845+
// if len(resources.Docker) > 0 {
846+
// if resources.Docker[0].Cpu != "" {
847+
// pluginInstance.Cpu = resources.Docker[0].Cpu
848+
// }
849+
// }
850+
// } else {
851+
// pluginInstance.Cpu = requestCpu
852+
// }
853+
// if requestMemory == "" {
854+
// if len(resources.Docker) > 0 {
855+
// if resources.Docker[0].Memory != "" {
856+
// pluginInstance.Memory = resources.Docker[0].Memory
857+
// }
858+
// }
859+
// } else {
860+
// pluginInstance.Memory = requestMemory
861+
// }
859862
if len(resources.Mysql) > 0 {
860863
mysqlResource := resources.Mysql[0]
861864
pluginInstance.PluginMysqlInstanceResourceId = mysqlResource.Id

0 commit comments

Comments
 (0)