From 5104009600966238f43091f3a855fa0b15f119bf Mon Sep 17 00:00:00 2001 From: tzwang Date: Mon, 9 Sep 2024 16:36:15 +0800 Subject: [PATCH] fix stopall startall logic Former-commit-id: ca3b3a57bdb722e48731f0a8e49e250277c52175 --- internal/logic/inference/startallbydeploytaskidlogic.go | 7 ++++++- internal/logic/inference/stopallbydeploytaskidlogic.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/logic/inference/startallbydeploytaskidlogic.go b/internal/logic/inference/startallbydeploytaskidlogic.go index 5074d1f5..d78f98b9 100644 --- a/internal/logic/inference/startallbydeploytaskidlogic.go +++ b/internal/logic/inference/startallbydeploytaskidlogic.go @@ -82,6 +82,7 @@ func (l *StartAllByDeployTaskIdLogic) startAll(list []*models.AiInferDeployInsta errCh <- e wg.Done() <-buf + return } if checkStopStatus(in) { success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].StartInferDeployInstance(l.ctx, ins.InstanceId) @@ -100,11 +101,15 @@ func (l *StartAllByDeployTaskIdLogic) startAll(list []*models.AiInferDeployInsta errCh <- e wg.Done() <-buf + return } } + wg.Done() + <-buf }() - <-buf } + wg.Wait() + close(errCh) for e := range errCh { errs = append(errs, e) diff --git a/internal/logic/inference/stopallbydeploytaskidlogic.go b/internal/logic/inference/stopallbydeploytaskidlogic.go index d4cc2b36..c6eaad01 100644 --- a/internal/logic/inference/stopallbydeploytaskidlogic.go +++ b/internal/logic/inference/stopallbydeploytaskidlogic.go @@ -83,6 +83,7 @@ func (l *StopAllByDeployTaskIdLogic) stopAll(list []*models.AiInferDeployInstanc errCh <- e wg.Done() <-buf + return } if checkStatus(in) { success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].StopInferDeployInstance(l.ctx, ins.InstanceId) @@ -101,11 +102,15 @@ func (l *StopAllByDeployTaskIdLogic) stopAll(list []*models.AiInferDeployInstanc errCh <- e wg.Done() <-buf + return } } + wg.Done() + <-buf }() - <-buf } + wg.Wait() + close(errCh) for e := range errCh { errs = append(errs, e)