chore(runner): update runner status when start job
This commit is contained in:
parent
d4c1515f4e
commit
7bebd2bbad
@ -16,8 +16,10 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const errorRetryCounterLimit = 3
|
const (
|
||||||
const errorRetryTimeSleepSecs = 30
|
errorRetryCounterLimit = 3
|
||||||
|
errorRetryTimeSleepSecs = 30
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrDataLock = errors.New("Data Lock Error")
|
ErrDataLock = errors.New("Data Lock Error")
|
||||||
|
@ -170,15 +170,12 @@ func (r *Reporter) Close(lastWords string) error {
|
|||||||
}
|
}
|
||||||
r.stateM.Unlock()
|
r.stateM.Unlock()
|
||||||
|
|
||||||
if err := retry.Do(func() error {
|
return retry.Do(func() error {
|
||||||
if err := r.ReportLog(true); err != nil {
|
if err := r.ReportLog(true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return r.ReportState()
|
return r.ReportState()
|
||||||
}, retry.Context(r.ctx)); err != nil {
|
}, retry.Context(r.ctx))
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reporter) ReportLog(noMore bool) error {
|
func (r *Reporter) ReportLog(noMore bool) error {
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"gitea.com/gitea/act_runner/client"
|
"gitea.com/gitea/act_runner/client"
|
||||||
runnerv1 "gitea.com/gitea/proto-go/runner/v1"
|
runnerv1 "gitea.com/gitea/proto-go/runner/v1"
|
||||||
|
|
||||||
|
"github.com/bufbuild/connect-go"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,5 +23,30 @@ func (s *Runner) Run(ctx context.Context, task *runnerv1.Task) error {
|
|||||||
WithField("task.id", task.Id)
|
WithField("task.id", task.Id)
|
||||||
l.Info("start running pipeline")
|
l.Info("start running pipeline")
|
||||||
|
|
||||||
|
// update runner status
|
||||||
|
// running: idle -> active
|
||||||
|
// stopped: active -> idle
|
||||||
|
if _, err := s.Client.UpdateRunner(
|
||||||
|
ctx,
|
||||||
|
connect.NewRequest(&runnerv1.UpdateRunnerRequest{
|
||||||
|
Status: runnerv1.RunnerStatus_RUNNER_STATUS_ACTIVE,
|
||||||
|
}),
|
||||||
|
); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
l.Info("update runner status to active")
|
||||||
|
defer func() {
|
||||||
|
if _, err := s.Client.UpdateRunner(
|
||||||
|
ctx,
|
||||||
|
connect.NewRequest(&runnerv1.UpdateRunnerRequest{
|
||||||
|
Status: runnerv1.RunnerStatus_RUNNER_STATUS_IDLE,
|
||||||
|
}),
|
||||||
|
); err != nil {
|
||||||
|
log.Errorln("update status error:", err.Error())
|
||||||
|
}
|
||||||
|
l.Info("update runner status to idle")
|
||||||
|
}()
|
||||||
|
|
||||||
return NewTask(task.Id, s.Client).Run(ctx, task)
|
return NewTask(task.Id, s.Client).Run(ctx, task)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user