You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cron.go 2.6 kB

7 months ago
4 months ago
10 months ago
10 months ago
10 months ago
4 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. Copyright (c) [2023] [pcm]
  3. [pcm-coordinator] is licensed under Mulan PSL v2.
  4. You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. You may obtain a copy of Mulan PSL v2 at:
  6. http://license.coscl.org.cn/MulanPSL2
  7. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. See the Mulan PSL v2 for more details.
  11. */
  12. package cron
  13. import (
  14. "github.com/zeromicro/go-zero/core/logx"
  15. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule"
  16. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/utils/status"
  17. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  18. )
  19. func AddCronGroup(svc *svc.ServiceContext) {
  20. svc.Cron.AddFunc("*/5 * * * * ?", func() {
  21. UpdateAiAdapterMaps(svc)
  22. })
  23. //svc.Cron.AddFunc("30 * * * * ?", func() {
  24. // adapterList, err := svc.Scheduler.AiStorages.GetAdaptersByType("1")
  25. // if err != nil {
  26. // logx.Errorf(err.Error())
  27. // return
  28. // }
  29. // stat.UpdateClusterResources(svc, adapterList)
  30. //})
  31. svc.Cron.AddFunc("@hourly", func() {
  32. status.UpdateAutoStoppedInstance(svc)
  33. })
  34. svc.Cron.AddFunc("1 * * * * *", func() {
  35. queryResource := schedule.NewQueryResourcesLogic(svc.HttpClient.R().Context(), svc)
  36. trainResrc, err := queryResource.QueryResourcesByClusterId(nil, "Train")
  37. if err != nil {
  38. logx.Error(err)
  39. }
  40. svc.Scheduler.AiService.LocalCache[schedule.QUERY_TRAIN_RESOURCES] = trainResrc
  41. inferResrc, err := queryResource.QueryResourcesByClusterId(nil, "Inference")
  42. if err != nil {
  43. logx.Error(err)
  44. }
  45. svc.Scheduler.AiService.LocalCache[schedule.QUERY_INFERENCE_RESOURCES] = inferResrc
  46. })
  47. //更新hpc任务状态
  48. svc.Cron.AddFunc("*/5 * * * * ?", func() {
  49. status.UpdateHpcTaskStatus(svc)
  50. })
  51. //更新推理任务状态
  52. svc.Cron.AddFunc("*/5 * * * * ?", func() {
  53. tasks, err := svc.Scheduler.AiStorages.GetInferDeployInstanceListLastMonth()
  54. if err != nil {
  55. logx.Error(err)
  56. }
  57. svc.Scheduler.AiService.Si.UpdateDeployInstanceStatusBatch(tasks, true)
  58. })
  59. //更新训练任务状态
  60. svc.Cron.AddFunc("*/10 * * * * ?", func() {
  61. tasks, err := svc.Scheduler.AiStorages.AllTaskLastMonth()
  62. if err != nil {
  63. logx.Error(err)
  64. }
  65. go svc.Scheduler.AiService.St.UpdateTaskStatus(tasks)
  66. go svc.Scheduler.AiService.St.UpdateAiTaskStatus(tasks)
  67. })
  68. svc.Cron.AddFunc("*/30 * * * * ?", func() {
  69. status.UpdateCloudTaskStatus(svc)
  70. })
  71. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.