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

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

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.