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.

startallbydeploytaskidlogic.go 2.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package inference
  2. import (
  3. "context"
  4. "errors"
  5. "github.com/zeromicro/go-zero/core/logx"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/inference"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  9. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  10. "strconv"
  11. )
  12. type StartAllByDeployTaskIdLogic struct {
  13. logx.Logger
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. }
  17. func NewStartAllByDeployTaskIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StartAllByDeployTaskIdLogic {
  18. return &StartAllByDeployTaskIdLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. }
  23. }
  24. func (l *StartAllByDeployTaskIdLogic) StartAllByDeployTaskId(req *types.StartAllByDeployTaskIdReq) (resp *types.StartAllByDeployTaskIdResp, err error) {
  25. resp = &types.StartAllByDeployTaskIdResp{}
  26. id, err := strconv.ParseInt(req.Id, 10, 64)
  27. list, err := l.svcCtx.Scheduler.AiStorages.GetInstanceListByDeployTaskId(id)
  28. if err != nil {
  29. return nil, err
  30. }
  31. for _, ins := range list {
  32. in, err := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].GetInferDeployInstance(l.ctx, ins.InstanceId)
  33. if err != nil {
  34. return nil, err
  35. }
  36. if checkStopStatus(in) {
  37. success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].StartInferDeployInstance(l.ctx, ins.InstanceId)
  38. if !success {
  39. return nil, errors.New(ins.InstanceName + " start failed")
  40. }
  41. }
  42. }
  43. err = l.svcCtx.Scheduler.AiStorages.UpdateDeployTaskById(id)
  44. if err != nil {
  45. return nil, err
  46. }
  47. return resp, nil
  48. }
  49. func checkStopStatus(in *inference.DeployInstance) bool {
  50. switch in.ClusterType {
  51. case storeLink.TYPE_OCTOPUS:
  52. switch in.Status {
  53. case "stopped":
  54. return true
  55. default:
  56. return false
  57. }
  58. case storeLink.TYPE_MODELARTS:
  59. switch in.Status {
  60. case "stopped":
  61. return true
  62. default:
  63. return false
  64. }
  65. case storeLink.TYPE_SHUGUANGAI:
  66. switch in.Status {
  67. case "Terminated":
  68. return true
  69. default:
  70. return false
  71. }
  72. default:
  73. return false
  74. }
  75. }

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.