Merge pull request 'updated cron function' (#313) from tzwang/pcm-coordinator:master into master

This commit is contained in:
tzwang 2024-09-18 17:37:48 +08:00
commit 32bc8b11fe
4 changed files with 10 additions and 10 deletions

2
go.mod
View File

@ -18,7 +18,7 @@ require (
github.com/prometheus/common v0.59.1 github.com/prometheus/common v0.59.1
github.com/robfig/cron/v3 v3.0.1 github.com/robfig/cron/v3 v3.0.1
github.com/zeromicro/go-zero v1.7.2 github.com/zeromicro/go-zero v1.7.2
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240725071305-f751eec4dde1 gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240918015229-59c579d1a437
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240909072501-939c3144cd9e gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240909072501-939c3144cd9e
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110 gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203

4
go.sum
View File

@ -466,8 +466,8 @@ github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
github.com/zeromicro/go-zero v1.7.2 h1:a8lyVOG3KXG4LrAy6ZmtJTJtisX4Ostc4Pst4fE704I= github.com/zeromicro/go-zero v1.7.2 h1:a8lyVOG3KXG4LrAy6ZmtJTJtisX4Ostc4Pst4fE704I=
github.com/zeromicro/go-zero v1.7.2/go.mod h1:WFXfF92Exw0O7WECifS6r99JSzv4KEN49x9RhAfgkMc= github.com/zeromicro/go-zero v1.7.2/go.mod h1:WFXfF92Exw0O7WECifS6r99JSzv4KEN49x9RhAfgkMc=
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240725071305-f751eec4dde1 h1:DicBXoQiC6mumMBeyqSPNrsjtqJIgk5Pv2hscu2xryw= gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240918015229-59c579d1a437 h1:ta6h9+FU7AQ2fNyQiXrZnMdlNBjOKdyBx4e3RF7BE84=
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240725071305-f751eec4dde1/go.mod h1:3eECiw9O2bIFkkePlloKyLNXiqBAhOxNrDoGaaGseGY= gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240918015229-59c579d1a437/go.mod h1:3eECiw9O2bIFkkePlloKyLNXiqBAhOxNrDoGaaGseGY=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240909072501-939c3144cd9e h1:6LYJggBoeAQxy/otzWjt40Pa7gnVvUR4c5YMi6A/NdU= gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240909072501-939c3144cd9e h1:6LYJggBoeAQxy/otzWjt40Pa7gnVvUR4c5YMi6A/NdU=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240909072501-939c3144cd9e/go.mod h1:/eOmBFZKWGoabG3sRVkVvIbLwsd2631k4jkUBR6x1AA= gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240909072501-939c3144cd9e/go.mod h1:/eOmBFZKWGoabG3sRVkVvIbLwsd2631k4jkUBR6x1AA=
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110 h1:GaXwr5sgDh0raHjUf9IewTvnRvajYea7zbLsaerYyXo= gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110 h1:GaXwr5sgDh0raHjUf9IewTvnRvajYea7zbLsaerYyXo=

View File

@ -37,7 +37,7 @@ func AddCronGroup(svc *svc.ServiceContext) {
UpdateAiAdapterMaps(svc) UpdateAiAdapterMaps(svc)
}) })
svc.Cron.AddFunc("*/59 * * * * ?", func() { svc.Cron.AddFunc("30 * * * * ?", func() {
adapterList, err := svc.Scheduler.AiStorages.GetAdaptersByType("1") adapterList, err := svc.Scheduler.AiStorages.GetAdaptersByType("1")
if err != nil { if err != nil {
logx.Errorf(err.Error()) logx.Errorf(err.Error())

View File

@ -290,22 +290,22 @@ func (i *ImageInference) updateStatus(aiTaskList []*models.TaskAi, cs []*Filtere
//change cluster status //change cluster status
if len(i.clusters) != len(cs) { if len(i.clusters) != len(cs) {
var acs []*strategy.AssignedCluster var failedclusters []*strategy.AssignedCluster
var rcs []*strategy.AssignedCluster var runningclusters []*strategy.AssignedCluster
for _, cluster := range i.clusters { for _, cluster := range i.clusters {
if contains(cs, cluster.ClusterId) { if contains(cs, cluster.ClusterId) {
var ac *strategy.AssignedCluster var ac *strategy.AssignedCluster
ac = cluster ac = cluster
rcs = append(rcs, ac) runningclusters = append(runningclusters, ac)
} else { } else {
var ac *strategy.AssignedCluster var ac *strategy.AssignedCluster
ac = cluster ac = cluster
acs = append(acs, ac) failedclusters = append(failedclusters, ac)
} }
} }
// update failed cluster status // update failed cluster status
for _, ac := range acs { for _, ac := range failedclusters {
for _, t := range aiTaskList { for _, t := range aiTaskList {
if ac.ClusterId == strconv.Itoa(int(t.ClusterId)) { if ac.ClusterId == strconv.Itoa(int(t.ClusterId)) {
t.Status = constants.Failed t.Status = constants.Failed
@ -322,7 +322,7 @@ func (i *ImageInference) updateStatus(aiTaskList []*models.TaskAi, cs []*Filtere
} }
// update running cluster status // update running cluster status
for _, ac := range rcs { for _, ac := range runningclusters {
for _, t := range aiTaskList { for _, t := range aiTaskList {
if ac.ClusterId == strconv.Itoa(int(t.ClusterId)) { if ac.ClusterId == strconv.Itoa(int(t.ClusterId)) {
t.Status = constants.Running t.Status = constants.Running