Compare commits

...

304 Commits

Author SHA1 Message Date
tzwang ff0cedb43b Merge pull request 'updated cron' (#629) from tzwang/pcm-coordinator:master into master 2026-04-27 15:28:28 +08:00
tzwang cd66b59777 update infer openi 2026-04-27 15:27:26 +08:00
tzwang c1cb62f789 Merge pull request 'updated openi' (#628) from tzwang/pcm-coordinator:master into master 2026-04-27 11:29:14 +08:00
tzwang adfbf9a5d2 update infer openi 2026-04-27 11:28:29 +08:00
tzwang 6a241bad72 Merge pull request 'updated openi' (#627) from tzwang/pcm-coordinator:master into master 2026-04-27 10:54:27 +08:00
tzwang c3a7f6a3af update infer openi 2026-04-27 10:53:08 +08:00
tzwang 6ec3a29a9c Merge pull request 'updated openi' (#626) from tzwang/pcm-coordinator:master into master 2026-04-25 16:39:27 +08:00
tzwang 4d5f426b6c update infer openi 2026-04-25 16:38:42 +08:00
tzwang 539837e355 Merge pull request 'updated openi' (#625) from tzwang/pcm-coordinator:master into master 2026-04-25 12:08:48 +08:00
tzwang aeeaecf6a7 update infer openi 2026-04-25 12:07:44 +08:00
tzwang 513cfed082 Merge pull request 'updated openi' (#624) from tzwang/pcm-coordinator:master into master 2026-04-25 12:03:57 +08:00
tzwang e51be34def update infer openi 2026-04-25 12:00:32 +08:00
tzwang e0387a27f2 Merge pull request 'updated openi' (#623) from tzwang/pcm-coordinator:master into master 2026-04-24 21:27:09 +08:00
tzwang ff3b86f32d update infer openi 2026-04-24 21:26:06 +08:00
tzwang 42feab6bf8 Merge pull request 'updated infer openi' (#622) from tzwang/pcm-coordinator:master into master 2026-04-24 20:51:10 +08:00
tzwang 60e7fdccfe update infer openi 2026-04-24 20:32:13 +08:00
tzwang 7e6088cad9 Merge pull request 'update infer openi' (#621) from tzwang/pcm-coordinator:master into master 2026-04-24 18:13:03 +08:00
tzwang 66e567ead0 update infer openi 2026-04-24 18:10:47 +08:00
tzwang 25765e4b1e Merge pull request 'updated infer openi' (#620) from tzwang/pcm-coordinator:master into master 2026-04-24 17:48:15 +08:00
tzwang f07610c9fe update infer update openi status 2026-04-24 17:46:45 +08:00
tzwang cc9e6238b3 update infer update openi status 2026-04-24 17:43:29 +08:00
devad c1624dd7d8 Merge pull request 'fix' (#619) from hotfix/fix-bug into master 2026-03-21 17:14:43 +08:00
jagger 2271a8481d fix 2026-03-18 19:11:18 +08:00
tzwang 02aaa2a58e Merge pull request '状态更新,加入章鱼集群发送report output' (#618) from tzwang/pcm-coordinator:master into master 2026-03-10 19:25:33 +08:00
tzwang 7962ed1eca update train task sync 2026-03-10 18:47:48 +08:00
zhangweiii a6181ddf23 Merge pull request '通算任务状态同步修改' (#617) from master_zw into master 2026-03-09 20:44:41 +08:00
zhangwei b78d47c944 通算任务列表修复用户id问题 2026-03-09 20:45:25 +08:00
zhangweiii 48f68dc963 Merge pull request '通算状态同步' (#616) from master_zw into master 2026-03-09 17:09:54 +08:00
zhangwei fe494a108f 通算的查询 删除 日志接口修改 2026-03-09 15:39:21 +08:00
zhangwei 59104d618b 通算的查询 删除 日志接口修改 2026-03-09 13:42:52 +08:00
devad f68fcca0e6 Merge pull request 'fix' (#615) from hotfix/fix-hpc-report into master 2026-01-29 15:28:14 +08:00
jagger 50c71624e3 Add token handling to task creation and status reporting
Signed-off-by: jagger <cossjie@foxmail.com>
2026-01-29 15:25:53 +08:00
tzwang e25c348c94 Merge pull request 'updated traintaskdetail' (#614) from test into master 2026-01-27 09:49:42 +08:00
tzwang 7553f8f67b updated ai trainingtaskdetail 2026-01-27 09:51:14 +08:00
zhangwei d966ceabff 虚拟机查询详情字段修改 2026-01-23 18:53:32 +08:00
zhangwei 71846f9ca5 虚拟机查询详情字段修改 2026-01-23 18:46:57 +08:00
tzwang 6eeadf78b8 updated syncresult 2026-01-23 17:09:42 +08:00
tzwang 426126614c Merge pull request 'updated syncresult' (#613) from test into master 2026-01-23 17:09:09 +08:00
tzwang 24945355d3 createinferencetasklogic added token 2026-01-23 10:34:15 +08:00
tzwang 94c384a566 Merge pull request 'createInferencetasklogic added token' (#612) from test into master 2026-01-23 10:32:37 +08:00
tzwang bbb48d290d updated cron 2026-01-22 17:46:14 +08:00
tzwang 5f0c2b479f Merge pull request 'updated cron' (#611) from test into master 2026-01-22 17:43:51 +08:00
tzwang 2514a2f6a8 updated cron 2026-01-22 17:43:43 +08:00
tzwang 76845be166 Merge pull request 'test合并到master' (#610) from test into master 2026-01-22 17:40:34 +08:00
tzwang d996ae5dbf updated runtask logic: traintask added model 2026-01-22 17:04:18 +08:00
tzwang 8f815c452d Merge remote-tracking branch 'origin/test' into test 2026-01-22 11:41:13 +08:00
tzwang d71c9688ab added inferencetaskStop route and logic 2026-01-22 11:40:46 +08:00
zhangwei fceb088dbd 博客管理的crud 2026-01-21 18:32:36 +08:00
tzwang 3300d9ba9f added inferencetaskLog route and logic 2026-01-21 16:45:48 +08:00
tzwang 89b1f7c61f update ai service 2026-01-20 19:02:49 +08:00
tzwang cb025314b8 update cron 2026-01-20 15:21:10 +08:00
tzwang 7c287b55a6 update create ai task 2026-01-20 15:17:31 +08:00
tzwang dca5c2cf41 update get token and deploy task status 2026-01-20 12:05:13 +08:00
tzwang be33fa5450 update cron 2026-01-12 15:36:33 +08:00
tzwang d2d7e52dec update cron 2026-01-12 15:33:10 +08:00
tzwang 85089ef409 Merge pull request 'update cron' (#609) from tzwang/pcm-coordinator:master into master 2026-01-12 15:30:16 +08:00
tzwang 897da39d1d update cron 2026-01-12 15:02:13 +08:00
tzwang 5820b1658f Merge pull request 'update cron' (#608) from tzwang/pcm-coordinator:master into master 2026-01-12 14:59:25 +08:00
tzwang a25200ab91 update cron 2026-01-12 14:51:45 +08:00
tzwang ccb56cbfca add slurm conversion methods 2026-01-09 16:29:21 +08:00
tzwang 89d76e6f06 add slurm conversion methods 2026-01-08 16:32:20 +08:00
tzwang fce28695c7 update queryresourceslogic 2026-01-05 11:21:00 +08:00
zhangwei beb0db6447 通算任务查询镜像通过规格id查询 2025-12-31 09:14:09 +08:00
devad e7b460b071 Merge pull request 'fix' (#607) from test into master 2025-12-26 17:18:42 +08:00
jagger 8c01d1c110 Fix spelling of "Canceled" to "Cancelled" in database update logic
Signed-off-by: jagger <cossjie@foxmail.com>
2025-12-26 17:21:02 +08:00
devad aead326363 Merge pull request '修复超算任务运行时状态不更新问题' (#606) from test into master 2025-12-26 16:34:08 +08:00
jagger dadaa105d3 Update git reference to use the test branch in tencent-develop.yml
Signed-off-by: jagger <cossjie@foxmail.com>
2025-12-26 16:18:20 +08:00
jagger ad80ce1faa Improve null handling for task start and end times
Signed-off-by: jagger <cossjie@foxmail.com>
2025-12-26 16:16:54 +08:00
tzwang e814f33cd2 update openi 2025-12-23 16:41:12 +08:00
tzwang ec52a3a275 Merge pull request 'update openi' (#605) from tzwang/pcm-coordinator:master into master 2025-12-23 16:39:15 +08:00
zhangwei 4b4a0b1951 修复定时通算任务bug 2025-12-04 19:31:08 +08:00
jagger 739b2640b8 Merge remote-tracking branch 'gitlink/master' 2025-12-02 17:38:02 +08:00
jagger fe34ef1b37 fix
Signed-off-by: jagger <cossjie@foxmail.com>
2025-12-02 17:37:47 +08:00
tzwang cbf15f71fb update aiStorage 2025-12-02 17:30:35 +08:00
tzwang 43488554c5 Merge pull request 'update aiStorage' (#604) from tzwang/pcm-coordinator:master into master 2025-12-02 17:28:15 +08:00
jagger 1a8d7ad78e fix
Signed-off-by: jagger <cossjie@foxmail.com>
2025-12-02 16:53:11 +08:00
jagger 2e4d08ab6a Merge remote-tracking branch 'gitlink/master' 2025-12-02 16:46:48 +08:00
jagger 9e33e5677f Change TenantId field type to pointer for better null handling
Signed-off-by: jagger <cossjie@foxmail.com>
2025-12-02 16:46:20 +08:00
tzwang e3cbc56060 Merge pull request 'update inferencetaskstat' (#603) from tzwang/pcm-coordinator:master into master 2025-12-02 16:26:59 +08:00
tzwang 8b8bef38e5 update inferencetaskstat 2025-12-02 16:29:27 +08:00
jagger 74ad910920 Refactor task model usage in HPC status reporting and update time handling
Signed-off-by: jagger <cossjie@foxmail.com>
2025-12-02 15:05:21 +08:00
tzwang b452640385 update inferencetaskstat 2025-12-02 11:07:13 +08:00
tzwang 61a1848714 Merge pull request 'update inferencetaskstat' (#602) from tzwang/pcm-coordinator:master into master 2025-12-02 11:05:15 +08:00
zhangwei b90b6a27b0 列表新增cpu和内存字段 2025-12-01 16:53:43 +08:00
tzwang dc444e8ebb Merge pull request 'update cron, inferencetaskstat' (#601) from tzwang/pcm-coordinator:master into master 2025-12-01 16:06:01 +08:00
tzwang cd81126504 update cron, inferencetaskstat 2025-12-01 16:08:24 +08:00
tzwang 4d8f158b66 Merge pull request 'update cron' (#600) from tzwang/pcm-coordinator:master into master 2025-11-28 17:35:07 +08:00
tzwang 2d7181edea update cron 2025-11-28 17:35:47 +08:00
jagger 4dea1377f2 Add TypeClusterResource handler and logic to fetch cluster info by resource type
Signed-off-by: jagger <cossjie@foxmail.com>
2025-11-28 14:50:57 +08:00
tzwang 9964988221 Merge pull request 'updated createinferencelogics' (#599) from tzwang/pcm-coordinator:master into master 2025-11-24 16:08:50 +08:00
tzwang 04556a970c update createinferencelogic 2025-11-24 16:11:02 +08:00
tzwang fced3537f0 update createinferencelogic 2025-11-24 16:03:04 +08:00
tzwang edcc25130c Merge pull request 'update createinferencelogic' (#598) from tzwang/pcm-coordinator:master into master 2025-11-24 16:01:32 +08:00
tzwang 1121f03f4a Merge pull request 'update openi' (#597) from tzwang/pcm-coordinator:master into master 2025-11-21 18:42:49 +08:00
tzwang 1c7aa64828 update openi 2025-11-21 18:45:11 +08:00
tzwang 167aa97687 Merge pull request 'update CreateInferenceTask' (#596) from tzwang/pcm-coordinator:master into master 2025-11-21 10:48:42 +08:00
tzwang 576ca3f3da update CreateInferenceTask 2025-11-21 10:50:12 +08:00
zhangwei 977985ac08 创建通算任务bug fix 2025-11-20 19:17:41 +08:00
tzwang c8ab2c5525 Merge pull request 'update schedule runTask' (#595) from tzwang/pcm-coordinator:master into master 2025-11-20 18:24:58 +08:00
tzwang 2eb6c5e0e7 update scheduleRunTask 2025-11-20 18:16:59 +08:00
zhangwei 49ad57da67 并行智算云 2025-11-20 15:47:41 +08:00
jagger ee77e5ec2f Update query ordering to include status before sort order
Signed-off-by: jagger <cossjie@foxmail.com>
2025-11-18 17:15:42 +08:00
tzwang 3a212d7e39 Merge pull request 'update ai createinferencelogic' (#594) from tzwang/pcm-coordinator:master into master 2025-11-13 18:06:51 +08:00
tzwang 2550c027a8 update ai createinferencelogic 2025-11-13 18:08:35 +08:00
tzwang 3314c1f000 Merge pull request 'update ai createinferencelogic' (#593) from tzwang/pcm-coordinator:master into master 2025-11-12 18:03:22 +08:00
tzwang 1e8b879a63 update ai createinferencelogic 2025-11-12 18:04:32 +08:00
tzwang 3d74ce8f55 Merge pull request 'update ai createinferencelogic' (#592) from tzwang/pcm-coordinator:master into master 2025-11-11 17:43:05 +08:00
tzwang 93ba1c5b9e Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-11-11 17:45:04 +08:00
tzwang f6bd035a1c update ai createinferencelogic 2025-11-11 17:44:41 +08:00
tzwang 7e001744af Merge pull request 'update ai participant' (#591) from tzwang/pcm-coordinator:master into master 2025-11-10 17:47:35 +08:00
tzwang 46fcfde641 update ai participant 2025-11-10 17:45:00 +08:00
zhangwei 84728ee84b 容器和虚拟机开始时间同步bug修复 2025-11-08 11:51:31 +08:00
zhangwei 1129fa369a 容器和虚拟机开始时间同步bug修复 2025-11-08 11:47:44 +08:00
zhangwei 32fa4bbe84 容器和虚拟机开始时间同步bug修复 2025-11-07 16:50:29 +08:00
jagger 23a79927ce fix
Signed-off-by: jagger <cossjie@foxmail.com>
2025-11-07 14:49:08 +08:00
jagger 574c09e2b8 Add JcsUserID to request parameters and task submission logic
Signed-off-by: jagger <cossjie@foxmail.com>
2025-11-07 14:39:05 +08:00
jagger b86a901797 Update work directory path to use jobFullPath instead of jobDir
Signed-off-by: jagger <cossjie@foxmail.com>
2025-11-07 10:13:38 +08:00
zhangwei 78109e3c0d 虚拟机状态同步接口完成 2025-11-06 19:10:19 +08:00
zhangwei d2ee6c536c 虚拟机状态同步接口完成 2025-11-06 19:08:55 +08:00
tzwang 4e535e6974 Merge pull request 'update ai cvt' (#590) from tzwang/pcm-coordinator:master into master 2025-11-06 18:17:47 +08:00
tzwang 0efcd0d512 update ai cvt 2025-11-06 18:19:58 +08:00
tzwang 30bf21d875 update ai cvt 2025-11-06 17:58:59 +08:00
tzwang 14097c3d92 Merge pull request 'update ai cvt' (#589) from tzwang/pcm-coordinator:master into master 2025-11-06 17:56:47 +08:00
tzwang 3b0ec7dc7b update ai cvt 2025-11-06 17:46:35 +08:00
tzwang 90973fdaa8 Merge pull request 'update ai cvt' (#588) from tzwang/pcm-coordinator:master into master 2025-11-06 17:44:22 +08:00
tzwang 2577f600f9 update ai cvt 2025-11-06 17:27:07 +08:00
tzwang 92832c61fc Merge pull request 'update ai cvt' (#587) from tzwang/pcm-coordinator:master into master 2025-11-06 17:25:45 +08:00
tzwang 3a64603c2c Merge pull request 'update openi participant' (#586) from tzwang/pcm-coordinator:master into master 2025-11-05 18:54:31 +08:00
tzwang a9a2c08a81 update openi participant 2025-11-05 18:56:20 +08:00
zhangwei 70855cd95d 创建虚拟机更改参数 2025-11-05 17:23:46 +08:00
zhangwei f75bddd9ed 创建虚拟机更改参数 2025-11-05 16:23:29 +08:00
tzwang 01ccf9a025 Merge pull request 'updated runtask' (#585) from tzwang/pcm-coordinator:master into master 2025-11-05 16:07:09 +08:00
tzwang f7ff33af53 update runTask 2025-11-05 16:03:14 +08:00
zhangwei 3dc14265b9 Merge remote-tracking branch 'origin/master' 2025-11-04 17:21:30 +08:00
zhangwei 1e88f764ab 虚拟机分页查询添加名称和状态查询 2025-11-04 17:21:21 +08:00
jagger 0980495daa Add sort order field to instance model and update query ordering
Signed-off-by: jagger <cossjie@foxmail.com>
2025-11-04 16:59:39 +08:00
tzwang 8c7df931ca Merge pull request 'update participant ai' (#584) from tzwang/pcm-coordinator:master into master 2025-11-04 15:30:30 +08:00
tzwang f3281860e9 update participant ai 2025-11-04 15:26:51 +08:00
zhangwei d3136a8c5b 虚拟机实例监控查询 2025-10-27 16:08:36 +08:00
zhangwei f4636bd12a 实例创建修改字段属性 2025-10-24 11:09:59 +08:00
zhangwei 14ac827483 实例创建修改字段属性 2025-10-24 10:41:56 +08:00
zhangwei feb4250ed8 镜像分页列表 2025-10-21 15:04:50 +08:00
zhangwei 03ac348761 实例详情bug修复 2025-10-17 17:22:19 +08:00
zhangwei d19e3fc21b 查询实例详情补充监控信息 2025-10-17 09:13:56 +08:00
zhangwei ccaf325e46 Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-10-17 08:55:36 +08:00
zhangwei 0b1ac4e46e 查询实例详情补充监控信息 2025-10-17 08:55:28 +08:00
tzwang e8f6d8ad34 Merge pull request 'update octopus ToTrainingTaskDetail' (#583) from tzwang/pcm-coordinator:master into master 2025-10-16 16:25:11 +08:00
tzwang 9235b956b0 Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-10-16 16:26:59 +08:00
tzwang 4453853e3d update octopus ToTrainingTaskDetail 2025-10-16 16:26:01 +08:00
tzwang 22514270a2 update train/infer syncstatus 2025-10-15 18:16:15 +08:00
tzwang 5ca39a40df Merge pull request 'update train/infer syncstatus' (#582) from tzwang/pcm-coordinator:master into master 2025-10-15 18:15:17 +08:00
tzwang f374754928 Merge pull request 'update ai participant' (#581) from tzwang/pcm-coordinator:master into master 2025-10-14 18:25:04 +08:00
tzwang a7d99112b9 update ai participant 2025-10-14 18:26:27 +08:00
zhangwei 1a7d6f9f80 查询实例详情返回系统盘大小 2025-10-14 17:31:05 +08:00
zhangwei fbc250ce20 资源规格列表 2025-10-14 16:27:26 +08:00
zhangwei 0a2b5a450f 资源规格列表 2025-10-14 15:45:01 +08:00
zhangwei 93ccf47bff 查询实例详情接口 2025-10-14 11:00:07 +08:00
zhangwei fd5e60a882 Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-10-14 09:23:09 +08:00
zhangwei c472efdff0 查询实例详情接口 2025-10-14 09:22:55 +08:00
tzwang 6ca32b1726 Merge pull request 'update ai participant' (#580) from tzwang/pcm-coordinator:master into master 2025-10-13 18:13:43 +08:00
tzwang 5872ee40bc update ai participant 2025-10-13 18:15:25 +08:00
zhangwei 944cd66970 Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-10-11 20:11:43 +08:00
zhangwei a7f7743906 实例列表 2025-10-11 20:11:34 +08:00
tzwang 73c5fc00fb Merge pull request 'update ai participant' (#579) from tzwang/pcm-coordinator:master into master 2025-10-11 17:30:24 +08:00
tzwang cbcd267b53 update ai participant 2025-10-11 17:32:05 +08:00
zhangwei ba4e0027b2 操作实例接口修改 2025-10-11 16:32:00 +08:00
zhangwei 883b9af1f5 新增实例列表接口 2025-10-11 11:33:08 +08:00
zhangwei fba85e2c09 新增实例列表接口 2025-10-11 09:47:02 +08:00
zhangwei 34a36affdd 虚拟机实例操作 2025-10-10 15:57:58 +08:00
zhangwei b7e882fb55 虚拟机实例操作 2025-10-10 08:56:47 +08:00
zhangwei 08009da067 定时任务获取通算任务状态修改 2025-09-30 16:02:14 +08:00
zhangwei e6e6b68245 定时任务获取通算任务状态修改 2025-09-30 10:37:57 +08:00
zhangwei 8b155bf813 定时任务获取通算任务状态修改 2025-09-30 10:01:44 +08:00
zhangwei 96dca8a74a 定时任务获取通算任务状态修改 2025-09-30 09:19:47 +08:00
zhangwei df9385872f 定时任务获取通算任务状态修改 2025-09-30 09:17:38 +08:00
zhangwei 8c5190ffd3 定时任务获取通算任务状态修改 2025-09-30 09:08:52 +08:00
tzwang cd4afb9c6b Merge pull request 'update inference deployinstance logic' (#578) from tzwang/pcm-coordinator:master into master 2025-09-29 16:39:16 +08:00
tzwang 569c3c158e update inference deployinstance 2025-09-29 16:40:24 +08:00
tzwang cef122f920 Merge pull request 'added ai participant utils' (#577) from tzwang/pcm-coordinator:master into master 2025-09-28 18:22:07 +08:00
tzwang 5c98e5db11 added ai participant utils 2025-09-28 18:23:39 +08:00
tzwang 11653af0e1 update ai participant 2025-09-28 18:17:02 +08:00
tzwang 216ce13f76 Merge pull request 'update ai participant' (#576) from tzwang/pcm-coordinator:master into master 2025-09-28 18:15:22 +08:00
tzwang 469260042a update ai participant 2025-09-28 17:54:16 +08:00
tzwang 52686f0e4d Merge pull request 'update ai participant' (#575) from tzwang/pcm-coordinator:master into master 2025-09-28 17:53:28 +08:00
zhangweiii 313d652e9a Merge pull request '虚拟机实例创建新增字段' (#574) from zhangweiii/pcm-coordinator:master into master 2025-09-28 10:47:04 +08:00
zhangwei 53bd8a71cd 创建虚拟机实例 2025-09-28 10:47:36 +08:00
zhangweiii f046b8b021 Merge pull request '创建虚拟机实例' (#573) from zhangweiii/pcm-coordinator:master into master 2025-09-28 09:58:30 +08:00
zhangwei 3f1384f2cd Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-09-28 09:39:58 +08:00
zhangwei e4884dcc12 创建虚拟机实例 2025-09-28 09:39:44 +08:00
tzwang 3862f80f5d Merge pull request 'update ai participant' (#572) from tzwang/pcm-coordinator:master into master 2025-09-25 19:09:55 +08:00
tzwang b6f53e8f33 update ai participant 2025-09-25 19:10:49 +08:00
zhangwei 4c95380389 Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-09-25 14:35:31 +08:00
zhangwei 5493b582bf 通算新增命名空间模块 2025-09-25 14:31:51 +08:00
jagger 0ac4a6ceda Add status filter to task list query parameters
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-23 15:23:09 +08:00
jagger 0a8555b381 Improve resource utilization calculations by adding checks for available resources
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-22 10:58:54 +08:00
tzwang 22604c26e6 Merge pull request 'updated joblog' (#571) from tzwang/pcm-coordinator:master into master 2025-09-19 17:43:49 +08:00
tzwang 2a35ba546b update joblog 2025-09-19 17:42:54 +08:00
jagger 3a21601ac3 Merge remote-tracking branch 'gitlink/master' 2025-09-19 14:39:24 +08:00
jagger 0b933bbd65 Add FileParams field to container creation parameters
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-19 14:39:03 +08:00
tzwang 08cb2d05d2 Merge pull request 'update queryresourceslogic' (#570) from tzwang/pcm-coordinator:master into master 2025-09-19 11:13:56 +08:00
tzwang 442129d7e4 update queryresourceslogic 2025-09-19 11:12:18 +08:00
jagger 7eca1049dd fix
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-16 18:24:47 +08:00
tzwang 4a77ae8b2f Merge pull request 'update octopushttp' (#569) from tzwang/pcm-coordinator:master into master 2025-09-12 11:36:52 +08:00
tzwang 45e80861a6 update octopushttp 2025-09-12 11:38:01 +08:00
tzwang 105c4a6ef5 update octopushttp 2025-09-12 11:28:43 +08:00
tzwang 59286eef3c Merge pull request 'update octopushttp resource' (#568) from tzwang/pcm-coordinator:master into master 2025-09-12 11:28:42 +08:00
tzwang 2dffbc82d2 update modelarts 2025-09-11 11:25:46 +08:00
tzwang ce34871239 Merge pull request 'update modelarts default submit param' (#567) from tzwang/pcm-coordinator:master into master 2025-09-11 11:25:09 +08:00
jagger d459e778be Get the resource specification list and add the cluster type field filter
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-11 10:27:30 +08:00
jagger ae09113e03 增加算力清单
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-10 18:08:09 +08:00
zhangwei ba21022293 任务资源监控 2025-09-10 09:59:45 +08:00
zhangweiii 39e48a1e43 Merge pull request '通算监控' (#566) from zhangweiii/pcm-coordinator:master into master 2025-09-10 09:58:33 +08:00
zhangwei 5199871a63 任务资源监控 2025-09-10 09:20:40 +08:00
zhangweiii cf3f32a0d8 Merge pull request 'http://pcm-participant:9599' (#565) from zhangweiii/pcm-coordinator:master into master 2025-09-10 09:20:34 +08:00
zhangwei 626a6eb6dd Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator
# Conflicts:
#	internal/logic/xjlab/task_resource_usage.go
2025-09-10 09:19:58 +08:00
zhangwei 602861d6d5 任务资源监控 2025-09-10 09:18:59 +08:00
jagger 31966c05a4 fix
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-09 18:31:05 +08:00
tzwang 25e2b48876 Merge pull request 'update task_resource_usage' (#564) from tzwang/pcm-coordinator:master into master 2025-09-09 17:47:31 +08:00
tzwang 952b23bdba Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-09-09 17:48:32 +08:00
tzwang de33678941 update task_resource_usage 2025-09-09 17:48:20 +08:00
tzwang defaba5f69 update task_resource_usage 2025-09-09 17:05:36 +08:00
tzwang 9cf502d3e0 Merge pull request 'update task_resource_usage' (#563) from tzwang/pcm-coordinator:master into master 2025-09-09 17:04:56 +08:00
tzwang 0b040611c3 Merge pull request 'update octopushttp' (#562) from tzwang/pcm-coordinator:master into master 2025-09-09 15:17:15 +08:00
tzwang 0e1dd6aaab update octopushttp 2025-09-09 15:15:34 +08:00
tzwang a34ca541ad Merge pull request 'update octopushttp' (#561) from tzwang/pcm-coordinator:master into master 2025-09-08 17:05:57 +08:00
tzwang e767ade95c Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-09-08 17:05:56 +08:00
tzwang 1af848fce3 update octopushttp 2025-09-08 17:05:13 +08:00
jagger 18a256764a fix
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-08 16:26:30 +08:00
jagger 9967a59a75 fix
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-08 15:59:39 +08:00
tzwang 0bc582243b update octopus custom params 2025-09-08 11:21:51 +08:00
tzwang c95b8e794f Merge pull request 'update octopus custom params' (#560) from tzwang/pcm-coordinator:master into master 2025-09-08 11:20:59 +08:00
jagger ceb8d8f473 add TaskResourceStatus struct
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-08 11:07:07 +08:00
tzwang 438a64d7a2 Merge pull request 'update octopus custom params' (#559) from tzwang/pcm-coordinator:master into master 2025-09-08 10:21:02 +08:00
tzwang 407da5db64 update octopus custom params 2025-09-08 10:21:51 +08:00
tzwang 622c4c0fcb Merge pull request 'update openi custom params' (#558) from tzwang/pcm-coordinator:master into master 2025-09-08 08:57:36 +08:00
tzwang 80333b4017 update openi custom params 2025-09-08 08:57:28 +08:00
zhangweiii 723b72ebdd Merge pull request '通算任务对接存储' (#557) from zhangweiii/pcm-coordinator:master into master 2025-09-05 20:49:37 +08:00
zhangwei 3a9fb27416 Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-09-05 20:47:50 +08:00
zhangwei c44ec47789 通算任务连接存储 2025-09-05 20:47:34 +08:00
jagger 39c303bf6f fix: update Dockerfile to use new Golang image repository
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-05 17:41:15 +08:00
jagger 890cc30f29 Merge remote-tracking branch 'gitlink/master' 2025-09-05 17:33:28 +08:00
jagger 4f413d432f fix: update Dockerfile to use new Golang image repository
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-05 17:32:15 +08:00
tzwang 2a0245de01 update openi custom params 2025-09-05 17:30:59 +08:00
tzwang 5b55e1664f Merge pull request 'update openi custom params' (#556) from tzwang/pcm-coordinator:master into master 2025-09-05 17:30:23 +08:00
jagger bb6109bca5 feat: add overview endpoints for computing type ratio, counting HPC app executions, task statuses, and listing tasks
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-05 17:24:05 +08:00
jagger 216d597cf3 Merge remote-tracking branch 'gitlink/master' 2025-09-05 16:59:08 +08:00
jagger f01397be3a feat: add overview endpoints for computing type ratio, counting HPC app executions, task statuses, and listing tasks
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-05 16:58:38 +08:00
tzwang 85d6849d1d Merge pull request 'update openi custom params' (#555) from tzwang/pcm-coordinator:master into master 2025-09-05 16:54:15 +08:00
tzwang 562d9c6275 update openi custom params 2025-09-05 16:53:52 +08:00
tzwang f35d7ab038 update octopusHttp 2025-09-05 15:35:44 +08:00
tzwang 1739db258c Merge pull request 'update octopusHttp env' (#554) from tzwang/pcm-coordinator:master into master 2025-09-05 15:34:58 +08:00
tzwang 7db6c6d830 update octopusHttp 2025-09-05 11:21:45 +08:00
tzwang 72bd860dec Merge pull request 'update octopusHttp' (#553) from tzwang/pcm-coordinator:master into master 2025-09-05 11:21:32 +08:00
tzwang 4c981584f2 Merge pull request 'add default param' (#552) from tzwang/pcm-coordinator:master into master 2025-09-04 16:32:09 +08:00
tzwang 579d956f9a add default param 2025-09-04 16:32:31 +08:00
zhangwei dd4c1f2567 通算任务删除修改 2025-09-04 16:18:53 +08:00
zhangweiii be1a71d6d7 Merge pull request '通算任务删除接口修复' (#551) from zhangweiii/pcm-coordinator:master into master 2025-09-04 16:18:50 +08:00
zhangwei 73f996fced 通算任务删除修改 2025-09-04 15:41:59 +08:00
zhangweiii 551a297ded Merge pull request '通算任务删除修改' (#550) from zhangweiii/pcm-coordinator:master into master 2025-09-04 15:40:53 +08:00
zhangwei 26db9fe068 Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-09-04 15:28:39 +08:00
zhangwei b0c5303b96 通算任务删除修改 2025-09-04 15:28:24 +08:00
zhangweiii 2e359ea2c8 Merge pull request '通算任务删除修改' (#549) from zhangweiii/pcm-coordinator:master into master 2025-09-04 15:28:15 +08:00
jagger 8ddc4ef537 feat: add filtering by cluster ID in getClusterBaseInfo logic
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-04 09:49:31 +08:00
zhangwei 916196e961 Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-09-03 19:08:24 +08:00
zhangwei 68bbd11748 通算增加容器监控 2025-09-03 19:08:12 +08:00
zhangweiii 2981e290e3 Merge pull request '通算任务增加监控' (#548) from zhangweiii/pcm-coordinator:master into master 2025-09-03 19:07:28 +08:00
jagger 88166ac24f feat: enhance task status filtering to support multiple statuses
Signed-off-by: jagger <cossjie@foxmail.com>
2025-09-03 17:25:33 +08:00
tzwang 6ab9890134 Merge pull request 'update client timeout' (#547) from tzwang/pcm-coordinator:master into master 2025-09-03 17:09:40 +08:00
tzwang f2596a6d90 update client timeout 2025-09-03 17:10:13 +08:00
zhangwei 2e297362f0 Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-09-02 19:33:14 +08:00
zhangweiii 5a2b9d5959 Merge pull request '通算增加容器监控' (#546) from zhangweiii/pcm-coordinator:master into master 2025-09-02 19:31:56 +08:00
zhangwei 7b9398a3d7 通算增加容器监控 2025-09-02 19:31:23 +08:00
tzwang 1d85f430ab Merge pull request 'update task_resource_usage' (#545) from tzwang/pcm-coordinator:master into master 2025-09-02 17:49:57 +08:00
tzwang 8b45e1ba85 update task_resource_usage 2025-09-02 17:50:49 +08:00
tzwang 291a8347d0 Merge pull request 'update octopushttp' (#544) from tzwang/pcm-coordinator:master into master 2025-09-02 15:09:56 +08:00
tzwang ccbaae766f update octopushttp 2025-09-02 15:09:39 +08:00
tzwang 84d10e9249 Merge pull request 'update octopushttp resourcePool' (#543) from tzwang/pcm-coordinator:master into master 2025-09-01 17:41:21 +08:00
tzwang c5a7c7f233 update octopushttp resourcePool 2025-09-01 17:40:57 +08:00
tzwang 89823bf54e Merge pull request 'update octopushttp resourcePool' (#542) from tzwang/pcm-coordinator:master into master 2025-09-01 11:00:35 +08:00
tzwang 2e65585b4c update octopushttp resourcePool 2025-09-01 10:59:28 +08:00
tzwang 3e6daf350d Merge pull request 'update octopushttp' (#541) from tzwang/pcm-coordinator:master into master 2025-08-28 20:23:43 +08:00
tzwang d4c88602c1 update octopushttp 2025-08-28 20:24:18 +08:00
zhangwei e5b41573a5 Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator 2025-08-28 18:21:51 +08:00
zhangwei 3dfddf8a13 容器删除 2025-08-28 18:21:42 +08:00
zhangweiii 99c6f9b49f Merge pull request '容器删除接口修改' (#540) from zhangweiii/pcm-coordinator:master into master 2025-08-28 18:20:52 +08:00
zhangwei a4bf41dae1 容器删除 2025-08-28 18:19:50 +08:00
jagger c206111e47 feat: add task failure analysis endpoint and logic
Signed-off-by: jagger <cossjie@foxmail.com>
2025-08-27 19:27:40 +08:00
tzwang 3ee60519e9 Merge pull request 'update aijoblog' (#539) from tzwang/pcm-coordinator:master into master 2025-08-26 16:29:19 +08:00
tzwang f67589382f update aijoblog 2025-08-26 16:10:53 +08:00
tzwang 998998f13a update aijoblog 2025-08-26 15:58:34 +08:00
tzwang 21a7258d38 update openi 2025-08-26 09:10:57 +08:00
tzwang d58b56987e Merge pull request 'update openi' (#538) from tzwang/pcm-coordinator:master into master 2025-08-26 09:10:50 +08:00
zhangwei fd843e9864 通算增加状态同步 2025-08-25 09:29:05 +08:00
zhangweiii 80f0c3718b Merge pull request '通算任务同步状态' (#537) from zhangweiii/pcm-coordinator:master into master 2025-08-25 09:28:12 +08:00
zhangweiii ad2df5b380 Merge pull request '通算任务同步状态' (#536) from zhangweiii/pcm-coordinator:master into master 2025-08-25 09:25:41 +08:00
zhangwei 05c1c23cbd Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator
# Conflicts:
#	internal/logic/cloud/containercreatelogic.go
2025-08-25 09:09:25 +08:00
zhangwei 321da46ef1 通算增加状态同步 2025-08-25 09:08:20 +08:00
jagger d0a4d115a1 fix: update Dockerfile base images to use new registry
Signed-off-by: jagger <cossjie@foxmail.com>
2025-08-22 17:14:41 +08:00
jagger ff72602018 Merge remote-tracking branch 'gitlink/master' 2025-08-22 15:20:44 +08:00
jagger 55494450e3 refactor task handling; improve resource usage tracking, enhance task status reporting, and update Dockerfile base images
Signed-off-by: jagger <cossjie@foxmail.com>
2025-08-22 15:20:08 +08:00
tzwang 4dfe23236c Merge pull request 'update ai service' (#535) from tzwang/pcm-coordinator:master into master 2025-08-21 11:02:54 +08:00
tzwang 99d47f45f0 update ai service 2025-08-21 11:03:29 +08:00
tzwang 01fde0a3b2 Merge pull request 'update ai service adapterid' (#534) from tzwang/pcm-coordinator:master into master 2025-08-21 10:55:09 +08:00
tzwang 98d8c94ff2 update ai service adapterid 2025-08-21 10:54:40 +08:00
186 changed files with 8159 additions and 1949 deletions

View File

@ -15,7 +15,7 @@ workflow:
task: git_clone@1.2.9
input:
remote_url: '"https://gitlink.org.cn/JointCloud/pcm-coordinator.git"'
ref: '"refs/heads/master"'
ref: '"refs/heads/test"'
commit_id: '""'
depth: 1
needs:

View File

@ -1,4 +1,4 @@
FROM docker-0.unsee.tech/golang:alpine AS builder
FROM docker.1ms.run/golang:alpine AS builder
WORKDIR /app
@ -21,7 +21,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-w -s" -o pcm-core-api
FROM --platform=$TARGETPLATFORM docker-0.unsee.tech/alpine:latest
FROM --platform=$TARGETPLATFORM docker.1ms.run/alpine:latest
WORKDIR /app
RUN apk add --no-cache ca-certificates && update-ca-certificates && \

View File

@ -95,6 +95,7 @@ JcsMiddleware:
Participant:
AdapterId: "1777144940456666666"
CloudAdapterId: "1770658294298316800"
ServiceToken: "CHANGE_ME_INTERNAL_SERVICE_TOKEN"
JccUserService:
Url: http://jcce-admin:8082/jcc-admin/admin/user/{id}
Url: http://jcce-admin:8082/jcc-admin/admin/user/{id}

8
go.mod
View File

@ -5,8 +5,8 @@ go 1.23.0
require (
github.com/JCCE-nudt/apigw-go-sdk v0.0.0-20230525025609-34159d6f2818
github.com/Masterminds/squirrel v1.5.4
github.com/aliyun/alibaba-cloud-sdk-go v1.63.107
github.com/bwmarrin/snowflake v0.3.0
github.com/ghodss/yaml v1.0.0
github.com/go-redis/redis/v8 v8.11.5
github.com/go-resty/resty/v2 v2.16.2
github.com/golang-jwt/jwt/v5 v5.2.2
@ -24,11 +24,12 @@ require (
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20250107025835-8fc888b1d170
gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250624091120-dee975c73c57
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250912031150-2f5de7195a9f
gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5
go.opentelemetry.io/otel/trace v1.32.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
gonum.org/v1/gonum v0.11.0
google.golang.org/grpc v1.68.1
gopkg.in/yaml.v2 v2.4.0
@ -128,7 +129,7 @@ require (
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
@ -172,7 +173,6 @@ require (
go.uber.org/zap v1.27.0 // indirect
golang.org/x/arch v0.15.0 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.37.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect

38
go.sum
View File

@ -38,10 +38,12 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
github.com/JCCE-nudt/apigw-go-sdk v0.0.0-20230525025609-34159d6f2818 h1:QLulhUyxPDs9FFieVZwmKAnUBLeRDhsVNehotAAL/FE=
github.com/JCCE-nudt/apigw-go-sdk v0.0.0-20230525025609-34159d6f2818/go.mod h1:j+am5/1URgsvyhOAyURFR9vH3malaW7Tq6d33OyPsnM=
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY=
github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@ -55,6 +57,8 @@ github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis/v2 v2.33.0 h1:uvTF0EDeu9RLnUEG27Db5I68ESoIxTiXbNUiji6lZrA=
github.com/alicebob/miniredis/v2 v2.33.0/go.mod h1:MhP4a3EU7aENRi9aO+tHfTBZicLqQevyi/DJpoj6mi0=
github.com/aliyun/alibaba-cloud-sdk-go v1.63.107 h1:qagvUyrgOnBIlVRQWOyCZGVKUIYbMBdGdJ104vBpRFU=
github.com/aliyun/alibaba-cloud-sdk-go v1.63.107/go.mod h1:SOSDHfe1kX91v3W5QiBsWSLqeLxImobbMX1mxrFHsVQ=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA=
github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4=
@ -101,6 +105,7 @@ github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03V
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
@ -115,6 +120,7 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
@ -123,8 +129,6 @@ github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
@ -194,6 +198,7 @@ github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRx
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
@ -202,6 +207,7 @@ github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0kt
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@ -334,6 +340,7 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
@ -395,6 +402,7 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
@ -407,8 +415,8 @@ github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b h1:FfH+VrHHk6Lxt9HdVS0PXzSXFyS2NbZKXv33FYPol0A=
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b/go.mod h1:AC62GU6hc0BrNm+9RK9VSiwa/EUe1bkIeFORAMcHvJU=
github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg=
github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
@ -516,6 +524,10 @@ github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSW
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o=
github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg=
github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
@ -539,8 +551,8 @@ gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4 h1:WIs/189l
gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4/go.mod h1:YbuoRgF9sEVvNJPQtGRjdocX7Du6NBOTLn+GVwqRVjo=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6 h1:9o0ONbSiQHTzODptzgtVZjRYFBLncZ6dpHp9YF+v73I=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6/go.mod h1:MxtnJJcU8S4zfGKZVcg2MOXGtwucKy7MMDwA0IemBd0=
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250624091120-dee975c73c57 h1:+T/ZPk1hjNBQy5pKqLsd27s4PVJbee4CzB0OWV27mg4=
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250624091120-dee975c73c57/go.mod h1:iQtyaoeMP4mNY0xutDBDD/305QwnPjj0zNtiQjXix50=
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250912031150-2f5de7195a9f h1:W9x63bxs13zbb05Wo+cYi4EZhbqd+6KAn+yWw7Tdk88=
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250912031150-2f5de7195a9f/go.mod h1:iQtyaoeMP4mNY0xutDBDD/305QwnPjj0zNtiQjXix50=
gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee h1:+YYzcWPX0Up98nOb5ngkCaqiWHpSH7XJQRTUSvYclWU=
gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee/go.mod h1:0VMTWXsRx7Z5z+kxBid2zf7kq5YtFlxubXEwPHiicyM=
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6PsZ1+bev294IWdZRlV7mnOwI1+UzFcldVW/BqhQzI=
@ -582,6 +594,7 @@ go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQD
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg=
go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
@ -603,7 +616,10 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
@ -615,6 +631,7 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@ -757,8 +774,10 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxb
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
@ -807,8 +826,12 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0=
gonum.org/v1/gonum v0.11.0 h1:f1IJhK4Km5tBJmaiJXtk/PkL4cdVX6J+tGiM187uT5E=
gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA=
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
@ -895,6 +918,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
@ -915,6 +939,7 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/datatypes v1.2.0 h1:5YT+eokWdIxhJgWHdrb2zYUimyk0+TaFth+7a0ybzco=
@ -951,6 +976,7 @@ k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJ
k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE=

View File

@ -73,4 +73,5 @@ type JcsMiddleware struct {
type Participant struct {
AdapterId string
CloudAdapterId string
ServiceToken string
}

View File

@ -17,6 +17,7 @@ package cron
import (
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/utils/stat"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/utils/status"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
)
@ -27,20 +28,20 @@ func AddCronGroup(svc *svc.ServiceContext) {
UpdateAiAdapterMaps(svc)
})
//svc.Cron.AddFunc("30 * * * * ?", func() {
// adapterList, err := svc.Scheduler.AiStorages.GetAdaptersByType("1")
// if err != nil {
// logx.Errorf(err.Error())
// return
// }
// stat.UpdateClusterResources(svc, adapterList)
//})
svc.Cron.AddFunc("@hourly", func() {
status.UpdateAutoStoppedInstance(svc)
svc.Cron.AddFunc("30 * * * * ?", func() {
adapterList, err := svc.Scheduler.AiStorages.GetAdaptersByType("1")
if err != nil {
logx.Errorf(err.Error())
return
}
stat.UpdateClusterResources(svc, adapterList)
})
svc.Cron.AddFunc("1 * * * * *", func() {
svc.Cron.AddFunc("0 */5 * * * *", func() {
svc.Scheduler.AiService.Si.UpdateAutoStoppedInstance()
})
svc.Cron.AddFunc("0 */1 * * * *", func() {
queryResource := schedule.NewQueryResourcesLogic(svc.HttpClient.R().Context(), svc)
trainResrc, err := queryResource.QueryResourcesByClusterId(nil, "Train")
if err != nil {
@ -60,7 +61,7 @@ func AddCronGroup(svc *svc.ServiceContext) {
})
//更新推理任务状态
svc.Cron.AddFunc("*/5 * * * * ?", func() {
svc.Cron.AddFunc("*/10 * * * * ?", func() {
tasks, err := svc.Scheduler.AiStorages.GetInferDeployInstanceListLastMonth()
if err != nil {
logx.Error(err)
@ -69,7 +70,7 @@ func AddCronGroup(svc *svc.ServiceContext) {
})
//更新训练任务状态
svc.Cron.AddFunc("*/10 * * * * ?", func() {
svc.Cron.AddFunc("0 */1 * * * *", func() {
tasks, err := svc.Scheduler.AiStorages.AllTaskLastMonth()
if err != nil {
logx.Error(err)
@ -77,6 +78,7 @@ func AddCronGroup(svc *svc.ServiceContext) {
go svc.Scheduler.AiService.St.UpdateTaskStatus(tasks)
go svc.Scheduler.AiService.St.UpdateAiTaskStatus(tasks)
})
svc.Cron.AddFunc("*/30 * * * * ?", func() {
status.UpdateCloudTaskStatus(svc)
})

View File

@ -0,0 +1,48 @@
package adapters
import (
"net/http"
"strings"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
)
func ClusterBootstrapHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if !validateServiceToken(r, svcCtx) {
http.Error(w, "unauthorized", http.StatusUnauthorized)
return
}
var req types.ClusterBootstrapReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := adapters.NewClusterBootstrapLogic(r.Context(), svcCtx)
resp, err := l.ClusterBootstrap(&req)
result.HttpResult(r, w, resp, err)
}
}
func validateServiceToken(r *http.Request, svcCtx *svc.ServiceContext) bool {
expected := strings.TrimSpace(svcCtx.Config.Participant.ServiceToken)
if expected == "" {
return false
}
provided := strings.TrimSpace(r.Header.Get("X-Service-Token"))
if provided == expected {
return true
}
auth := strings.TrimSpace(r.Header.Get("Authorization"))
if auth == "" {
return false
}
return strings.TrimSpace(strings.TrimPrefix(auth, "Bearer")) == expected
}

View File

@ -25,6 +25,10 @@ func CreateAlgorithmHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
// 获取token信息
token := r.Header.Get("Authorization")
req.Token = token
l := ai.NewCreateAlgorithmLogic(r.Context(), svcCtx)
resp, err := l.CreateAlgorithm(&req)
result.HttpResult(r, w, resp, err)

View File

@ -25,6 +25,10 @@ func TaskResultSyncHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
// 获取token信息
token := r.Header.Get("Authorization")
req.Token = token
l := ai.NewTaskResultSyncLogic(r.Context(), svcCtx)
resp, err := l.TaskResultSync(&req)
result.HttpResult(r, w, resp, err)

View File

@ -0,0 +1,24 @@
package ai
import (
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"net/http"
)
func TrainingTaskDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.TaskDetailReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := ai.NewTrainingTaskDetailsLogic(r.Context(), svcCtx)
resp, err := l.TaskDetails(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -2,6 +2,7 @@ package ai
import (
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai"
@ -10,8 +11,14 @@ import (
func TrainingTaskStatHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
token := r.Header.Get("Authorization")
jccUserInfo, err := utils.ParseTokenWithoutVerify(token)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := ai.NewTrainingTaskStatLogic(r.Context(), svcCtx)
resp, err := l.TrainingTaskStat()
resp, err := l.TrainingTaskStat(jccUserInfo.UserName, jccUserInfo.Id)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -1,11 +1,11 @@
package cloud
import (
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
"io"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"k8s.io/apimachinery/pkg/util/json"
@ -26,12 +26,15 @@ func ContainerCreateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
result.ParamErrorResult(r, w, err)
return
}
// 获取用户信息
userStr := r.Header.Get("User")
user := &models.JccUserInfo{}
json.Unmarshal([]byte(userStr), user)
req.UserId = user.Id
req.UserName = user.UserName
// 获取token信息
token := r.Header.Get("Authorization")
jccUserInfo, err := utils.ParseTokenWithoutVerify(token)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
req.UserId = jccUserInfo.Id
req.UserName = jccUserInfo.UserName
l := cloud.NewContainerCreateLogic(r.Context(), svcCtx)
resp, err := l.ContainerCreate(&req)
result.HttpResult(r, w, resp, err)

View File

@ -1,10 +1,9 @@
package cloud
import (
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"io"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
@ -14,17 +13,10 @@ import (
func ContainerDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req container.DeleteParam
body, err := io.ReadAll(r.Body)
if err != nil {
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err = json.Unmarshal(body, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := cloud.NewContainerDeleteLogic(r.Context(), svcCtx)
resp, err := l.ContainerDelete(&req)
result.HttpResult(r, w, resp, err)

View File

@ -1,11 +1,12 @@
package cloud
import (
"io"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"io"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"

View File

@ -1,24 +1,24 @@
package cloud
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"net/http"
)
func DeleteYamlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func ContainerImagesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ApplyReq
var req container.ImagesParam
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := cloud.NewDeleteYamlLogic(r.Context(), svcCtx)
resp, err := l.DeleteYaml(&req)
l := cloud.NewContainerImagesLogic(r.Context(), svcCtx)
resp, err := l.ContainerImages(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -1,10 +1,10 @@
package cloud
import (
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"io"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
@ -14,17 +14,10 @@ import (
func ContainerLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req container.LogParam
body, err := io.ReadAll(r.Body)
if err != nil {
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err = json.Unmarshal(body, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := cloud.NewContainerLogLogic(r.Context(), svcCtx)
resp, err := l.ContainerLog(&req)
result.HttpResult(r, w, resp, err)

View File

@ -2,23 +2,24 @@ package cloud
import (
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
)
func PodLogsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func ContainerMetricsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.PodLogsReq
var req container.MetricsParam
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := cloud.NewPodLogsLogic(r.Context(), svcCtx, w)
resp, err := l.PodLogs(&req, w)
l := cloud.NewContainerMetricsLogic(r.Context(), svcCtx)
resp, err := l.ContainerMetrics(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,32 @@
package cloud
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
instance "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
)
func InstanceImagesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req instance.InstanceImagesParam
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
// 获取token信息
//token := r.Header.Get("Authorization")
//jccUserInfo, err := utils.ParseTokenWithoutVerify(token)
//if err != nil {
// result.ParamErrorResult(r, w, err)
// return
//}
//req.UserId = jccUserInfo.Id
l := cloud.NewInstanceImagesLogic(r.Context(), svcCtx)
resp, err := l.InstanceImages(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,40 @@
package cloud
import (
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
"io"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
)
func InstanceCreateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req container.CreateInstanceParam
body, err := io.ReadAll(r.Body)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err = json.Unmarshal(body, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
// 获取token信息
token := r.Header.Get("Authorization")
jccUserInfo, err := utils.ParseTokenWithoutVerify(token)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
req.UserId = jccUserInfo.Id
req.Username = jccUserInfo.UserName
l := cloud.NewInstanceCreateLogic(r.Context(), svcCtx)
resp, err := l.InstanceCreate(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,32 @@
package cloud
import (
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
instance "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
"net/http"
)
func InstanceInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req instance.InstanceInfoParam
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
// 获取token信息
token := r.Header.Get("Authorization")
jccUserInfo, err := utils.ParseTokenWithoutVerify(token)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
req.UserId = jccUserInfo.Id
l := cloud.NewInstanceInfoLogic(r.Context(), svcCtx)
resp, err := l.InstanceInfo(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,34 @@
package cloud
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
instance "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
)
func InstanceListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req instance.PageInstanceParam
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
// 获取token信息
token := r.Header.Get("Authorization")
jccUserInfo, err := utils.ParseTokenWithoutVerify(token)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
req.UserId = jccUserInfo.Id
req.UserName = jccUserInfo.UserName
l := cloud.NewInstanceListLogic(r.Context(), svcCtx)
resp, err := l.InstanceList(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,31 @@
package cloud
import (
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
cloud2 "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"io"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
)
func InstanceOperateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req cloud2.OperateInstanceParam
body, err := io.ReadAll(r.Body)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err = json.Unmarshal(body, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := cloud.NewInstanceOperateLogic(r.Context(), svcCtx)
resp, err := l.InstanceOperate(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,32 @@
package cloud
import (
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
instance "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
"net/http"
)
func InstanceTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req instance.InstanceTypesParam
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
// 获取token信息
token := r.Header.Get("Authorization")
jccUserInfo, err := utils.ParseTokenWithoutVerify(token)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
req.UserId = jccUserInfo.Id
l := cloud.NewInstanceTypesLogic(r.Context(), svcCtx)
resp, err := l.InstanceTypes(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,33 @@
package cloud
import (
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"io"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"k8s.io/apimachinery/pkg/util/json"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
cloud2 "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
)
func NamespaceCreateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req cloud2.CreateNamespaceParam
body, err := io.ReadAll(r.Body)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err = json.Unmarshal(body, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := cloud.NewNamespaceCreateLogic(r.Context(), svcCtx)
resp, err := l.NamespaceCreate(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -1,24 +1,25 @@
package core
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"net/http"
)
func CommitTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func EditAchievementHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CommitTaskReq
var req types.EditAchievementReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := core.NewCommitTaskLogic(r.Context(), svcCtx)
err := l.CommitTask(&req)
result.HttpResult(r, w, nil, err)
l := core.NewEditAchievementLogic(r.Context(), svcCtx)
resp, err := l.EditAchievement(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,25 @@
package core
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
)
func ListAchievementHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ListAchievementReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := core.NewListAchievementLogic(r.Context(), svcCtx)
resp, err := l.ListAchievement(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,34 @@
package core
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
)
func PublishAchievementHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.PublishAchievementReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
// 获取token信息
token := r.Header.Get("Authorization")
jccUserInfo, err := utils.ParseTokenWithoutVerify(token)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
req.UserId = jccUserInfo.Id
req.UserName = jccUserInfo.UserName
l := core.NewPublishAchievementLogic(r.Context(), svcCtx)
resp, err := l.PublishAchievement(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,25 @@
package core
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
)
func QueryAchievementHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.QueryAchievementReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := core.NewQueryAchievementLogic(r.Context(), svcCtx)
resp, err := l.QueryAchievement(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,25 @@
package core
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
)
func RevokeAchievementHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.RevokeAchievementReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := core.NewRevokeAchievementLogic(r.Context(), svcCtx)
resp, err := l.RevokeAchievement(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,25 @@
package core
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
)
func TypeClusterResourceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.TypeResourceSpecReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := core.NewTypeClusterResourceLogic(r.Context(), svcCtx)
resp, err := l.TypeClusterResource(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -20,6 +20,9 @@ func CommitHpcTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
result.ParamErrorResult(r, w, err)
return
}
if req.Parameters == nil {
req.Parameters = make(map[string]string)
}
// 获取ip信息
ip := utils.GetClientIP(r)
req.Parameters["UserIp"] = ip
@ -34,6 +37,8 @@ func CommitHpcTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
req.Parameters[constants.UserId] = strconv.FormatInt(jccUserInfo.Id, 10)
req.Parameters[constants.UserName] = jccUserInfo.UserName
jcsUserID := r.Header.Get("JCS-UserID")
req.JcsUserID = jcsUserID
l := hpc.NewCommitHpcTaskLogic(r.Context(), svcCtx)
resp, err := l.CommitHpcTask(&req)

View File

@ -0,0 +1,24 @@
package inference
import (
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"net/http"
)
func InferenceTaskLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.InferenceTaskLogReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := inference.NewInferenceTaskLogLogic(r.Context(), svcCtx)
resp, err := l.InferenceTaskLog(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -26,6 +26,7 @@ func CreateInferenceTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
req.UserId = jccUserInfo.Id
req.Token = token
l := inference.NewCreateInferenceTaskLogic(r.Context(), svcCtx)
resp, err := l.CreateInferenceTask(&req)
result.HttpResult(r, w, resp, err)

View File

@ -2,6 +2,7 @@ package inference
import (
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
@ -18,8 +19,14 @@ func DeployInstanceStatHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
token := r.Header.Get("Authorization")
jccUserInfo, err := utils.ParseTokenWithoutVerify(token)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := inference.NewDeployInstanceStatLogic(r.Context(), svcCtx)
resp, err := l.DeployInstanceStat(&req)
resp, err := l.DeployInstanceStat(&req, jccUserInfo.UserName, jccUserInfo.Id)
result.HttpResult(r, w, resp, err)
}

View File

@ -6,6 +6,7 @@ import (
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
"net/http"
)
@ -17,8 +18,14 @@ func InferenceTaskStatHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
token := r.Header.Get("Authorization")
jccUserInfo, err := utils.ParseTokenWithoutVerify(token)
if err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := inference.NewInferenceTaskStatLogic(r.Context(), svcCtx)
resp, err := l.InferenceTaskStat(&req)
resp, err := l.InferenceTaskStat(&req, jccUserInfo.UserName, jccUserInfo.Id)
result.HttpResult(r, w, resp, err)
}

View File

@ -13,7 +13,6 @@ import (
inference "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/inference"
monitoring "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/monitoring"
schedule "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/schedule"
storage "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/storage"
storelink "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/storelink"
vm "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/vm"
xjlab "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/xjlab"
@ -99,6 +98,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
rest.WithPrefix("/pcm/v1"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodGet,
Path: "/participant/cluster/bootstrap",
Handler: adapters.ClusterBootstrapHandler(serverCtx),
},
},
rest.WithPrefix("/internal/v1"),
)
server.AddRoutes(
[]rest.Route{
{
@ -221,6 +231,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/ai/chat",
Handler: ai.ChatHandler(serverCtx),
},
{
// 训练任务详情
Method: http.MethodGet,
Path: "/ai/task/details",
Handler: ai.TrainingTaskDetailsHandler(serverCtx),
},
{
// 创建数据集
Method: http.MethodPost,
@ -336,12 +352,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/cloud/model/bind",
Handler: cloud.BindModelHandler(serverCtx),
},
{
// yaml删除
Method: http.MethodGet,
Path: "/cloud/DeleteYaml",
Handler: cloud.DeleteYamlHandler(serverCtx),
},
{
// 控制器监控
Method: http.MethodGet,
@ -354,11 +365,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/cloud/deleteCluster",
Handler: cloud.DeleteClusterHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/cloud/pod/logs",
Handler: cloud.PodLogsHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/cloud/pods/list",
@ -397,7 +404,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
{
// 删除容器
Method: http.MethodDelete,
Path: "/cloud/container/delete",
Path: "/cloud/container/delete/:id",
Handler: cloud.ContainerDeleteHandler(serverCtx),
},
{
@ -409,9 +416,63 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
{
// 获取容器
Method: http.MethodGet,
Path: "/cloud/container/log",
Path: "/cloud/container/images",
Handler: cloud.ContainerImagesHandler(serverCtx),
},
{
// 获取容器日志
Method: http.MethodGet,
Path: "/cloud/container/log/:id",
Handler: cloud.ContainerLogHandler(serverCtx),
},
{
// 获取容器监控数据
Method: http.MethodGet,
Path: "/cloud/container/metrics/:id",
Handler: cloud.ContainerMetricsHandler(serverCtx),
},
{
// 创建命名空间
Method: http.MethodPost,
Path: "/cloud/namespace/create",
Handler: cloud.NamespaceCreateHandler(serverCtx),
},
{
// 查询实例
Method: http.MethodGet,
Path: "/cloud/instance/types",
Handler: cloud.InstanceTypesHandler(serverCtx),
},
{
// 查询实例
Method: http.MethodGet,
Path: "/cloud/instance/images",
Handler: cloud.InstanceImagesHandler(serverCtx),
},
{
// 查询实例
Method: http.MethodGet,
Path: "/cloud/instance/get/:instanceId",
Handler: cloud.InstanceInfoHandler(serverCtx),
},
{
// 创建实例
Method: http.MethodPost,
Path: "/cloud/instance/create",
Handler: cloud.InstanceCreateHandler(serverCtx),
},
{
// 分页查询实例列表
Method: http.MethodGet,
Path: "/cloud/instance/page",
Handler: cloud.InstanceListHandler(serverCtx),
},
{
// 删除容器
Method: http.MethodPut,
Path: "/cloud/instance/operate",
Handler: cloud.InstanceOperateHandler(serverCtx),
},
},
rest.WithPrefix("/pcm/v1"),
)
@ -466,6 +527,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/core/ai/resourceSpec/sync",
Handler: core.SyncResourceSpecHandler(serverCtx),
},
{
// 获取通过type过滤资源规格获取对应集群
Method: http.MethodGet,
Path: "/core/resourceSpec/typeCluster",
Handler: core.TypeClusterResourceHandler(serverCtx),
},
{
// 获取节点资产
Method: http.MethodGet,
@ -484,12 +551,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/core/centerResources",
Handler: core.CenterResourcesHandler(serverCtx),
},
{
// 提交任务
Method: http.MethodPost,
Path: "/core/commitTask",
Handler: core.CommitTaskHandler(serverCtx),
},
{
// 提交虚拟机任务
Method: http.MethodPost,
@ -694,6 +755,36 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/core/taskList",
Handler: core.TaskListHandler(serverCtx),
},
{
// 成果发布
Method: http.MethodPost,
Path: "/core/publishAchievement",
Handler: core.PublishAchievementHandler(serverCtx),
},
{
// 成果查看
Method: http.MethodGet,
Path: "/core/queryAchievement/:taskId",
Handler: core.QueryAchievementHandler(serverCtx),
},
{
// 成果编辑
Method: http.MethodPut,
Path: "/core/editAchievement",
Handler: core.EditAchievementHandler(serverCtx),
},
{
// 成果撤销
Method: http.MethodPut,
Path: "/core/revokeAchievement/:taskId",
Handler: core.RevokeAchievementHandler(serverCtx),
},
{
// 成果查看
Method: http.MethodGet,
Path: "/core/listAchievement",
Handler: core.ListAchievementHandler(serverCtx),
},
},
rest.WithPrefix("/pcm/v1"),
)
@ -928,6 +1019,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/inference/text",
Handler: inference.TextToTextInferenceHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/inference/taskLog/:taskId",
Handler: inference.InferenceTaskLogHandler(serverCtx),
},
},
rest.WithPrefix("/pcm/v1"),
)
@ -1079,24 +1175,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
rest.WithPrefix("/pcm/v1"),
)
server.AddRoutes(
[]rest.Route{
{
// 日常算力查询
Method: http.MethodGet,
Path: "/storage/dailyPowerScreen",
Handler: storage.DailyPowerScreenHandler(serverCtx),
},
{
// 算力中心算力情况
Method: http.MethodGet,
Path: "/storage/perCenterComputerPowers",
Handler: storage.PerCenterComputerPowersHandler(serverCtx),
},
},
rest.WithPrefix("/pcm/v1"),
)
server.AddRoutes(
[]rest.Route{
{
@ -1752,11 +1830,53 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Handler: xjlab.TaskResourceUsageHandler(serverCtx),
},
{
//任务状态监控
//任务状态统计
Method: http.MethodGet,
Path: "/xjlab/taskStatusStatistics",
Handler: xjlab.TaskStatusStatisticsHandler(serverCtx),
},
{
//单任务失败分析
Method: http.MethodGet,
Path: "/xjlab/task/failureAnalyze",
Handler: xjlab.TaskFailureAnalyzeHandler(serverCtx),
},
{
//大屏-融合资源占比-计算类型占比
Method: http.MethodGet,
Path: "/xjlab/overview/computeTypeRatio",
Handler: xjlab.ComputeTypeRatioHandler(serverCtx),
},
{
//大屏-超算应用执行情况
Method: http.MethodGet,
Path: "/xjlab/overview/countHpcAppExec",
Handler: xjlab.CountHpcAppExecHandler(serverCtx),
},
{
//大屏-统计任务执行状态
Method: http.MethodGet,
Path: "/xjlab/overview/countTaskStatus",
Handler: xjlab.CountTaskStatusHandler(serverCtx),
},
{
//大屏-任务执行列表
Method: http.MethodGet,
Path: "/xjlab/overview/listTask",
Handler: xjlab.ListTaskHandler(serverCtx),
},
{
//大屏-计算域信息
Method: http.MethodGet,
Path: "/xjlab/overview/computeDomainInfo",
Handler: xjlab.ComputeDomainInfoHandler(serverCtx),
},
{
//大屏-算力清单
Method: http.MethodGet,
Path: "/xjlab/overview/computerPowerList",
Handler: xjlab.ComputerPowerListHandler(serverCtx),
},
},
rest.WithPrefix("/pcm/v1"),
)

View File

@ -1,17 +0,0 @@
package storage
import (
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storage"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
)
func DailyPowerScreenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := storage.NewDailyPowerScreenLogic(r.Context(), svcCtx)
resp, err := l.DailyPowerScreen()
result.HttpResult(r, w, resp, err)
}
}

View File

@ -1,17 +0,0 @@
package storage
import (
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storage"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
)
func PerCenterComputerPowersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := storage.NewPerCenterComputerPowersLogic(r.Context(), svcCtx)
resp, err := l.PerCenterComputerPowers()
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,95 @@
package xjlab
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/xjlab"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
)
func ComputeTypeRatioHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.XJLABCommonReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := xjlab.NewComputeTypeRatioLogic(r.Context(), ctx)
resp, err := l.ComputeTypeRatio(&req)
result.HttpResult(r, w, resp, err)
}
}
func CountHpcAppExecHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.XJLABCommonReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := xjlab.NewCountHpcAppExecLogic(r.Context(), ctx)
resp, err := l.CountHpcAppExec(&req)
result.HttpResult(r, w, resp, err)
}
}
func CountTaskStatusHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.XJLABCommonReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := xjlab.NewCountTaskStatusLogic(r.Context(), ctx)
resp, err := l.CountTaskStatus(&req)
result.HttpResult(r, w, resp, err)
}
}
func ListTaskHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.XJLABCommonReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := xjlab.NewListTaskLogic(r.Context(), ctx)
resp, err := l.ListTask(&req)
result.HttpResult(r, w, resp, err)
}
}
func ComputeDomainInfoHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.XJLABCommonReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := xjlab.NewComputeDomainInfoLogic(r.Context(), ctx)
resp, err := l.ComputeDomainInfo(&req)
result.HttpResult(r, w, resp, err)
}
}
func ComputerPowerListHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.XJLABCommonReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := xjlab.NewComputerPowerListLogic(r.Context(), ctx)
resp, err := l.ComputerPowerList(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -62,3 +62,17 @@ func TaskStatusStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
result.HttpResult(r, w, resp, err)
}
}
func TaskFailureAnalyzeHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.FId
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := xjlab.NewTaskFailureAnalyzeLogic(r.Context(), ctx)
resp, err := l.TaskFailureAnalyze(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,50 @@
package adapters
import (
"context"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type ClusterBootstrapLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewClusterBootstrapLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClusterBootstrapLogic {
return &ClusterBootstrapLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ClusterBootstrapLogic) ClusterBootstrap(req *types.ClusterBootstrapReq) (resp *types.PageResult, err error) {
resp = &types.PageResult{}
list := make([]types.ClusterInfo, 0)
db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_cluster").
Joins("left join t_adapter on t_adapter.id = t_cluster.adapter_id").
Where("t_cluster.deleted_at is null")
if req.AdapterId != "" {
db = db.Where("t_cluster.adapter_id = ?", req.AdapterId)
}
if req.Type != "" {
db = db.Where("t_adapter.type = ?", req.Type)
}
if err = db.Select("t_cluster.*").Order("t_cluster.create_time desc").Scan(&list).Error; err != nil {
return nil, err
}
resp.List = list
resp.Total = int64(len(list))
resp.PageNum = 1
resp.PageSize = len(list)
return resp, nil
}

View File

@ -2,6 +2,7 @@ package adapters
import (
"context"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/security"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
@ -74,6 +75,7 @@ func (l *ClusterListLogic) ClusterList(req *types.ClusterReq) (resp *types.PageR
if err != nil {
return resp, err
}
security.SanitizeClusterSecretList(list)
resp.List = list
resp.PageSize = req.PageSize
resp.PageNum = req.PageNum

View File

@ -125,8 +125,6 @@ func GeoMap(address string) (string, error) {
if err2 != nil {
fmt.Printf("response error: %v", err2)
}
fmt.Println(string(body))
geoResponse := GeoResponse{}
json.Unmarshal(body, &geoResponse)
return geoResponse.Geocodes[0].Location, err

View File

@ -2,6 +2,9 @@ package adapters
import (
"context"
"strconv"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/security"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
@ -58,7 +61,7 @@ func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterRelationQ
cr = &types.ClusterRelationInfo{}
utils.Convert(&v, &cr)
cr.CId = c.Id
cr.CAdapterId = string(c.AdapterId)
cr.CAdapterId = strconv.FormatInt(c.AdapterId, 10)
cr.CName = c.Name
cr.CNickname = c.Nickname
cr.CDescription = c.Description
@ -78,9 +81,11 @@ func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterRelationQ
cr.CRegionDict = c.RegionDict
cr.CProducerDict = c.ProducerDict
cr.CCreateTime = c.CreateTime
security.SanitizeClusterRelationSecret(cr)
rlist = append(rlist, cr)
}
if len(clusters) == 0 {
security.SanitizeClusterRelationSecret(cr)
rlist = append(rlist, cr)
}
}

View File

@ -32,6 +32,9 @@ func (l *GetClusterBaseInfoLogic) GetClusterBaseInfo(req *types.ClusterReq) (res
db = db.Joins("left join t_adapter on t_adapter.id = t_cluster.adapter_id").
Where("t_cluster.deleted_at is null")
if req.Id != "" {
db = db.Where("t_cluster.id = ?", req.Id)
}
if req.Name != "" {
db = db.Where("t_cluster.name LIKE ?", "%"+req.Name+"%")
}

View File

@ -3,6 +3,7 @@ package adapters
import (
"context"
"github.com/pkg/errors"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/security"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
@ -31,6 +32,7 @@ func (l *GetClusterLogic) GetCluster(req *types.FId) (resp *types.ClusterInfo, e
logx.Errorf("err %v", db.Error.Error())
return nil, errors.New("Adapter does not exist")
}
security.SanitizeClusterSecret(resp)
return
}

View File

@ -39,13 +39,25 @@ func NewCreateAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
}
func (l *CreateAlgorithmLogic) CreateAlgorithm(req *algorithm.CreateAlgorithmReq) (resp interface{}, err error) {
cinfo, err := l.svcCtx.Scheduler.AiStorages.GetClusterByIdAndAdapterId(req.ClusterId, l.svcCtx.Config.Participant.AdapterId)
if err != nil {
return nil, err
}
algorithmParam, err := l.svcCtx.Scheduler.AiService.Cvt.ConvertToCreateAlgorithmParam(req.Param, cinfo.Driver)
if err != nil {
return nil, err
}
param := &participant.CreateParam{
Name: req.Name,
Desc: req.Desc,
CType: cinfo.Driver,
Src: req.Src,
Param: req.Param,
Param: algorithmParam,
}
create, err := l.svcCtx.Ai.AlgorithmCreateById(req.ClusterId, param)
create, err := l.svcCtx.Scheduler.AiService.Ai.AlgorithmCreateById(req.Token, req.ClusterId, param)
if err != nil {
return nil, err
}

View File

@ -39,13 +39,24 @@ func NewCreateDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre
}
func (l *CreateDataSetLogic) CreateDataSet(req *dataset.CreateDatasetReq) (resp interface{}, err error) {
cinfo, err := l.svcCtx.Scheduler.AiStorages.GetClusterByIdAndAdapterId(req.ClusterId, l.svcCtx.Config.Participant.AdapterId)
if err != nil {
return nil, err
}
dtsParam, err := l.svcCtx.Scheduler.AiService.Cvt.ConvertToCreateDatasetParam(req.Param, cinfo.Driver)
if err != nil {
return nil, err
}
param := &participant.CreateParam{
Name: req.Name,
Desc: req.Desc,
CType: cinfo.Driver,
Src: req.Src,
Param: req.Param,
Param: dtsParam,
}
create, err := l.svcCtx.Ai.DatasetCreateById(req.ClusterId, param)
create, err := l.svcCtx.Scheduler.AiService.Ai.DatasetCreateById(req.ClusterId, param)
if err != nil {
return nil, err
}

View File

@ -39,13 +39,24 @@ func NewCreateModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Creat
}
func (l *CreateModelLogic) CreateModel(req *model.CreateModelReq) (resp interface{}, err error) {
cinfo, err := l.svcCtx.Scheduler.AiStorages.GetClusterByIdAndAdapterId(req.ClusterId, l.svcCtx.Config.Participant.AdapterId)
if err != nil {
return nil, err
}
modelParam, err := l.svcCtx.Scheduler.AiService.Cvt.ConvertToCreateModelParam(req.Param, cinfo.Driver)
if err != nil {
return nil, err
}
param := &participant.CreateParam{
Name: req.Name,
Desc: req.Desc,
CType: cinfo.Driver,
Src: req.Src,
Param: req.Param,
Param: modelParam,
}
create, err := l.svcCtx.Ai.ModelCreateById(req.ClusterId, param)
create, err := l.svcCtx.Scheduler.AiService.Ai.ModelCreateById(req.ClusterId, param)
if err != nil {
return nil, err
}

View File

@ -37,7 +37,7 @@ func NewListAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Li
}
func (l *ListAlgorithmsLogic) ListAlgorithms(req *types.ListAlgorithmsReq) (resp interface{}, err error) {
list, err := l.svcCtx.Ai.AlgorithmById(req.ProjectId)
list, err := l.svcCtx.Scheduler.AiService.Ai.AlgorithmById(req.ProjectId)
if err != nil {
return nil, err
}

View File

@ -39,12 +39,16 @@ func NewTaskResultSyncLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ta
}
func (l *TaskResultSyncLogic) TaskResultSync(req *sync.ResultSyncReq) (resp interface{}, err error) {
cinfo, err := l.svcCtx.Scheduler.AiStorages.GetClusterByIdAndAdapterId(req.ClusterId, l.svcCtx.Config.Participant.AdapterId)
if err != nil {
return nil, err
}
param := &participant.TaskResultSyncParam{
CType: cinfo.Driver,
Src: req.Src,
Param: req.Param,
}
rs, err := l.svcCtx.Ai.TaskResultSync(req.ClusterId, param)
rs, err := l.svcCtx.Scheduler.AiService.Ai.TaskResultSync(req.Token, req.ClusterId, param)
if err != nil {
return nil, err
}

View File

@ -0,0 +1,72 @@
package ai
import (
"context"
"github.com/pkg/errors"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
"gorm.io/gorm"
"strings"
"github.com/zeromicro/go-zero/core/logx"
)
type TrainingTaskDetailsLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewTrainingTaskDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TrainingTaskDetailsLogic {
return &TrainingTaskDetailsLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *TrainingTaskDetailsLogic) TaskDetails(req *types.TaskDetailReq) (resp *types.TaskDetailsResp, err error) {
resp = &types.TaskDetailsResp{}
task := &models.Task{}
if errors.Is(l.svcCtx.DbEngin.Where("id", req.TaskId).First(&task).Error, gorm.ErrRecordNotFound) {
return nil, errors.New("记录不存在")
}
clusterIds := make([]string, 0)
var cList []*types.ClusterInfo
var subList []*types.SubTaskInfo
switch task.AdapterTypeDict {
case "0":
l.svcCtx.DbEngin.Table("task_cloud").Where("task_id", task.Id).Scan(&subList)
if len(subList) <= 0 {
l.svcCtx.DbEngin.Table("task_vm").Where("task_id", task.Id).Find(&subList)
}
case "1":
l.svcCtx.DbEngin.Table("task_ai").Where("task_id", task.Id).Scan(&subList)
if len(subList) <= 0 {
l.svcCtx.DbEngin.Table("task_ai_asynchronous").Where("task_id", task.Id).Scan(&subList)
}
case "2":
l.svcCtx.DbEngin.Table("task_hpc").Where("task_id", task.Id).Scan(&subList)
for _, hpc := range subList {
var cluster types.ClusterInfo
tx := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", hpc.ClusterId).Scan(&cluster)
if tx.Error != nil {
}
hpc.WorkDir = strings.TrimPrefix(hpc.WorkDir, cluster.WorkDir)
}
}
for _, sub := range subList {
clusterIds = append(clusterIds, sub.ClusterId)
}
err = l.svcCtx.DbEngin.Table("t_cluster").Select("id,adapter_id,name,nickname,description,create_time").Where("storage_schedule = 1 and id in ?", clusterIds).Scan(&cList).Error
if err != nil {
return resp, err
}
utils.Convert(&task, &resp)
resp.ClusterInfos = cList
resp.SubTaskInfos = subList
return
}

View File

@ -22,20 +22,34 @@ func NewTrainingTaskStatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
}
}
func (l *TrainingTaskStatLogic) TrainingTaskStat() (resp *types.TrainingTaskStatResp, err error) {
func (l *TrainingTaskStatLogic) TrainingTaskStat(userName string, userId int64) (resp *types.TrainingTaskStatResp, err error) {
resp = &types.TrainingTaskStatResp{}
total, err := l.svcCtx.Scheduler.AiStorages.GetTrainingTaskTotalNum()
if err != nil {
return nil, err
if userName != "" && userName != "admin" {
total, err := l.svcCtx.Scheduler.AiStorages.GetTrainingTaskTotalNumByUserId(userId)
if err != nil {
return nil, err
}
running, err := l.svcCtx.Scheduler.AiStorages.GetTrainingTaskRunningNumByUserId(userId)
if err != nil {
return nil, err
}
resp.Total = total
resp.Running = running
} else {
total, err := l.svcCtx.Scheduler.AiStorages.GetTrainingTaskTotalNum()
if err != nil {
return nil, err
}
running, err := l.svcCtx.Scheduler.AiStorages.GetTrainingTaskRunningNum()
if err != nil {
return nil, err
}
resp.Total = total
resp.Running = running
}
running, err := l.svcCtx.Scheduler.AiStorages.GetTrainingTaskRunningNum()
if err != nil {
return nil, err
}
resp.Total = total
resp.Running = running
return resp, nil
}

View File

@ -47,32 +47,67 @@ func NewContainerCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
}
func (l *ContainerCreateLogic) ContainerCreate(req *container.CreateParam) (resp *ContainerCreateRespStruct, err error) {
resp = &ContainerCreateRespStruct{}
// 构建云适配器的创建参数(使用结构体字面量直接映射)
param := &cloud.CreateParam{
Name: req.Name,
Description: req.Description,
Capacity: req.Capacity,
UserId: strconv.FormatInt(req.UserId, 10),
Image: req.Image,
Cpu: req.Cpu,
Memory: req.Memory,
Port: req.Port,
NodePort: req.NodePort,
MountPath: req.MountPath,
Args: req.Args,
Command: req.Command,
Envs: req.Envs,
Replica: req.Replica,
ImagePullSecrets: req.ImagePullSecrets,
ImageRegistry: req.ImageRegistry,
ImageUsername: req.ImageUsername,
ImagePassword: req.ImagePassword,
Port: req.Port,
Cpu: req.Cpu,
Memory: req.Memory,
Image: req.Image,
Args: req.Args,
MountPath: req.MountPath,
Envs: req.Envs,
NodePort: req.NodePort,
ContainerGroupName: req.ContainerGroupName,
CreateParameter: req.ContainerCreateParameter,
FileParams: req.FileParams,
BillingType: req.BillingType,
Region: req.Region,
PayPeriod: req.PayPeriod,
ServiceModel: req.ServiceModel,
}
create, err := l.svcCtx.Cloud.ContainerCreate(req.ClusterId, param)
gen := utils.NewRandomStringGenerator("0123456789abcdefghijklmnopqrstuvwxyz")
param.ContainerGroupName = gen.Generate(15)
// 调用云适配器创建容器
createResp, err := l.svcCtx.Cloud.ContainerCreate(req.ClusterId, param)
if err != nil {
l.Logger.Errorf("调用p端创建容器失败clusterId: %s, name: %s, err: %v", req.ClusterId, req.Name, err)
return nil, err
}
if create.Code != http.StatusOK {
return nil, errors.New(create.Message)
if createResp.Code != http.StatusOK {
l.Logger.Errorf("p端返回错误clusterId: %s, name: %s, message: %s", req.ClusterId, req.Name, createResp.Message)
return nil, errors.New(createResp.Message)
}
// 查询集群信息
type ClusterInfo struct {
Name string `json:"name"`
AdapterId int64 `json:"adapter_id"`
}
var clusterInfo ClusterInfo
err = l.svcCtx.DbEngin.Table("t_cluster").Select("adapter_id,name").Where("id=?", req.ClusterId).First(&clusterInfo).Error
if err != nil {
l.Logger.Errorf("查询集群信息失败clusterId: %s, err: %v", req.ClusterId, err)
return nil, errors.New("查询集群信息失败")
}
// 开启事务
tx := l.svcCtx.DbEngin.Begin()
defer func() {
if r := recover(); r != nil {
tx.Rollback()
}
}()
// 构建主任务结构体
taskModel := models.Task{
Id: utils.GenSnowflakeID(),
@ -83,36 +118,57 @@ func (l *ContainerCreateLogic) ContainerCreate(req *container.CreateParam) (resp
UserName: req.UserName,
AdapterTypeDict: "0",
CommitTime: time.Now(),
TaskTypeDict: "container",
}
// 保存任务数据到数据库
tx := l.svcCtx.DbEngin.Create(&taskModel)
if tx.Error != nil {
// 保存主任务数据到数据库
if err = tx.Create(&taskModel).Error; err != nil {
tx.Rollback()
l.Logger.Errorf("保存主任务失败name: %s, err: %v", req.Name, err)
return nil, errors.New("保存主任务失败")
}
var adapterId int64
tx.Table("t_cluster").Select("adapter_id").Where("id=?", req.ClusterId).Find(&adapterId)
// 构建cloud任务结构体
// 构建 cloud 任务结构体
cloudTaskModel := cloud2.TaskCloudModel{
Id: utils.GenSnowflakeID(),
TaskId: taskModel.Id,
Name: req.Name,
AdapterId: adapterId,
Status: constants.Saved,
Namespace: "default",
UserId: req.UserId,
ClusterId: req.ClusterId,
Id: utils.GenSnowflakeID(),
TaskId: taskModel.Id,
Name: req.Name,
AdapterId: clusterInfo.AdapterId,
Status: constants.Saved,
Namespace: "default",
UserId: req.UserId,
ClusterId: req.ClusterId,
ClusterName: clusterInfo.Name,
ResourceSpec: cloud2.ResourceSpec{
CPU: req.Cpu,
Memory: req.Memory,
ResourceName: fmt.Sprintf("%s_cpu %s_mem %s", clusterInfo.Name, req.Cpu, req.Memory),
ResourceType: constants.TaskTypeCloud,
Specifications: map[string]interface{}{
"CPU": req.Cpu,
"Memory": req.Memory,
},
},
}
// 保存任务数据到数据库
tx = l.svcCtx.DbEngin.Create(&cloudTaskModel)
if tx.Error != nil {
fmt.Println()
return nil, tx.Error
if createResp.Data != nil {
cloudTaskModel.BusinessCode = fmt.Sprintf("%v", createResp.Data)
}
// 保存 cloud 任务数据到数据库
if err = tx.Create(&cloudTaskModel).Error; err != nil {
tx.Rollback()
l.Logger.Errorf("保存 cloud 任务失败name: %s, err: %v", req.Name, err)
return nil, errors.New("保存 cloud 任务失败")
}
// 提交事务
if err = tx.Commit().Error; err != nil {
l.Logger.Errorf("提交事务失败err: %v", err)
return nil, errors.New("提交事务失败")
}
l.Logger.Infof("创建容器成功taskId: %d, clusterId: %s, name: %s", taskModel.Id, req.ClusterId, req.Name)
resp = &ContainerCreateRespStruct{
TaskId: strconv.FormatInt(taskModel.Id, 10),
}
resp.TaskId = strconv.FormatInt(taskModel.Id, 10)
return resp, nil
}

View File

@ -17,11 +17,14 @@ package cloud
import (
"context"
"errors"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/participant/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"net/http"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
)
type ContainerDeleteLogic struct {
@ -39,16 +42,75 @@ func NewContainerDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
}
func (l *ContainerDeleteLogic) ContainerDelete(req *container.DeleteParam) (resp interface{}, err error) {
param := &cloud.DeleteParam{
Name: req.Name,
// 查询任务信息
task := &types.TaskModel{}
err = l.svcCtx.DbEngin.Table("task").Where("id", req.Id).First(task).Error
if err != nil || task.Id == 0 {
l.Logger.Errorf("任务不存在id: %d, err: %v", req.Id, err)
return nil, errors.New("任务不存在")
}
create, err := l.svcCtx.Cloud.ContainerDelete(req.ClusterId, param)
// 查询通算任务信息
taskCloud := &models.TaskCloud{}
err = l.svcCtx.DbEngin.Table("task_cloud").Where("task_id", req.Id).First(taskCloud).Error
if err != nil || taskCloud.Id == 0 {
l.Logger.Errorf("通算任务不存在taskId: %d, err: %v", req.Id, err)
return nil, errors.New("通算任务不存在")
}
// 设置删除请求参数
clusterId := strconv.FormatInt(taskCloud.ClusterId, 10)
deleteReq := &container.DeleteParam{
Id: req.Id,
ClusterId: clusterId,
}
if taskCloud.BusinessCode != "" && taskCloud.BusinessCode != "null" {
deleteReq.Name = taskCloud.BusinessCode
} else {
deleteReq.Name = taskCloud.Name
}
// 调用底层删除接口
create, err := l.svcCtx.Cloud.ContainerDelete(clusterId, deleteReq)
if err != nil {
l.Logger.Errorf("删除容器失败clusterId: %s, name: %s, err: %v", clusterId, deleteReq.Name, err)
return nil, err
}
if create.Code != http.StatusOK {
l.Logger.Errorf("删除容器返回错误clusterId: %s, name: %s, message: %s", clusterId, deleteReq.Name, create.Message)
return nil, errors.New(create.Message)
}
resp = create.Data
// 开启事务更新状态
tx := l.svcCtx.DbEngin.Begin()
defer func() {
if r := recover(); r != nil {
tx.Rollback()
}
}()
// 更新 task_cloud 状态
err = tx.Model(&models.TaskCloud{}).Where("id", taskCloud.Id).Update("status", "Deleted").Error
if err != nil {
tx.Rollback()
l.Logger.Errorf("更新 task_cloud 状态失败id: %d, err: %v", taskCloud.Id, err)
return nil, errors.New("更新任务状态失败")
}
// 更新 task 状态
err = tx.Model(&types.Task{}).Where("id", req.Id).Update("status", "Deleted").Error
if err != nil {
tx.Rollback()
l.Logger.Errorf("更新 task 状态失败id: %d, err: %v", req.Id, err)
return nil, errors.New("更新任务状态失败")
}
// 提交事务
if err = tx.Commit().Error; err != nil {
l.Logger.Errorf("提交事务失败err: %v", err)
return nil, errors.New("提交事务失败")
}
l.Logger.Infof("删除容器成功taskId: %d, clusterId: %s, name: %s", req.Id, clusterId, deleteReq.Name)
return
}

View File

@ -0,0 +1,57 @@
/*
Copyright (c) [2023] [pcm]
[pcm-coordinator] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
package cloud
import (
"context"
"errors"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/participant/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
)
type ContainerImagesLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewContainerImagesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ContainerImagesLogic {
return &ContainerImagesLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ContainerImagesLogic) ContainerImages(req *container.ImagesParam) (resp interface{}, err error) {
param := &cloud.ImagesParam{
Region: req.Region,
PageNum: req.PageNum,
PageSize: req.PageSize,
}
get, err := l.svcCtx.Cloud.ContainerImages(req.ClusterId, param)
if err != nil {
return nil, err
}
if get.Code != http.StatusOK {
return nil, errors.New(get.Message)
}
resp = get.Data
return
}

View File

@ -17,10 +17,14 @@ package cloud
import (
"context"
"errors"
"net/http"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"net/http"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
)
type ContainerLogLogic struct {
@ -38,10 +42,19 @@ func NewContainerLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cont
}
func (l *ContainerGetLogic) ContainerLog(req *container.LogParam) (resp interface{}, err error) {
param := &container.LogParam{
Name: req.Name,
task := &types.TaskModel{}
l.svcCtx.DbEngin.Table("task").Where("id", req.Id).Scan(&task)
if task.Name == "" {
return nil, errors.New("任务不存在")
}
get, err := l.svcCtx.Cloud.ContainerLog(req.ClusterId, param)
taskCloud := models.TaskCloud{}
l.svcCtx.DbEngin.Table("task_cloud").Where("task_id", req.Id).Scan(&taskCloud)
if taskCloud.Name == "" {
return nil, errors.New("通算任务不存在")
}
req.Name = taskCloud.BusinessCode
req.ClusterId = strconv.FormatInt(taskCloud.ClusterId, 10)
get, err := l.svcCtx.Cloud.ContainerLog(req.ClusterId, req)
if err != nil {
return nil, err
}
@ -49,5 +62,6 @@ func (l *ContainerGetLogic) ContainerLog(req *container.LogParam) (resp interfac
return nil, errors.New(get.Message)
}
resp = get.Data
return
return resp, nil
}

View File

@ -0,0 +1,78 @@
/*
Copyright (c) [2023] [pcm]
[pcm-coordinator] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
package cloud
import (
"context"
"errors"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/participant/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strconv"
)
type ContainerMetricsLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewContainerMetricsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ContainerMetricsLogic {
return &ContainerMetricsLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ContainerMetricsLogic) ContainerMetrics(req *container.MetricsParam) (resp interface{}, err error) {
task := &types.TaskModel{}
l.svcCtx.DbEngin.Table("task").Where("id", req.Id).Scan(&task)
if task.Name == "" {
return nil, errors.New("任务不存在")
}
taskCloud := models.TaskCloud{}
l.svcCtx.DbEngin.Table("task_cloud").Where("task_id", req.Id).Scan(&taskCloud)
if taskCloud.Name == "" {
return nil, errors.New("通算任务不存在")
}
if taskCloud.BusinessCode != "" && taskCloud.BusinessCode != "null" {
var eciRequestParam cloud.EciRequestParam
err := json.Unmarshal([]byte(taskCloud.BusinessCode), &eciRequestParam)
if err != nil {
logx.Errorf("Failed to unmarshal BusinessCode: %v", err)
return nil, err
}
req.Name = eciRequestParam.ContainerGroupId
} else {
req.Name = taskCloud.Name
}
req.ClusterId = strconv.FormatInt(taskCloud.ClusterId, 10)
get, err := l.svcCtx.Cloud.ContainerMetrics(req.ClusterId, req)
if err != nil {
return nil, err
}
if get.Code != http.StatusOK {
return nil, errors.New(get.Message)
}
resp = get.Data
return resp, nil
}

View File

@ -2,6 +2,7 @@ package cloud
import (
"context"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/security"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
@ -25,5 +26,6 @@ func NewGetClusterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
func (l *GetClusterListLogic) GetClusterList(req *types.GetClusterListReq) (resp *types.GetClusterListResp, err error) {
resp = &types.GetClusterListResp{}
l.svcCtx.DbEngin.Raw("select * from t_cluster where adapter_id = ?", req.AdapterId).Scan(&resp.Clusters)
security.SanitizeClusterSecretList(resp.Clusters)
return resp, nil
}

View File

@ -12,29 +12,34 @@
*/
package mqs
package cloud
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
instance "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
)
/*
*
Listening to the payment flow status change notification message queue
*/
type HpcMq struct {
type InstanceImagesLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewHpcMq(ctx context.Context, svcCtx *svc.ServiceContext) *HpcMq {
return &HpcMq{
func NewInstanceImagesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InstanceImagesLogic {
return &InstanceImagesLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *HpcMq) Consume(val string) error {
return nil
func (l *InstanceImagesLogic) InstanceImages(req *instance.InstanceImagesParam) (resp interface{}, err error) {
resp, err = l.svcCtx.Cloud.InstanceImages(req.ClusterId, req)
if err != nil {
return nil, err
}
return resp, nil
}

View File

@ -16,29 +16,30 @@ package cloud
import (
"context"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
instance "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
)
type DeleteYamlLogic struct {
type InstanceTypesLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewDeleteYamlLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteYamlLogic {
return &DeleteYamlLogic{
func NewInstanceTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InstanceTypesLogic {
return &InstanceTypesLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *DeleteYamlLogic) DeleteYaml(req *types.ApplyReq) (resp *types.DeleteResp, err error) {
// todo: add your logic here and delete this line
func (l *InstanceTypesLogic) InstanceTypes(req *instance.InstanceTypesParam) (resp interface{}, err error) {
return
resp, err = l.svcCtx.Cloud.InstanceTypes(req.ClusterId, req)
if err != nil {
return nil, err
}
return resp, nil
}

View File

@ -0,0 +1,139 @@
/*
Copyright (c) [2023] [pcm]
[pcm-coordinator] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
package cloud
import (
"context"
"errors"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
"strconv"
"time"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
)
type InstanceCreateLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewInstanceCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InstanceCreateLogic {
return &InstanceCreateLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *InstanceCreateLogic) InstanceCreate(req *container.CreateInstanceParam) (resp *ContainerCreateRespStruct, err error) {
resp = &ContainerCreateRespStruct{}
param := &container.CreateInstanceParam{
ClusterId: req.ClusterId,
ImageId: req.ImageId,
InstanceType: req.InstanceType,
InstanceChargeType: req.InstanceChargeType,
HostName: req.HostName,
Username: req.Username,
Password: req.Password,
SecurityGroupId: req.SecurityGroupId,
SystemDiskSize: req.SystemDiskSize,
SystemDiskCategory: req.SystemDiskCategory,
SystemDiskPerformanceLevel: req.SystemDiskPerformanceLevel,
Replica: req.Replica,
}
createResp, err := l.svcCtx.Cloud.InstanceCreate(req.ClusterId, param)
if err != nil {
return nil, err
}
if createResp.Code != http.StatusOK {
return nil, errors.New(createResp.Message)
}
// 构建主任务结构体
taskModel := models.Task{
Id: utils.GenSnowflakeID(),
Status: constants.Saved,
Description: req.Description,
Name: req.HostName,
UserId: req.UserId,
UserName: req.Username,
AdapterTypeDict: "0",
CommitTime: time.Now(),
TaskTypeDict: "instance",
}
// 保存任务数据到数据库
tx := l.svcCtx.DbEngin.Create(&taskModel)
if tx.Error != nil {
return nil, err
}
type ClusterInfo struct {
Name string `json:"name"`
AdapterId int64 `json:"adapter_id"`
}
var ci ClusterInfo
tx.Table("t_cluster").Select("adapter_id,name").Where("id=?", req.ClusterId).Find(&ci)
// 构建cloud任务结构体
clusterId, err := strconv.ParseInt(req.ClusterId, 10, 64)
bytes, err := json.Marshal(createResp.Data)
if err != nil {
return nil, err
}
instanceIds := make([]string, 0)
err = json.Unmarshal(bytes, &instanceIds)
if err != nil {
return nil, err
}
if len(instanceIds) != 0 {
for _, instanceId := range instanceIds {
instance := types.VmInstance{
Id: utils.GenSnowflakeID(),
TaskId: taskModel.Id,
HostName: req.HostName,
Status: constants.Saved,
UserId: req.UserId,
ClusterId: clusterId,
InstanceType: req.InstanceType,
Password: req.Password,
ImageId: req.ImageId,
SystemDiskSize: req.SystemDiskSize,
Replica: req.Replica,
ClusterName: ci.Name,
InstanceId: instanceId,
}
// 保存任务数据到数据库
tx = l.svcCtx.DbEngin.Create(&instance)
if tx.Error != nil {
return nil, tx.Error
}
}
}
resp.TaskId = strconv.FormatInt(taskModel.Id, 10)
return resp, nil
}
type InstanceCreateRespStruct struct {
TaskId string `json:"taskId"`
}

View File

@ -0,0 +1,80 @@
/*
Copyright (c) [2023] [pcm]
[pcm-coordinator] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
package cloud
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/participant/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
instance "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"k8s.io/apimachinery/pkg/util/json"
"strconv"
)
type InstanceInfoLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewInstanceInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InstanceInfoLogic {
return &InstanceInfoLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *InstanceInfoLogic) InstanceInfo(req *instance.InstanceInfoParam) (resp *cloud.InstanceInfo, err error) {
vmInstance := &types.VmInstance{}
tx := l.svcCtx.DbEngin.Model(&types.VmInstance{}).Where("instance_id = ?", req.InstanceId).Table("vm_instance").Find(&vmInstance)
if tx.Error != nil {
return nil, tx.Error
}
// 查询公有云数据
remoteResp := &cloud.Resp{}
remoteResp, err = l.svcCtx.Cloud.InstanceInfo(strconv.FormatInt(vmInstance.ClusterId, 10), req)
bytes, err := json.Marshal(remoteResp.Data)
if err != nil {
return nil, err
}
remoteInfo := cloud.InstanceInfo{}
json.Unmarshal(bytes, &remoteInfo)
if remoteInfo.InstanceId == "" {
vmInstance.Status = "Deleted"
} else {
vmInstance.PrivateIpAddress = remoteInfo.PrivateIpAddress
vmInstance.PublicIpAddress = remoteInfo.PublicIpAddress
vmInstance.Status = remoteInfo.Status
vmInstance.OSName = remoteInfo.OSName
}
l.svcCtx.DbEngin.Updates(vmInstance)
marshal, err := json.Marshal(vmInstance)
if err != nil {
return nil, err
}
json.Unmarshal(marshal, &resp)
// 封装返回信息
resp.InternetInRate = remoteInfo.InternetInRate
resp.InternetOutRate = remoteInfo.InternetOutRate
resp.CPUUtilization = remoteInfo.CPUUtilization
resp.MemoryUtilization = remoteInfo.MemoryUtilization
resp.DiskUtilization = remoteInfo.DiskUtilization
return resp, nil
}

View File

@ -0,0 +1,69 @@
/*
Copyright (c) [2023] [pcm]
[pcm-coordinator] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
package cloud
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
instance "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
)
type InstanceListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewInstanceListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InstanceListLogic {
return &InstanceListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *InstanceListLogic) InstanceList(req *instance.PageInstanceParam) (resp *types.PageResult, err error) {
limit := req.PageSize
offset := req.PageSize * (req.PageNum - 1)
resp = &types.PageResult{}
var localList []types.VmInstance
db := l.svcCtx.DbEngin.Model(&types.VmInstance{}).Table("vm_instance")
if req.HostName != "" {
db = db.Where("host_name LIKE ?", "%"+req.HostName+"%")
}
if req.UserName != "" && req.UserName != "admin" {
db = db.Where("user_id = ?", req.UserId)
}
if req.Status != "" {
db = db.Where("status = ?", req.Status)
}
var total int64
err = db.Count(&total).Error
if err != nil {
return resp, err
}
db = db.Where("deleted_at is null").Limit(limit).Offset(offset)
err = db.Order("create_time desc").Find(&localList).Error
resp.List = localList
resp.PageSize = req.PageSize
resp.PageNum = req.PageNum
resp.Total = total
return resp, nil
}

View File

@ -0,0 +1,68 @@
/*
Copyright (c) [2023] [pcm]
[pcm-coordinator] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
package cloud
import (
"context"
"errors"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/participant/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"net/http"
"strconv"
)
type InstanceOperateLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewInstanceOperateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InstanceOperateLogic {
return &InstanceOperateLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *InstanceOperateLogic) InstanceOperate(req *container.OperateInstanceParam) (resp interface{}, err error) {
instance := types.VmInstance{}
l.svcCtx.DbEngin.Table("vm_instance").Where("instance_id", req.InstanceIds[0]).Scan(&instance)
remoteResp := &cloud.Resp{}
switch req.OperateType {
case "delete":
remoteResp, err = l.svcCtx.Cloud.InstanceDelete(strconv.FormatInt(instance.ClusterId, 10), req)
case "stop":
remoteResp, err = l.svcCtx.Cloud.InstanceStop(strconv.FormatInt(instance.ClusterId, 10), req)
case "start":
remoteResp, err = l.svcCtx.Cloud.InstanceStart(strconv.FormatInt(instance.ClusterId, 10), req)
case "reboot":
remoteResp, err = l.svcCtx.Cloud.InstanceReboot(strconv.FormatInt(instance.ClusterId, 10), req)
}
if err != nil {
return nil, err
}
if remoteResp.Code != http.StatusOK {
return nil, errors.New(remoteResp.Message)
}
if req.OperateType == "delete" {
instance.Status = "Deleted"
l.svcCtx.DbEngin.Updates(instance)
}
return
}

View File

@ -12,39 +12,37 @@
*/
package mqs
package cloud
import (
"context"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/executor"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
)
/*
*
Listening to the payment flow status change notification message queue
*/
type AiQueue struct {
type NamespaceCreateLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewAiMq(ctx context.Context, svcCtx *svc.ServiceContext) *AiQueue {
return &AiQueue{
func NewNamespaceCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NamespaceCreateLogic {
return &NamespaceCreateLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *AiQueue) Consume(val string) error {
aiSchdl, _ := schedulers.NewAiScheduler(l.ctx, val, l.svcCtx.Scheduler, nil)
// 调度算法
_, err := l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl, executor.SUBMIT_MODE_JOINT_CLOUD, nil)
func (l *NamespaceCreateLogic) NamespaceCreate(req *container.CreateNamespaceParam) (data interface{}, err error) {
param := &container.CreateNamespaceParam{
Name: req.Name,
}
ns, err := l.svcCtx.Cloud.NamespaceCreate(req.ClusterId, param)
if err != nil {
return err
return nil, err
}
return nil
return ns, nil
}

View File

@ -1,30 +0,0 @@
package cloud
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"net/http"
)
type PodLogsLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
w http.ResponseWriter
}
func NewPodLogsLogic(ctx context.Context, svcCtx *svc.ServiceContext, w http.ResponseWriter) *PodLogsLogic {
return &PodLogsLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
w: w,
}
}
func (l *PodLogsLogic) PodLogs(req *types.PodLogsReq, w http.ResponseWriter) (resp string, err error) {
// todo: add your logic here and delete this line
return
}

View File

@ -1,66 +0,0 @@
package core
import (
"context"
"github.com/ghodss/yaml"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/mqs"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/response"
"strings"
"time"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type CommitTaskLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCommitTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitTaskLogic {
return &CommitTaskLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *CommitTaskLogic) CommitTask(req *types.CommitTaskReq) error {
//req.YamlList转换为json
var yamlStr []string
for _, s := range req.YamlList {
j2, err := yaml.YAMLToJSON([]byte(s))
if err != nil {
logx.Errorf("Failed to convert yaml to JSON, err: %v", err)
return err
}
yamlStr = append(yamlStr, string(j2))
}
result := strings.Join(yamlStr, ",")
taskModel := models.Task{
Status: constants.Saved,
Name: req.Name,
CommitTime: time.Now(),
NsID: req.NsID,
YamlString: "[" + result + "]",
}
// 保存任务数据到数据库
tx := l.svcCtx.DbEngin.Create(&taskModel)
if tx.Error != nil {
return tx.Error
}
task := response.TaskInfo{
TaskId: taskModel.Id,
MatchLabels: req.MatchLabels,
NsID: req.NsID,
Metadata: req.YamlList,
Replicas: req.Replicas,
}
mqs.InsQueue.Beta.Add(&task)
return nil
}

View File

@ -0,0 +1,43 @@
package core
import (
"context"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
)
type EditAchievementLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewEditAchievementLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditAchievementLogic {
return &EditAchievementLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *EditAchievementLogic) EditAchievement(req *types.EditAchievementReq) (resp *types.TaskListResp, err error) {
id, err := strconv.ParseInt(req.Id, 10, 64)
taskId, err := strconv.ParseInt(req.TaskId, 10, 64)
achievement := models.Achievement{
Id: id,
TaskId: taskId,
Title: req.Title,
TitleImagePath: req.TitleImagePath,
Label: req.Label,
Description: req.Description,
Content: req.Content,
Status: req.Status,
}
l.svcCtx.DbEngin.Table("achievement").Updates(&achievement)
return nil, nil
}

View File

@ -3,6 +3,7 @@ package core
import (
"context"
"github.com/pkg/errors"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/security"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
@ -31,5 +32,6 @@ func (l *GetClusterByIdLogic) GetClusterById(req *types.GetClusterByIdReq) (resp
logx.Errorf(tx.Error.Error())
return nil, errors.New("cluster create failed")
}
security.SanitizeClusterSecret(&resp.ClusterInfo)
return resp, nil
}

View File

@ -0,0 +1,60 @@
package core
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
)
type ListAchievementLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewListAchievementLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAchievementLogic {
return &ListAchievementLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ListAchievementLogic) ListAchievement(req *types.ListAchievementReq) (resp *[]types.ListAchievementResp, err error) {
var achievements []models.Achievement
query := l.svcCtx.DbEngin.Table("achievement")
// 添加成果名称模糊查询条件
if req.Title != "" {
query = query.Where("title LIKE ?", "%"+req.Title+"%")
}
// 添加标签名称查询条件假设标签存储在tags字段中
if req.Label != "" {
query = query.Where("label LIKE ?", "%"+req.Label+"%")
}
query = query.Where("status = 1")
tx := query.Find(&achievements)
if tx.Error != nil {
return nil, tx.Error
}
result := make([]types.ListAchievementResp, len(achievements))
for i, achievement := range achievements {
result[i] = types.ListAchievementResp{
Id: fmt.Sprintf("%d", achievement.Id),
TaskId: fmt.Sprintf("%d", achievement.TaskId),
Title: achievement.Title,
Label: achievement.Label,
Description: achievement.Description,
Status: achievement.Status,
UserName: achievement.UserName,
PublishTime: achievement.PublishTime,
}
}
return &result, nil
}

View File

@ -2,11 +2,13 @@ package core
import (
"context"
"strings"
"time"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/timeutils"
"time"
"github.com/zeromicro/go-zero/core/logx"
)
@ -49,8 +51,18 @@ func (l *PageListTaskLogic) PageListTask(req *types.PageTaskReq) (resp *types.Pa
if req.Name != "" {
db = db.Where("name LIKE ?", "%"+req.Name+"%")
}
// 任务状态筛选
if req.Status != "" {
split := strings.Split(req.Status, ",")
if len(split) > 1 {
db = db.Where("status IN ?", split)
} else {
db = db.Where("status = ?", req.Status)
}
}
if req.Type != "" {
db = db.Where("adapter_type_dict = ?", req.Type)
db = db.Where("task_type_dict != ?", "instance")
}
// 计算总数
var total int64
@ -70,6 +82,16 @@ func (l *PageListTaskLogic) PageListTask(req *types.PageTaskReq) (resp *types.Pa
// 计算每个任务的运行时间x
for _, model := range list {
model.RunningTime = calculateRunningTime(model.StartTime, model.EndTime)
if model.AdapterTypeDict == "0" {
type tempSpec struct { // 嵌套临时 struct对应 JSON 的 specifications 字段
CPU string `json:"CPU"`
Memory string `json:"Memory"`
}
var temp tempSpec
l.svcCtx.DbEngin.Raw("SELECT IFNULL(resource_spec->>'$.specifications.CPU', '') AS cpu,IFNULL(resource_spec->>'$.specifications.Memory', '') AS memory FROM task_cloud where task_id = ?", model.Id).Scan(&temp)
model.Cpu = temp.CPU
model.Memory = temp.Memory
}
}
// 填充响应数据

View File

@ -3,6 +3,7 @@ package core
import (
"context"
"fmt"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"gorm.io/gorm"
@ -52,26 +53,32 @@ func (l *PageResourceRangeLogic) PageResourceRange(req *types.ResourceSpecReq) (
}
func (l *PageResourceRangeLogic) buildBaseQuery(req *types.ResourceSpecReq) *gorm.DB {
query := l.svcCtx.DbEngin.Model(&models.TResourceSpec{}).
Where("deleted_at IS NULL")
query := l.svcCtx.DbEngin.Model(&models.TResourceSpec{}).Table("t_resource_spec as rs").
Where("rs.deleted_at IS NULL")
if req.ClusterId != "" {
query = query.Where("cluster_id = ?", req.ClusterId)
query = query.Where("rs.cluster_id = ?", req.ClusterId)
}
if req.Tag != "" {
query = query.Where("tag = ?", req.Tag)
query = query.Where("rs.tag = ?", req.Tag)
}
if req.Status != "" {
query = query.Where("status = ?", req.Status)
query = query.Where("rs.status = ?", req.Status)
}
if req.ChangeType != "" {
query = query.Where("change_type = ?", req.ChangeType)
query = query.Where("rs.change_type = ?", req.ChangeType)
}
if req.Type != "" {
query = query.Where("type = ?", req.Type)
query = query.Where("rs.type = ?", req.Type)
}
if req.Name != "" {
query = query.Where("name LIKE ?", "%"+req.Name+"%")
query = query.Where("rs.name LIKE ?", "%"+req.Name+"%")
}
if req.ClusterType != "" {
query = query.
Joins("JOIN t_cluster c ON rs.cluster_id = c.id").
Where("c.cluster_type = ?", req.ClusterType).
Where("c.deleted_at IS NULL")
}
return query

View File

@ -0,0 +1,47 @@
package core
import (
"context"
"strconv"
"time"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
)
type PublishAchievementLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewPublishAchievementLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PublishAchievementLogic {
return &PublishAchievementLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *PublishAchievementLogic) PublishAchievement(req *types.PublishAchievementReq) (resp *types.TaskListResp, err error) {
taskId, err := strconv.ParseInt(req.TaskId, 10, 64)
achievement := models.Achievement{
Id: tool.GenSnowflakeID(),
TaskId: taskId,
Title: req.Title,
TitleImagePath: req.TitleImagePath,
Label: req.Label,
Description: req.Description,
Content: req.Content,
Status: 1,
PublishTime: time.Now().Format("2006-01-02 15:04:05"),
UserId: req.UserId,
UserName: req.UserName,
}
l.svcCtx.DbEngin.Table("achievement").Create(&achievement)
return nil, nil
}

View File

@ -0,0 +1,46 @@
package core
import (
"context"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"k8s.io/apimachinery/pkg/util/json"
)
type QueryAchievementLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewQueryAchievementLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryAchievementLogic {
return &QueryAchievementLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *QueryAchievementLogic) QueryAchievement(req *types.QueryAchievementReq) (resp *types.QueryAchievementResp, err error) {
achievement := models.Achievement{}
tx := l.svcCtx.DbEngin.Table("achievement").Where("task_id = ?", req.TaskId).Find(&achievement)
if tx.Error != nil {
return nil, tx.Error
}
bytes, err := json.Marshal(achievement)
if err != nil {
return nil, err
}
json.Unmarshal(bytes, &resp)
if achievement.Id != 0 {
resp.Id = strconv.FormatInt(achievement.Id, 10)
}
if achievement.TaskId != 0 {
resp.TaskId = strconv.FormatInt(achievement.TaskId, 10)
}
return resp, nil
}

View File

@ -0,0 +1,44 @@
package core
import (
"context"
"errors"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
)
type RevokeAchievementLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewRevokeAchievementLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RevokeAchievementLogic {
return &RevokeAchievementLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *RevokeAchievementLogic) RevokeAchievement(req *types.RevokeAchievementReq) (resp *types.TaskListResp, err error) {
// 更新成就状态为草稿
result := l.svcCtx.DbEngin.Table("achievement").
Where("task_id = ?", req.TaskId).
Updates(map[string]interface{}{
"status": "0",
})
if result.Error != nil {
return nil, result.Error
}
if result.RowsAffected == 0 {
return nil, errors.New("未找到要更新的记录")
}
return nil, nil
}

View File

@ -61,7 +61,7 @@ func (l *TaskDetailsLogic) TaskDetails(req *types.FId) (resp *types.TaskDetailsR
for _, sub := range subList {
clusterIds = append(clusterIds, sub.ClusterId)
}
err = l.svcCtx.DbEngin.Table("t_cluster").Select("id,adapter_id,name,nickname,description,create_time").Where("id in ?", clusterIds).Scan(&cList).Error
err = l.svcCtx.DbEngin.Table("t_cluster").Select("id,adapter_id,name,nickname,description,create_time").Where("storage_schedule = 1 and id in ?", clusterIds).Scan(&cList).Error
if err != nil {
return resp, err
}

View File

@ -0,0 +1,57 @@
package core
import (
"context"
"fmt"
"strings"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
)
type TypeClusterResourceLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewTypeClusterResourceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TypeClusterResourceLogic {
return &TypeClusterResourceLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// TypeClusterResource 根据资源类型获取对应的集群信息
func (l *TypeClusterResourceLogic) TypeClusterResource(req *types.TypeResourceSpecReq) (resp []types.ClusterInfo, err error) {
if len(req.Type) == 0 {
return nil, nil
}
// 将逗号分隔的字符串拆分为类型列表
typeList := strings.Split(req.Type, ",")
// 构建占位符和参数
placeholders := make([]string, len(typeList))
args := make([]interface{}, len(typeList))
for i, t := range typeList {
placeholders[i] = "?"
args[i] = strings.TrimSpace(t) // 去除可能的前后空格
}
sqlStr := fmt.Sprintf(`SELECT c.id , c.name, c.nickname
FROM t_resource_spec rs
INNER JOIN t_cluster c ON rs.cluster_id = c.id
WHERE rs.type IN (%s)
AND rs.deleted_at IS NULL
AND c.deleted_at IS NULL
AND rs.status = 1
AND c.storage_schedule = 1
GROUP BY c.id, c.name, c.nickname
ORDER BY c.id;`, strings.Join(placeholders, ","))
l.svcCtx.DbEngin.Raw(sqlStr, args...).Scan(&resp)
return resp, nil
}

View File

@ -3,6 +3,7 @@ package hpc
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
@ -39,33 +40,6 @@ func NewCancelJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CancelJ
}
func (l *CancelJobLogic) CancelJob(req *types.CancelJobReq) error {
//var clusterInfo *types.ClusterInfo
//tx := l.svcCtx.DbEngin.Raw("select * from t_cluster where id = ?", req.ClusterId).Scan(&clusterInfo)
//if tx.Error != nil {
// return tx.Error
//}
//// 查询p端调用地址
//var adapterAddress string
//l.svcCtx.DbEngin.Raw("SELECT server FROM `t_adapter` where id = ?", clusterInfo.AdapterId).Scan(&adapterAddress)
//var jobResp slurm.GetJobResp
//httpClient := resty.New().R()
//_, err := httpClient.SetHeader("Content-Type", "application/json").
// SetQueryParams(map[string]string{
// "jobId": req.JobId,
// "server": clusterInfo.Server,
// "version": clusterInfo.Version,
// "token": clusterInfo.Token,
// "username": clusterInfo.Username,
// }).
// SetResult(&jobResp).
// Delete(adapterAddress + "/api/v1/job/cancel")
//if err != nil {
// return err
//}
//if len(jobResp.Errors) != 0 {
// return errors.Errorf(jobResp.Errors[0].Description)
//}
//return nil
var hpcR TaskHPCResult
tx := l.svcCtx.DbEngin.Raw(
"SELECT t.id, hpc.job_id ,hpc.adapter_id, hpc.cluster_id FROM task t "+
@ -79,23 +53,19 @@ func (l *CancelJobLogic) CancelJob(req *types.CancelJobReq) error {
if hpcR.ID == 0 || hpcR.JobID == "" {
return fmt.Errorf("作业不存在")
}
var adapterInfo types.AdapterInfo
l.svcCtx.DbEngin.Raw("SELECT * FROM `t_adapter` where id = ?", hpcR.AdapterId).Scan(&adapterInfo)
if adapterInfo.Id == "" {
return fmt.Errorf("adapter not found")
}
// 取消作业
err := l.hpcService.HpcExecutorAdapterMap[adapterInfo.Id].CancelTask(l.ctx, hpcR.JobID, hpcR.ClusterId)
err := l.hpcService.HpcExecutorClusterMap[hpcR.ClusterId].CancelTask(l.ctx, hpcR.JobID, hpcR.ClusterId)
if err != nil {
return err
}
// 更新数据库状态
tx = l.svcCtx.DbEngin.Model(&types.Task{}).Where("id = ?", hpcR.ID).Update("status", "Canceled").Error
tx = l.svcCtx.DbEngin.Model(&types.Task{}).Where("id = ?", hpcR.ID).Update("status", "Cancelled").Error
if tx != nil {
return fmt.Errorf("数据库更新失败: %v", tx.Error)
}
// 更新数据库状态
tx = l.svcCtx.DbEngin.Model(&models.TaskHpc{}).Where("task_id = ?", hpcR.ID).Update("status", "Canceled").Error
tx = l.svcCtx.DbEngin.Model(&models.TaskHpc{}).Where("task_id = ?", hpcR.ID).Update("status", "Cancelled").Error
if tx != nil {
return fmt.Errorf("数据库更新失败: %v", tx.Error)
}

View File

@ -209,6 +209,7 @@ func (l *CommitHpcTaskLogic) SaveHpcTaskToDB(req *types.CommitHpcTaskReq, jobScr
AdapterTypeDict: constants.AdapterTypeHPC,
UserId: userID,
UserName: req.Parameters[constants.UserName],
Token: req.Parameters["Token"],
}
if err = tx.Table("task").Create(&taskModel).Error; err != nil {
@ -231,7 +232,8 @@ func (l *CommitHpcTaskLogic) SaveHpcTaskToDB(req *types.CommitHpcTaskReq, jobScr
slurmResource := parser.ParseScript(jobScript)
resource = models.ResourceSpec{
//资源规格名称,采用拼接的方式 集群名+队列名
ResourceName: fmt.Sprintf("%s_%s", clusterInfo.Name, slurmResource.Partition),
ResourceName: fmt.Sprintf("%s_partition %s", clusterInfo.Name, slurmResource.Partition),
ResourceType: constants.TaskTypeHpc,
Partition: slurmResource.Partition,
Specifications: slurmResource,
}
@ -296,17 +298,17 @@ func (l *CommitHpcTaskLogic) SaveHpcTaskToDB(req *types.CommitHpcTaskReq, jobScr
}
func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *types.CommitHpcTaskResp, err error) {
reqJSON, err := jsoniter.MarshalToString(req)
if err != nil {
return nil, fmt.Errorf("failed to marshal request: %w", err)
}
logc.Infof(l.ctx, "提交超算任务请求参数: %s", reqJSON)
logc.Debugf(
l.ctx,
"提交超算任务请求: clusterId=%s, app=%s, backend=%s, operateType=%s",
req.ClusterId, req.App, req.Backend, req.OperateType,
)
jobName := generateJobName(req)
req.Parameters["jobName"] = jobName
// 获取集群和适配器信息
clusterInfo, adapterInfo, err := l.getClusterInfo(req.ClusterId)
clusterInfo, _, err := l.getClusterInfo(req.ClusterId)
if err != nil {
return nil, err
}
@ -337,7 +339,6 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
scriptContent = script
}
q, _ := jsoniter.MarshalToString(scriptContent)
submitQ := types.SubmitHpcTaskReq{
App: req.App,
ClusterId: req.ClusterId,
@ -345,11 +346,15 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
ScriptContent: scriptContent,
Parameters: req.Parameters,
Backend: req.Backend,
JcsUserID: req.JcsUserID,
}
log.Info().Msgf("Submitting HPC task to cluster %s with params: %s", clusterInfo.Name, q)
resp, err = l.hpcService.HpcExecutorAdapterMap[adapterInfo.Id].SubmitTask(l.ctx, submitQ)
log.Info().Msgf(
"Submitting HPC task to cluster %s, backend: %s, scriptLength: %d",
clusterInfo.Name, req.Backend, len(scriptContent),
)
resp, err = l.hpcService.HpcExecutorClusterMap[clusterInfo.Id].SubmitTask(l.ctx, submitQ)
if err != nil {
log.Error().Err(err).Msgf("提交超算任务失败, cluster: %s, jobName: %s, scriptContent: %s", clusterInfo.Name, jobName, scriptContent)
log.Error().Err(err).Msgf("提交超算任务失败, cluster: %s, jobName: %s", clusterInfo.Name, jobName)
return nil, fmt.Errorf("网络请求失败,请稍后重试")
}
@ -357,7 +362,7 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
workDir := resp.Data.JobInfo["jobDir"]
taskID, err := l.SaveHpcTaskToDB(req, scriptContent, jobID, workDir)
if err != nil {
log.Error().Msgf("超算任务保存到数据库失败, cluster: %s, jobName: %s, scriptContent: %s, error: %v", clusterInfo.Name, jobName, scriptContent, err)
log.Error().Msgf("超算任务保存到数据库失败, cluster: %s, jobName: %s, error: %v", clusterInfo.Name, jobName, err)
return nil, fmt.Errorf("保存超算任务到数据库失败: %w", err)
}

View File

@ -3,6 +3,7 @@ package hpc
import (
"context"
"fmt"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
@ -47,13 +48,9 @@ func (l *GetHpcTaskLogLogic) GetHpcTaskLog(req *types.HpcTaskLogReq) (resp inter
if hpcR.ID == 0 {
return nil, fmt.Errorf("任务不存在")
}
var adapterInfo types.AdapterInfo
l.svcCtx.DbEngin.Raw("SELECT * FROM `t_adapter` where id = ?", hpcR.AdapterId).Scan(&adapterInfo)
if adapterInfo.Id == "" {
return nil, fmt.Errorf("adapter not found")
}
// 取消作业
resp, err = l.hpcService.HpcExecutorAdapterMap[adapterInfo.Id].GetTaskLogs(l.ctx, hpcR.JobID, hpcR.ClusterId)
// 获取作业任务日志
resp, err = l.hpcService.HpcExecutorClusterMap[hpcR.ClusterId].GetTaskLogs(l.ctx, hpcR.JobID, hpcR.ClusterId)
if err != nil {
return nil, err
}

View File

@ -2,11 +2,13 @@ package hpc
import (
"context"
"github.com/go-resty/resty/v2"
"github.com/pkg/errors"
"fmt"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector"
hpcservice "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/hpc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-hpc/slurm"
"strconv"
"strings"
"github.com/zeromicro/go-zero/core/logx"
)
@ -27,34 +29,49 @@ func NewJobInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobInfoLo
func (l *JobInfoLogic) JobInfo(req *types.JobInfoReq) (resp *types.JobInfoResp, err error) {
resp = &types.JobInfoResp{}
var clusterInfo *types.ClusterInfo
tx := l.svcCtx.DbEngin.Raw("select * from t_cluster where id = ?", req.ClusterId).Scan(&clusterInfo)
clusterInfo := &types.ClusterInfo{}
tx := l.svcCtx.DbEngin.Raw("select * from t_cluster where id = ?", req.ClusterId).Scan(clusterInfo)
if tx.Error != nil {
return nil, tx.Error
}
// 查询p端调用地址
var adapterAddress string
l.svcCtx.DbEngin.Raw("SELECT server FROM `t_adapter` where id = ?", clusterInfo.AdapterId).Scan(&adapterAddress)
var jobResp slurm.GetJobResp
httpClient := resty.New().R()
_, err = httpClient.SetHeader("Content-Type", "application/json").
SetQueryParams(map[string]string{
"jobId": req.JobId,
"server": clusterInfo.Server,
"version": clusterInfo.Version,
"token": clusterInfo.Token,
"username": clusterInfo.Username,
}).
SetResult(&jobResp).
Get(adapterAddress + "/api/v1/job/info")
if strings.TrimSpace(clusterInfo.Id) == "" {
return nil, fmt.Errorf("cluster %d not found", req.ClusterId)
}
hpcCollector, err := l.resolveHpcCollector(clusterInfo)
if err != nil {
return nil, err
}
if len(jobResp.Errors) != 0 {
return nil, errors.Errorf(jobResp.Errors[0].Description)
task, err := hpcCollector.GetTaskDetail(l.ctx, req.JobId, clusterInfo.Id)
if err != nil {
return nil, err
}
resp.JobId = jobResp.Jobs[0].JobId
resp.JobState = jobResp.Jobs[0].JobState
resp.CurrentWorkingDirectory = jobResp.Jobs[0].CurrentWorkingDirectory
resp.JobId = task.Id
resp.JobState = task.Status
resp.CurrentWorkingDirectory = task.WorkDir
return resp, nil
}
func (l *JobInfoLogic) resolveHpcCollector(clusterInfo *types.ClusterInfo) (collector.HPCCollector, error) {
if l.svcCtx.Scheduler != nil &&
l.svcCtx.Scheduler.HpcService != nil &&
l.svcCtx.Scheduler.HpcService.HpcExecutorClusterMap != nil {
if c, ok := l.svcCtx.Scheduler.HpcService.HpcExecutorClusterMap[clusterInfo.Id]; ok && c != nil {
return c, nil
}
}
if strings.TrimSpace(clusterInfo.Server) == "" {
return nil, fmt.Errorf("cluster %s server is empty", clusterInfo.Id)
}
clusterID, err := strconv.ParseInt(clusterInfo.Id, 10, 64)
if err != nil {
return nil, fmt.Errorf("parse cluster id %s failed: %w", clusterInfo.Id, err)
}
return hpcservice.NewHpc(clusterInfo.Server, clusterID, clusterInfo.Nickname), nil
}

View File

@ -2,6 +2,7 @@ package hpc
import (
"context"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"github.com/zeromicro/go-zero/core/logx"
@ -48,7 +49,7 @@ func (l *ListInstanceCenterLogic) ListInstanceCenter(req *types.HpcInstanceCente
return resp, err
}
db = db.Where("deleted_at is null").Limit(limit).Offset(offset)
err = db.Order("created_at desc").Find(&list).Error
err = db.Order("status desc ,sort_order desc").Find(&list).Error
if err != nil {
return nil, err
}

View File

@ -0,0 +1,60 @@
package inference
import (
"context"
"errors"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"strconv"
)
type InferenceTaskLogLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewInferenceTaskLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InferenceTaskLogLogic {
return &InferenceTaskLogLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *InferenceTaskLogLogic) InferenceTaskLog(req *types.InferenceTaskLogReq) (resp *types.InferenceTaskLogResp, err error) {
resp = &types.InferenceTaskLogResp{}
taskId, err := strconv.ParseInt(req.TaskId, 10, 64)
if err != nil {
return nil, err
}
instance, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceByTaskId(taskId)
if err != nil {
return nil, err
}
if instance == nil {
return nil, errors.New("deploy instance not found")
}
clusterId := strconv.Itoa(int(instance.ClusterId))
log, err := l.svcCtx.Scheduler.AiService.Ai.TaskInferenceLog(clusterId, instance.InstanceId)
if err != nil {
return nil, err
}
if log.Code != 200 {
return nil, errors.New(log.Message)
}
str, ok := log.Data.(string)
if ok {
resp.Log = str
} else {
return nil, errors.New("not a string")
}
return resp, nil
}

View File

@ -50,7 +50,7 @@ func (l *CreateDeployTaskLogic) CreateDeployTask(req *types.CreateDeployTaskReq)
return nil, errors.New("TaskName already exists")
}
taskId, err := l.svcCtx.Scheduler.AiStorages.SaveInferDeployTask(req.TaskName, 0, req.ModelName, req.ModelType, req.TaskDesc)
taskId, err := l.svcCtx.Scheduler.AiStorages.SaveInferDeployTask("", req.TaskName, 0, req.ModelName, req.ModelType, req.TaskDesc)
if err != nil {
return nil, err
}

View File

@ -5,11 +5,14 @@ import (
"encoding/json"
"errors"
"fmt"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/participant"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/entity"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/utils/status"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/utils/task"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink"
"net/http"
"strconv"
"strings"
"sync"
@ -69,18 +72,18 @@ func (l *CreateInferenceTaskLogic) CreateInferenceTask(req *types.CreateInferenc
Cmd: "",
}
taskId, err := l.svcCtx.Scheduler.AiStorages.SaveInferDeployTask(taskName, req.UserId, modelName, "", req.Description)
taskId, err := l.svcCtx.Scheduler.AiStorages.SaveInferDeployTask(req.Token, taskName, req.UserId, modelName, "", req.Description)
if err != nil {
return nil, err
}
adapterClusterMap := make(map[string][]*strategy.AssignedCluster)
adapterClusterMap[AdapterId] = assignedClusters
adapterClusterMap[l.svcCtx.Config.Participant.AdapterId] = assignedClusters
err = l.createInferenceTask(taskId, adapterClusterMap, opt)
if err != nil {
if len(assignedClusters) != 0 {
_ = status.ReportInferenceStatusMessages(l.svcCtx, nil, taskName, strconv.FormatInt(taskId, 10), assignedClusters[0].ClusterId, "", false, "")
_ = status.ReportInferenceStatusMessages(l.svcCtx, nil, taskName, strconv.FormatInt(taskId, 10), assignedClusters[0].ClusterId, "", false, err.Error())
logx.Errorf("############ Report Infer Task Status Message Error %s", err.Error())
}
return nil, err
@ -107,11 +110,11 @@ func (l *CreateInferenceTaskLogic) createInferenceTask(taskId int64, adapterClus
cluster := c
buf <- true
go func() {
opt, _ := cloneOption(option)
//opt, _ := cloneOption(option)
//
//updateInferOption(cluster, opt)
updateInferOption(cluster, opt)
err := l.createDeployInstance(taskId, aid, cluster.ClusterId, opt)
err := l.createDeployInstance(taskId, aid, cluster)
if err != nil {
e := struct {
err error
@ -198,6 +201,7 @@ func generateClustersForTaskCreation(distributes types.DataDistribute, taskName
}
cluster.CodeId = jsonData.Id
cluster.CodeName = jsonData.Name
clusterMap[c.ClusterID] = cluster
}
}
@ -223,11 +227,10 @@ func generateClustersForTaskCreation(distributes types.DataDistribute, taskName
cluster, ok := clusterMap[c.ClusterID]
if ok {
cluster.ModelId = jsonData.Id
cluster.ModelId += jsonData.Id + storeLink.SEMMI_COLON
cluster.ModelName = jsonData.Name
}
}
}
for _, distribute := range distributes.Image {
@ -293,16 +296,26 @@ func generateModelName(clusters []*strategy.AssignedCluster) (string, error) {
return modelName, nil
}
func (l *CreateInferenceTaskLogic) createDeployInstance(taskId int64, adapterId string, clusterId string, opt *option.InferOption) error {
cmap, found := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[adapterId]
if !found {
return errors.New("adapterId not exist: " + adapterId)
func (l *CreateInferenceTaskLogic) createDeployInstance(taskId int64, adapterId string, c *strategy.AssignedCluster) error {
//cmap, found := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[adapterId]
//if !found {
// return errors.New("adapterId not exist: " + adapterId)
//}
//iCluster, found := cmap[clusterId]
//if !found {
// return errors.New("clusterId not exist: " + clusterId)
//}
//insId, err := iCluster.CreateInferDeployInstance(l.ctx, opt)
//if err != nil {
// return err
//}
resp, err := l.runTask(c)
if err != nil {
return err
}
iCluster, found := cmap[clusterId]
if !found {
return errors.New("clusterId not exist: " + clusterId)
}
insId, err := iCluster.CreateInferDeployInstance(l.ctx, opt)
insId, err := l.svcCtx.Scheduler.AiService.Cvt.ConvertToInferenceTaskResult(resp, c.ClusterId)
if err != nil {
return err
}
@ -311,7 +324,7 @@ func (l *CreateInferenceTaskLogic) createDeployInstance(taskId int64, adapterId
if err != nil {
return err
}
cid, err := strconv.ParseInt(clusterId, 10, 64)
cid, err := strconv.ParseInt(c.ClusterId, 10, 64)
if err != nil {
return err
}
@ -321,16 +334,39 @@ func (l *CreateInferenceTaskLogic) createDeployInstance(taskId int64, adapterId
return err
}
clusterName, err := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(clusterId)
clusterName, err := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(c.ClusterId)
if err != nil {
return err
}
ins, err := iCluster.GetInferDeployInstance(l.ctx, insId)
detail, err := l.svcCtx.Scheduler.AiService.Ai.TaskInferenceDetail(c.ClusterId, insId)
if err != nil {
return err
}
if detail.Code != http.StatusOK {
return errors.New(detail.Message)
}
//url, err := l.svcCtx.Ai.TaskInferenceUrl(c.ClusterId, insId)
//if err != nil {
// return err
//}
//
//if url.Code != http.StatusOK {
// return errors.New(url.Message)
//}
ins, err := l.svcCtx.Scheduler.AiService.Cvt.ConvertToDeployInstance(l.svcCtx.Scheduler.AiService.Ai, detail.Data, c.ClusterId, nil, false)
if err != nil {
return err
}
//ins, err := iCluster.GetInferDeployInstance(l.ctx, insId)
//if err != nil {
// return err
//}
_, err = l.svcCtx.Scheduler.AiStorages.SaveInferDeployInstance(taskId, ins.InstanceId, ins.InstanceName, aid, adapterName, cid, clusterName, ins.ModelName, ins.ModelType, ins.InferCard, ins.ClusterType)
if err != nil {
return err
@ -339,6 +375,45 @@ func (l *CreateInferenceTaskLogic) createDeployInstance(taskId int64, adapterId
return nil
}
func (l *CreateInferenceTaskLogic) runTask(c *strategy.AssignedCluster) (interface{}, error) {
param := &participant.TaskCreateInferParam{
Id: c.ClusterId,
Algorithm: struct {
Id string `json:"id"`
Name string `json:"name"`
}{
Id: c.CodeId,
Name: c.CodeName,
},
Model: struct {
Id string `json:"id"`
Name string `json:"name"`
}{
Id: c.ModelId,
Name: c.ModelName,
},
Image: struct {
Id string `json:"id"`
Name string `json:"name"`
}{
Id: c.ImageId,
},
Resource: struct {
ResourcesRequired []map[string]interface{} `json:"resourcesRequired"`
}{
ResourcesRequired: c.ResourcesRequired,
},
}
cresp, err := l.svcCtx.Scheduler.AiService.Ai.TaskCreateInfer(c.ClusterId, param)
if err != nil {
return nil, err
}
if cresp.Code != http.StatusOK {
return nil, errors.New(cresp.Message)
}
return cresp.Data, nil
}
func cloneOption(opt *option.InferOption) (*option.InferOption, error) {
origJSON, err := json.Marshal(opt)
if err != nil {

View File

@ -22,20 +22,36 @@ func NewDeployInstanceStatLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
}
func (l *DeployInstanceStatLogic) DeployInstanceStat(req *types.DeployInstanceStatReq) (resp *types.DeployInstanceStatResp, err error) {
func (l *DeployInstanceStatLogic) DeployInstanceStat(req *types.DeployInstanceStatReq, userName string, userId int64) (resp *types.DeployInstanceStatResp, err error) {
resp = &types.DeployInstanceStatResp{}
total, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceTotalNum()
if err != nil {
return nil, err
if userName != "" && userName != "admin" {
total, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceTotalNumByUserId(userId)
if err != nil {
return nil, err
}
running, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceRunningNumByUserId(userId)
if err != nil {
return nil, err
}
resp.Total = total
resp.Running = running
} else {
total, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceTotalNum()
if err != nil {
return nil, err
}
running, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceRunningNum()
if err != nil {
return nil, err
}
resp.Total = total
resp.Running = running
}
running, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceRunningNum()
if err != nil {
return nil, err
}
resp.Total = total
resp.Running = running
return resp, nil
}

View File

@ -2,10 +2,11 @@ package inference
import (
"context"
"strconv"
"errors"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"net/http"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
)
@ -27,13 +28,35 @@ func NewGetDeployInstanceLogic(ctx context.Context, svcCtx *svc.ServiceContext)
func (l *GetDeployInstanceLogic) GetDeployInstance(req *types.GetDeployInstanceReq) (resp *types.GetDeployInstanceResp, err error) {
resp = &types.GetDeployInstanceResp{}
id, err := strconv.ParseInt(req.Id, 10, 64)
ins, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceById(id)
taskId, err := strconv.ParseInt(req.TaskId, 10, 64)
if err != nil {
return nil, err
}
instance, err := l.svcCtx.Scheduler.AiService.Ai.Store.GetInferDeployInstanceByTaskId(taskId)
if err != nil {
return nil, err
}
in, err := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].GetInferDeployInstance(l.ctx, ins.InstanceId)
clusterId := strconv.Itoa(int(instance.ClusterId))
detail, err := l.svcCtx.Scheduler.AiService.Ai.TaskInferenceDetail(clusterId, instance.InstanceId)
if err != nil {
return nil, err
}
if detail.Code != http.StatusOK {
return nil, errors.New(detail.Message)
}
//url, err := l.svcCtx.Ai.TaskInferenceUrl(clusterId, instance.InstanceId)
//if err != nil {
// return nil, err
//}
//
//if url.Code != http.StatusOK {
// return nil, errors.New(url.Message)
//}
in, err := l.svcCtx.Scheduler.AiService.Cvt.ConvertToDeployInstance(l.svcCtx.Scheduler.AiService.Ai, detail.Data, clusterId, instance, true)
if err != nil {
return nil, err
}

View File

@ -22,20 +22,35 @@ func NewInferenceTaskStatLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
}
func (l *InferenceTaskStatLogic) InferenceTaskStat(req *types.InferenceTaskStatReq) (resp *types.InferenceTaskStatResp, err error) {
func (l *InferenceTaskStatLogic) InferenceTaskStat(req *types.InferenceTaskStatReq, userName string, userId int64) (resp *types.InferenceTaskStatResp, err error) {
resp = &types.InferenceTaskStatResp{}
total, err := l.svcCtx.Scheduler.AiStorages.GetInferenceTaskTotalNum()
if err != nil {
return nil, err
}
if userName != "" && userName != "admin" {
total, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceTotalNumByUserId(userId)
if err != nil {
return nil, err
}
running, err := l.svcCtx.Scheduler.AiStorages.GetInferenceTaskRunningNum()
if err != nil {
return nil, err
}
running, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceRunningNumByUserId(userId)
if err != nil {
return nil, err
}
resp.Total = total
resp.Running = running
resp.Total = total
resp.Running = running
} else {
total, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceTotalNum()
if err != nil {
return nil, err
}
running, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceRunningNum()
if err != nil {
return nil, err
}
resp.Total = total
resp.Running = running
}
return resp, nil
}

View File

@ -4,8 +4,11 @@ import (
"context"
"errors"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/participant/utils"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/inference"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"net/http"
"strconv"
)
@ -26,26 +29,52 @@ func NewStopDeployInstanceLogic(ctx context.Context, svcCtx *svc.ServiceContext)
func (l *StopDeployInstanceLogic) StopDeployInstance(req *types.StopDeployInstanceReq) (resp *types.StopDeployInstanceResp, err error) {
resp = &types.StopDeployInstanceResp{}
id, err := strconv.ParseInt(req.Id, 10, 64)
ins, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceById(id)
taskId, err := strconv.ParseInt(req.TaskId, 10, 64)
if err != nil {
return nil, err
}
instance, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceByTaskId(taskId)
if err != nil {
return nil, err
}
in, err := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].GetInferDeployInstance(l.ctx, ins.InstanceId)
if instance == nil {
return nil, errors.New("deploy instance not found")
}
clusterId := strconv.Itoa(int(instance.ClusterId))
detail, err := l.svcCtx.Scheduler.AiService.Ai.TaskInferenceDetail(clusterId, instance.InstanceId)
if err != nil {
return nil, err
}
if l.svcCtx.Scheduler.AiService.Si.CheckRunningStatus(in) {
success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[req.AdapterId][req.ClusterId].StopInferDeployInstance(l.ctx, in.InstanceId)
if !success {
return nil, errors.New("stop instance failed")
if detail.Code != http.StatusOK {
return nil, errors.New(detail.Message)
}
in, err := l.svcCtx.Scheduler.AiService.Cvt.ConvertToDeployInstance(l.svcCtx.Scheduler.AiService.Ai, detail.Data, clusterId, nil, false)
if err != nil {
return nil, err
}
// temporarily convert to type
deployInstance := &inference.DeployInstance{}
err = utils.InstanceToObj(in, deployInstance)
if err != nil {
return nil, err
}
if l.svcCtx.Scheduler.AiService.Si.CheckRunningStatus(deployInstance) {
stop, err := l.svcCtx.Scheduler.AiService.Ai.TaskInferenceStop(clusterId, instance.InstanceId)
if err != nil {
return nil, err
}
if stop.Code != http.StatusOK {
return nil, errors.New(stop.Message)
}
}
ins.Status = "Updating"
err = l.svcCtx.Scheduler.AiStorages.UpdateInferDeployInstance(ins, true)
instance.Status = "Updating"
err = l.svcCtx.Scheduler.AiStorages.UpdateInferDeployInstance(instance, true)
if err != nil {
return nil, err
}

View File

@ -2,20 +2,21 @@ package schedule
import (
"context"
"encoding/json"
"errors"
"fmt"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"strconv"
"strings"
"sync"
"time"
)
const (
ADAPTERID = "1777144940459986944" // 异构适配器id
ADAPTERID = "1777144940456666666" // 异构适配器id
QUERY_TRAIN_RESOURCES = "train_resources"
QUERY_INFERENCE_RESOURCES = "inference_resources"
)
@ -71,7 +72,7 @@ func (l *QueryResourcesLogic) QueryResources(req *types.QueryResourcesReq) (resp
} else {
var clusters []types.ClusterInfo
for _, id := range req.ClusterIDs {
cluster, err := l.svcCtx.Scheduler.AiStorages.GetClustersById(id)
cluster, err := l.svcCtx.Scheduler.AiStorages.GetStorageScheduledClustersById(id)
if err != nil {
return nil, err
}
@ -117,22 +118,48 @@ func (l *QueryResourcesLogic) QueryResourcesByClusterId(clusterinfos []types.Clu
defer wg.Done()
done := make(chan bool)
var u *collector.ResourceSpec
var err error
//var err error
go func() {
col, found := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[strconv.FormatInt(c.AdapterId, 10)][c.Id]
if !found {
done <- true
return
}
u, err = col.GetResourceSpecs(l.ctx, resrcType)
specs, err := l.svcCtx.Scheduler.AiService.Ai.ResourceSpecs(c.Id, resrcType)
if err != nil {
logx.Error(err)
done <- true
return
}
if specs.Code != 200 {
logx.Error(specs.Message)
done <- true
return
}
bytes, err := json.Marshal(specs.Data)
if err != nil {
logx.Error(err)
done <- true
return
}
u, err = parseResourceSpec(bytes)
if err != nil {
logx.Error(err)
done <- true
return
}
//col, found := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[strconv.FormatInt(c.AdapterId, 10)][c.Id]
//if !found {
// done <- true
// return
//}
//
//u, err = col.GetResourceSpecs(l.ctx, resrcType)
//if err != nil {
// logx.Error(err)
// done <- true
// return
//}
done <- true
}()
@ -210,6 +237,61 @@ func handleEmptyResourceUsage(list []types.ClusterInfo, ulist []*collector.Resou
return rus
}
func parseResourceSpec(jsonData []byte) (*collector.ResourceSpec, error) {
auxiliary := struct {
ClusterId string `json:"clusterID"`
ClusterType string `json:"clusterType"`
Region string `json:"region"`
Tag string `json:"tag"`
Resources json.RawMessage `json:"resources"`
Msg string `json:"msg"`
}{}
if err := json.Unmarshal(jsonData, &auxiliary); err != nil {
return nil, err
}
resources, err := convertRawMessageToInterfaceSlice(auxiliary.Resources)
if err != nil {
return nil, err
}
return &collector.ResourceSpec{
ClusterId: auxiliary.ClusterId,
ClusterType: auxiliary.ClusterType,
Region: auxiliary.Region,
Tag: auxiliary.Tag,
Resources: resources,
Msg: auxiliary.Msg,
}, nil
}
func convertRawMessageToInterfaceSlice(raw json.RawMessage) ([]interface{}, error) {
if len(raw) == 0 || string(raw) == "null" {
return []interface{}{}, nil
}
// 尝试解析为数组
var slice []interface{}
if err := json.Unmarshal(raw, &slice); err == nil {
return slice, nil
}
// 尝试解析为单个对象
var single interface{}
if err := json.Unmarshal(raw, &single); err == nil {
return []interface{}{single}, nil
}
// 尝试解析为其他类型(字符串、数字等)
var value interface{}
if err := json.Unmarshal(raw, &value); err == nil {
return []interface{}{value}, nil
}
return nil, fmt.Errorf("invalid resources format")
}
func checkCachingCondition(clusters []types.ClusterInfo, specs []*collector.ResourceSpec) bool {
var count int
for _, spec := range specs {

View File

@ -3,6 +3,7 @@ package schedule
import (
"context"
"fmt"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/entity"
"slices"
"strings"
"time"
@ -26,11 +27,6 @@ const (
QUERY_RESOURCE_RETRY = 3
)
type ClustersWithDataDistributes struct {
Clusters []*strategy.AssignedCluster
DataDistributes *types.DataDistribute
}
type ScheduleCreateTaskLogic struct {
logx.Logger
ctx context.Context
@ -47,14 +43,18 @@ func NewScheduleCreateTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
}
func generateFilteredDataDistributes(clusters []*strategy.AssignedCluster, distribute types.DataDistribute) *ClustersWithDataDistributes {
func (l *ScheduleCreateTaskLogic) generateFilteredDataDistributes(clusters []*strategy.AssignedCluster, distribute types.DataDistribute) *entity.ClustersWithDataDistributes {
var clusterIds []string
for _, c := range clusters {
clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(c.ClusterId)
if clusterName != "" {
c.ClusterName = clusterName
}
clusterIds = append(clusterIds, c.ClusterId)
}
clustersWithDataDistributes := &ClustersWithDataDistributes{
clustersWithDataDistributes := &entity.ClustersWithDataDistributes{
Clusters: clusters,
DataDistributes: &types.DataDistribute{
Dataset: make([]*types.DatasetDistribute, 0),
@ -166,7 +166,7 @@ func (l *ScheduleCreateTaskLogic) ScheduleCreateTask(req *types.CreateTaskReq) (
}}, req.JobResources.Clusters, "")
// filter data distribution
clustersWithDataDistributes := generateFilteredDataDistributes(assignedClusters, req.DataDistributes)
clustersWithDataDistributes := l.generateFilteredDataDistributes(assignedClusters, req.DataDistributes)
taskId, err := l.createTask(taskName, req.Description, req.UserId, req.JobResources.ScheduleStrategy, clustersWithDataDistributes, req.Token, req.UserIp, req.UserName)
if err != nil {
@ -197,7 +197,7 @@ func (l *ScheduleCreateTaskLogic) ScheduleCreateTask(req *types.CreateTaskReq) (
}
// filter data distribution
clustersWithDataDistributes := generateFilteredDataDistributes(assignedClusters, req.DataDistributes)
clustersWithDataDistributes := l.generateFilteredDataDistributes(assignedClusters, req.DataDistributes)
taskId, err := l.createTask(taskName, req.Description, req.UserId, req.JobResources.ScheduleStrategy, clustersWithDataDistributes, req.Token, req.UserIp, req.UserName)
if err != nil {
@ -263,7 +263,7 @@ func (l *ScheduleCreateTaskLogic) getAssignedClustersByStrategy(resources *types
return assignedClusters, nil
}
func (l *ScheduleCreateTaskLogic) createTask(taskName string, desc string, userId int64, strategyName string, clustersWithDataDistributes *ClustersWithDataDistributes, token string, userIp string, userName string) (int64, error) {
func (l *ScheduleCreateTaskLogic) createTask(taskName string, desc string, userId int64, strategyName string, clustersWithDataDistributes *entity.ClustersWithDataDistributes, token string, userIp string, userName string) (int64, error) {
var synergyStatus int64
if len(clustersWithDataDistributes.Clusters) > 1 {
synergyStatus = 1
@ -397,11 +397,11 @@ func (l *ScheduleCreateTaskLogic) updateStorageType(schedatas *[]*types.Schedule
var storageType string
var sTypes []string
for _, id := range s.ClusterIDs {
cluster, err := l.svcCtx.Scheduler.AiStorages.GetClustersById(id)
cluster, err := l.svcCtx.Scheduler.AiStorages.GetStorageScheduledClustersById(id)
if err != nil {
return err
}
stype, ok := storeLink.StorageTypeMap[strings.Title(cluster.Name)]
stype, ok := storeLink.StorageTypeMap[strings.Title(cluster.Driver)]
if ok {
sTypes = append(sTypes, stype)
}

View File

@ -2,6 +2,9 @@ package schedule
import (
"context"
"errors"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
"strconv"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
@ -26,15 +29,51 @@ func NewScheduleGetAiJobLogLogLogic(ctx context.Context, svcCtx *svc.ServiceCont
func (l *ScheduleGetAiJobLogLogLogic) ScheduleGetAiJobLogLog(req *types.AiJobLogReq) (resp *types.AiJobLogResp, err error) {
resp = &types.AiJobLogResp{}
id, err := l.svcCtx.Scheduler.AiStorages.GetAiTaskIdByClusterIdAndTaskId(req.ClusterId, req.TaskId)
taskId, err := strconv.ParseInt(req.TaskId, 10, 64)
if err != nil {
return nil, err
}
log, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].GetTrainingTaskLog(l.ctx, id, req.InstanceNum)
task, err := l.svcCtx.Scheduler.AiStorages.GetTaskById(taskId)
if err != nil {
return nil, err
}
resp.Log = log
aiTasks, err := l.svcCtx.Scheduler.AiStorages.GetAiTasksByTaskId(req.TaskId)
if err != nil {
return nil, err
}
if len(aiTasks) == 0 && task.Status == constants.Failed {
return nil, errors.New("submit failed, no log available")
} else if len(aiTasks) > 1 {
return nil, errors.New("multiple ai task found")
}
aiTask := aiTasks[0]
//adapterId := strconv.FormatInt(aiTask.AdapterId, 10)
clusterId := strconv.FormatInt(aiTask.ClusterId, 10)
if aiTask.Msg != "" {
resp.Log = aiTask.Msg
return resp, nil
}
jobId := aiTask.JobId
log, err := l.svcCtx.Scheduler.AiService.Ai.TaskLog(clusterId, jobId)
if err != nil {
return nil, err
}
if log.Code != 200 {
return nil, errors.New(log.Message)
}
str, ok := log.Data.(string)
if ok {
resp.Log = str
} else {
return nil, errors.New("not a string")
}
return resp, nil
}

View File

@ -5,18 +5,19 @@ import (
"encoding/json"
"errors"
"fmt"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/executor"
"strings"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/entity"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/executor"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"gopkg.in/yaml.v2"
"strings"
)
type ScheduleRunTaskLogic struct {
@ -59,25 +60,39 @@ func (l *ScheduleRunTaskLogic) ScheduleRunTask(req *types.RunTaskReq) (resp *typ
}
}
var clustersWithDataDistributes ClustersWithDataDistributes
var clustersWithDataDistributes entity.ClustersWithDataDistributes
err = yaml.Unmarshal([]byte(task.YamlString), &clustersWithDataDistributes)
if err != nil {
return nil, err
}
opt := &option.AiOption{
AdapterId: ADAPTERID,
TaskName: task.Name,
TaskId: task.Id,
StrategyName: "",
}
// update assignedClusters
assignedClusters, err := updateClustersByScheduledDatas(task.Id, &clustersWithDataDistributes, req.ScheduledDatas)
if err != nil {
opt := &option.AiOption{
AdapterId: l.svcCtx.Config.Participant.AdapterId,
TaskName: task.Name,
TaskId: task.Id,
StrategyName: "",
ResourcesRequired: clustersWithDataDistributes.Clusters[0].ResourcesRequired,
}
clusterId := clustersWithDataDistributes.Clusters[0].ClusterId
clusterName := clustersWithDataDistributes.Clusters[0].ClusterName
err = l.svcCtx.Scheduler.AiStorages.SaveAiTask(task.Id, opt, "", clusterId, clusterName, "", constants.Failed, err.Error())
if err != nil {
return nil, err
}
return nil, err
}
opt := &option.AiOption{
AdapterId: ADAPTERID,
TaskName: task.Name,
TaskId: task.Id,
StrategyName: "",
ResourcesRequired: clustersWithDataDistributes.Clusters[0].ResourcesRequired,
}
aiSchdl, err := schedulers.NewAiScheduler(l.ctx, "", l.svcCtx.Scheduler, opt)
if err != nil {
return nil, err
@ -126,7 +141,7 @@ func (l *ScheduleRunTaskLogic) SaveResult(task *models.Task, results []*schedule
}
func updateClustersByScheduledDatas(taskId int64, clustersWithDataDistributes *ClustersWithDataDistributes, scheduledDatas []*types.DataScheduleResults) ([]*strategy.AssignedCluster, error) {
func updateClustersByScheduledDatas(taskId int64, clustersWithDataDistributes *entity.ClustersWithDataDistributes, scheduledDatas []*types.DataScheduleResults) ([]*strategy.AssignedCluster, error) {
assignedClusters := make([]*strategy.AssignedCluster, 0)
if len(scheduledDatas) == 0 {
@ -154,6 +169,7 @@ func updateClustersByScheduledDatas(taskId int64, clustersWithDataDistributes *C
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype: %s", taskId, cluster.ClusterId, "dataset")
}
cluster.DatasetId = jsonData.Id
cluster.DatasetName = jsonData.Name
}
}
}
@ -192,6 +208,7 @@ func updateClustersByScheduledDatas(taskId int64, clustersWithDataDistributes *C
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype: %s", taskId, cluster.ClusterId, "code")
}
cluster.CodeId = jsonData.Id
cluster.CodeName = jsonData.Name
}
}
}
@ -235,6 +252,7 @@ func updateClustersByScheduledDatas(taskId int64, clustersWithDataDistributes *C
return nil, fmt.Errorf("db yaml jsonData convert failed, task %d, cluster %s, datatype: %s", taskId, cluster.ClusterId, "dataset")
}
cluster.DatasetId = jsonData.Id
cluster.DatasetName = jsonData.Name
}
}
}
@ -275,6 +293,7 @@ func updateClustersByScheduledDatas(taskId int64, clustersWithDataDistributes *C
return nil, fmt.Errorf("db yaml jsonData convert failed, task %d, cluster %s, datatype: %s", taskId, cluster.ClusterId, "code")
}
cluster.CodeId = jsonData.Id
cluster.CodeName = jsonData.Name
}
}
@ -293,7 +312,7 @@ func updateClustersByScheduledDatas(taskId int64, clustersWithDataDistributes *C
if err != nil {
return nil, fmt.Errorf("jsonData convert failed, task %d, cluster %s, datatype: %s", taskId, cluster.ClusterId, "model")
}
cluster.ModelId = jsonData.Id
cluster.ModelId += jsonData.Id + ";"
}
}
}

View File

@ -0,0 +1,33 @@
package security
import "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
func SanitizeClusterSecret(cluster *types.ClusterInfo) {
if cluster == nil {
return
}
cluster.Username = ""
cluster.Password = ""
cluster.Token = ""
cluster.Ak = ""
cluster.Sk = ""
cluster.PrivateKey = ""
cluster.Passphrase = ""
}
func SanitizeClusterSecretList(clusters []types.ClusterInfo) {
for i := range clusters {
SanitizeClusterSecret(&clusters[i])
}
}
func SanitizeClusterRelationSecret(info *types.ClusterRelationInfo) {
if info == nil {
return
}
info.CUsername = ""
info.CPassword = ""
info.CToken = ""
info.CAk = ""
info.CSk = ""
}

View File

@ -1,40 +0,0 @@
package storage
import (
"context"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils"
"k8s.io/apimachinery/pkg/util/json"
"strings"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type DailyPowerScreenLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewDailyPowerScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DailyPowerScreenLogic {
return &DailyPowerScreenLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *DailyPowerScreenLogic) DailyPowerScreen() (resp *types.DailyPowerScreenResp, err error) {
resp = &types.DailyPowerScreenResp{}
statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/dailytrend", strings.NewReader(``))
if statusCode == 200 {
json.Unmarshal(body, &resp.Chart)
println(resp)
} else if statusCode != 200 {
return nil, err
}
return resp, nil
}

View File

@ -1,39 +0,0 @@
package storage
import (
"context"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils"
"k8s.io/apimachinery/pkg/util/json"
"strings"
"github.com/zeromicro/go-zero/core/logx"
)
type PerCenterComputerPowersLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewPerCenterComputerPowersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerCenterComputerPowersLogic {
return &PerCenterComputerPowersLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *PerCenterComputerPowersLogic) PerCenterComputerPowers() (resp *types.PerCenterComputerPowersResp, err error) {
resp = &types.PerCenterComputerPowersResp{}
statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/percenter", strings.NewReader(``))
if statusCode == 200 {
json.Unmarshal(body, &resp.Chart)
println(resp)
} else if statusCode != 200 {
return nil, err
}
return resp, nil
}

View File

@ -1,30 +0,0 @@
package storage
import (
"context"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type ScreenStorageLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewScreenStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScreenStorageLogic {
return &ScreenStorageLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ScreenStorageLogic) ScreenStorage(req *types.StorageScreenReq) (resp *types.StorageScreenResp, err error) {
// todo: add your logic here and delete this line
return
}

View File

@ -0,0 +1,167 @@
package xjlab
import (
"context"
"fmt"
"strings"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
)
type ComputeDomainInfoLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
hpcService *service.HpcService
}
func NewComputeDomainInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ComputeDomainInfoLogic {
cache := make(map[string]interface{}, 10)
hpcService, err := service.NewHpcService(&svcCtx.Config, svcCtx.Scheduler.HpcStorages, cache)
if err != nil {
return nil
}
return &ComputeDomainInfoLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
hpcService: hpcService,
}
}
// ComputeDomainInfo 计算域信息
func (l *ComputeDomainInfoLogic) ComputeDomainInfo(req *types.XJLABCommonReq) (interface{}, error) {
logx.Infof("ComputeDomainInfo req: %+v", req)
// ClusterResource 集群资源信息
type ClusterResource struct {
ClusterID string `json:"clusterId"`
ClusterName string `json:"clusterName"`
TotalCPU string `json:"totalCpu"`
TotalRAM string `json:"totalRam"`
TotalVRAM string `json:"totalVram"`
TotalDisk string `json:"totalDisk"`
SpecCount string `json:"specCount"`
Driver string `json:"driver"`
ClusterType string `json:"clusterType"`
}
// resourceQueryResult SQL查询结果
type resourceQueryResult struct {
ClusterID string `json:"clusterId" gorm:"column:cluster_id"`
ResourceType string `json:"resourceType" gorm:"column:resource_type"`
ResourceName string `json:"resourceName" gorm:"column:resource_name"`
Unit string `json:"unit" gorm:"column:unit"`
TotalCapacity string `json:"totalCapacity" gorm:"column:total_capacity"`
SpecCount string `json:"specCount" gorm:"column:spec_count"`
}
// clusterInfo 集群基本信息
type clusterInfo struct {
ID string `json:"id" gorm:"column:id"`
Name string `json:"name" gorm:"column:name"`
Driver string `json:"driver" gorm:"column:driver"`
ClusterType string `json:"clusterType" gorm:"column:cluster_type"`
}
// 查询资源信息
const sqlStr = `
SELECT
rs.cluster_id,
brs.type as resource_type,
brs.name as resource_name,
brs.total_unit as unit,
SUM(brs.total_value) as total_capacity,
COUNT(DISTINCT rs.id) as spec_count
FROM t_resource_spec rs
INNER JOIN t_base_resource_spec brs ON rs.id = brs.resource_spec_id
WHERE rs.deleted_at IS NULL
AND brs.deleted_at IS NULL
AND rs.change_type != 2
GROUP BY rs.cluster_id, brs.type, brs.name, brs.total_unit
ORDER BY rs.cluster_id, brs.name`
var resources []*resourceQueryResult
if err := l.svcCtx.DbEngin.Raw(sqlStr).Scan(&resources).Error; err != nil {
logx.Errorf("failed to query resource specs: %v", err)
return nil, fmt.Errorf("查询资源规格失败: %w", err)
}
if len(resources) == 0 {
return []*ClusterResource{}, nil
}
// 聚合每个集群的资源信息
clusterMap := make(map[string]*ClusterResource)
for _, res := range resources {
cr, exists := clusterMap[res.ClusterID]
if !exists {
cr = &ClusterResource{
ClusterID: res.ClusterID,
TotalCPU: "0",
TotalRAM: "0",
TotalVRAM: "0",
TotalDisk: "0",
SpecCount: "0",
}
clusterMap[res.ClusterID] = cr
}
// 设置资源值
resourceType := strings.ToUpper(res.ResourceType)
resourceName := strings.ToUpper(res.ResourceName)
switch resourceType {
case "CPU":
cr.TotalCPU = res.TotalCapacity
case "MEMORY":
if resourceName == "RAM" {
cr.TotalRAM = res.TotalCapacity
} else if resourceName == "VRAM" {
cr.TotalVRAM = res.TotalCapacity
}
case "STORAGE":
cr.TotalDisk = res.TotalCapacity
}
cr.SpecCount = res.SpecCount
}
// 获取集群基本信息
clusterIDs := make([]string, 0, len(clusterMap))
for clusterID := range clusterMap {
clusterIDs = append(clusterIDs, clusterID)
}
var clusterList []*clusterInfo
if len(clusterIDs) > 0 {
err := l.svcCtx.DbEngin.
Table("t_cluster").
Select("id, name, driver, cluster_type").
Where("id IN ?", clusterIDs).
Find(&clusterList).Error
if err != nil {
logx.Errorf("failed to query cluster info: %v", err)
return nil, fmt.Errorf("获取集群信息失败: %w", err)
}
}
// 更新集群名称等信息
for _, cl := range clusterList {
if cr, exists := clusterMap[cl.ID]; exists {
cr.ClusterName = cl.Name
cr.Driver = cl.Driver
cr.ClusterType = cl.ClusterType
}
}
// 转换为结果列表
result := make([]*ClusterResource, 0, len(clusterMap))
for _, cr := range clusterMap {
result = append(result, cr)
}
return result, nil
}

Some files were not shown because too many files have changed in this diff Show More