From 5051e4aebdbb51575fa77bf472f4ee4ce03dfd0c Mon Sep 17 00:00:00 2001 From: "Bo-Yi.Wu" Date: Sun, 4 Sep 2022 15:19:07 +0800 Subject: [PATCH] chore(runtime): check error message data lock by another runner. Signed-off-by: Bo-Yi.Wu --- runtime/runtime.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/runtime/runtime.go b/runtime/runtime.go index 41f620c..16e1302 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -2,6 +2,7 @@ package runtime import ( "context" + "errors" "fmt" "gitea.com/gitea/act_runner/client" @@ -10,6 +11,8 @@ import ( log "github.com/sirupsen/logrus" ) +var ErrDataLock = errors.New("Data Lock Error") + // Defines the Resource Kind and Type. const ( Kind = "pipeline" @@ -36,10 +39,14 @@ func (s *Runner) Run(ctx context.Context, stage *runnerv1.Stage) error { data, err := s.Client.Detail(ctx, &runnerv1.DetailRequest{ Stage: stage, }) - if err != nil { - l.Debug("stage accepted by another runner") + if err != nil && err == ErrDataLock { + l.Info("stage accepted by another runner") return nil } + if err != nil { + l.WithError(err).Error("cannot accept stage") + return err + } l = log.WithField("repo.id", data.Repo.Id). WithField("repo.name", data.Repo.Name).