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
1 changed files with 9 additions and 2 deletions
|
@ -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).
|
||||||
|
|
Loading…
Reference in a new issue