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.

stopdeployinstancelogic.go 1.5 kB

5 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/svc"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  8. "strconv"
  9. )
  10. type StopDeployInstanceLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewStopDeployInstanceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StopDeployInstanceLogic {
  16. return &StopDeployInstanceLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *StopDeployInstanceLogic) StopDeployInstance(req *types.StopDeployInstanceReq) (resp *types.StopDeployInstanceResp, err error) {
  23. resp = &types.StopDeployInstanceResp{}
  24. id, err := strconv.ParseInt(req.Id, 10, 64)
  25. ins, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceById(id)
  26. if err != nil {
  27. return nil, err
  28. }
  29. in, err := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].GetInferDeployInstance(l.ctx, ins.InstanceId)
  30. if err != nil {
  31. return nil, err
  32. }
  33. if l.svcCtx.Scheduler.AiService.Si.CheckRunningStatus(in) {
  34. success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[req.AdapterId][req.ClusterId].StopInferDeployInstance(l.ctx, in.InstanceId)
  35. if !success {
  36. return nil, errors.New("stop instance failed")
  37. }
  38. }
  39. ins.Status = "Updating"
  40. err = l.svcCtx.Scheduler.AiStorages.UpdateInferDeployInstance(ins, true)
  41. if err != nil {
  42. return nil, err
  43. }
  44. return resp, nil
  45. }

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.