From 1f868c58c4479daaeb8fba163a04c872f10cc0e3 Mon Sep 17 00:00:00 2001 From: tzwang Date: Sat, 27 Jul 2024 15:07:19 +0800 Subject: [PATCH] fix deployinstance status Former-commit-id: 8e34db70114d86c5da2e5548e7046f1b2e8f04ae --- internal/logic/inference/startdeployinstancelistlogic.go | 2 -- internal/logic/inference/stopdeployinstancelogic.go | 2 -- internal/scheduler/database/aiStorage.go | 6 ++++-- internal/scheduler/service/updater/deployInstance.go | 8 +++----- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/internal/logic/inference/startdeployinstancelistlogic.go b/internal/logic/inference/startdeployinstancelistlogic.go index 8712a511..4b762e0f 100644 --- a/internal/logic/inference/startdeployinstancelistlogic.go +++ b/internal/logic/inference/startdeployinstancelistlogic.go @@ -33,8 +33,6 @@ func (l *StartDeployInstanceListLogic) StartDeployInstanceList(req *types.StartD return nil, err } - l.svcCtx.Scheduler.AiStorages.UpdateInferDeployInstance(ins) - success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[req.AdapterId][req.ClusterId].StartInferDeployInstance(l.ctx, req.InstanceId) if !success { return nil, errors.New("start instance failed") diff --git a/internal/logic/inference/stopdeployinstancelogic.go b/internal/logic/inference/stopdeployinstancelogic.go index ab2f863b..919e6aa4 100644 --- a/internal/logic/inference/stopdeployinstancelogic.go +++ b/internal/logic/inference/stopdeployinstancelogic.go @@ -33,8 +33,6 @@ func (l *StopDeployInstanceLogic) StopDeployInstance(req *types.StopDeployInstan return nil, err } - l.svcCtx.Scheduler.AiStorages.UpdateInferDeployInstance(ins) - success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[req.AdapterId][req.ClusterId].StopInferDeployInstance(l.ctx, req.InstanceId) if !success { return nil, errors.New("stop instance failed") diff --git a/internal/scheduler/database/aiStorage.go b/internal/scheduler/database/aiStorage.go index 75fba086..421bcc42 100644 --- a/internal/scheduler/database/aiStorage.go +++ b/internal/scheduler/database/aiStorage.go @@ -399,8 +399,10 @@ func (s *AiStorage) SaveInferDeployInstance(instanceId string, instanceName stri return insModel.Id, nil } -func (s *AiStorage) UpdateInferDeployInstance(instance *models.AiInferDeployInstance) error { - instance.UpdateTime = time.Now().Format(time.RFC3339) +func (s *AiStorage) UpdateInferDeployInstance(instance *models.AiInferDeployInstance, needUpdateTime bool) error { + if needUpdateTime { + instance.UpdateTime = time.Now().Format(time.RFC3339) + } tx := s.DbEngin.Table("ai_infer_deploy_instance").Updates(instance) if tx.Error != nil { logx.Errorf(tx.Error.Error()) diff --git a/internal/scheduler/service/updater/deployInstance.go b/internal/scheduler/service/updater/deployInstance.go index e4444b51..94e08b0d 100644 --- a/internal/scheduler/service/updater/deployInstance.go +++ b/internal/scheduler/service/updater/deployInstance.go @@ -71,10 +71,8 @@ func UpdateDeployInstanceStatus(svc *svc.ServiceContext, instance *models.AiInfe } } - if updatetime { - err = svc.Scheduler.AiStorages.UpdateInferDeployInstance(instance) - if err != nil { - return - } + err = svc.Scheduler.AiStorages.UpdateInferDeployInstance(instance, updatetime) + if err != nil { + return } }