chore(runtime): check error message

data lock by another runner.

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
pull/2/head
Bo-Yi.Wu 2022-09-04 15:19:07 +08:00 committed by Jason Song
parent d3d56ed0ef
commit 5051e4aebd
1 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package runtime
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"gitea.com/gitea/act_runner/client" "gitea.com/gitea/act_runner/client"
@ -10,6 +11,8 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
var ErrDataLock = errors.New("Data Lock Error")
// Defines the Resource Kind and Type. // Defines the Resource Kind and Type.
const ( const (
Kind = "pipeline" 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{ data, err := s.Client.Detail(ctx, &runnerv1.DetailRequest{
Stage: stage, Stage: stage,
}) })
if err != nil { if err != nil && err == ErrDataLock {
l.Debug("stage accepted by another runner") l.Info("stage accepted by another runner")
return nil return nil
} }
if err != nil {
l.WithError(err).Error("cannot accept stage")
return err
}
l = log.WithField("repo.id", data.Repo.Id). l = log.WithField("repo.id", data.Repo.Id).
WithField("repo.name", data.Repo.Name). WithField("repo.name", data.Repo.Name).