chore(runtime): check error message

data lock by another runner.

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
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 (
"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).