mirror of
https://gitea.com/gitea/act_runner.git
synced 2024-11-10 04:37:22 +01:00
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:
parent
d3d56ed0ef
commit
5051e4aebd
@ -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).
|
||||
|
Loading…
Reference in New Issue
Block a user