Skip to content

Commit

Permalink
feat:more for bazel_no_launcher,issue: TencentBlueKing#140
Browse files Browse the repository at this point in the history
  • Loading branch information
tbs60 committed Nov 7, 2023
1 parent b63c60e commit 9d742f3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ func (wp *worksPool) getFirstWork() (*types.Work, error) {
defer wp.RUnlock()

for _, work := range wp.works {
return work, nil
// check whether work is valid
if work.Basic().Info().IsWorking() {
return work, nil
}
}

return nil, types.ErrNoWork
Expand Down
31 changes: 23 additions & 8 deletions src/backend/booster/bk_dist/executor/pkg/dist_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
dcTypes "github.com/TencentBlueKing/bk-turbo/src/backend/booster/bk_dist/common/types"
dcUtil "github.com/TencentBlueKing/bk-turbo/src/backend/booster/bk_dist/common/util"
v1 "github.com/TencentBlueKing/bk-turbo/src/backend/booster/bk_dist/controller/pkg/api/v1"
"github.com/TencentBlueKing/bk-turbo/src/backend/booster/bk_dist/dashboard/pkg/api"
"github.com/TencentBlueKing/bk-turbo/src/backend/booster/common/blog"
)

Expand Down Expand Up @@ -112,7 +113,28 @@ func (d *DistExecutor) Run() (int, string, error) {
}

// work available, run work with executor-progress
return d.runWork()
// add retry here
var retcode int
retmsg := ""
waitsecs := 5
var err error
for i := 0; i < 3; i++ {
retcode, retmsg, err = d.runWork()
if retcode != int(api.ServerErrOK) {
break
}

if err != nil {
blog.Warnf("executor: failed to execute with error [%+v] for %d times cmd:%s", err, i+1, strings.Join(os.Args, " "))
time.Sleep(time.Duration(waitsecs) * time.Second)
waitsecs = waitsecs * 2
continue
}

break
}

return retcode, retmsg, err
}

func compileReadFromStdin() bool {
Expand Down Expand Up @@ -180,13 +202,6 @@ func (d *DistExecutor) runWork() (int, string, error) {
return 0, "", fmt.Errorf("not enough args to execute")
}

// ignore argv[0], it's itself
// _, _, r, err := d.work.Job(d.stats).ExecuteLocalTask(os.Args[1:], "")
// if err != nil {
// blog.Errorf("executor: execute failed, error: %v, exit code: -1", err)
// return -1, err
// }

retcode, retmsg, r, err := d.work.Job(d.stats).ExecuteLocalTask(os.Args[1:], "")
if err != nil || retcode != 0 {
if r != nil {
Expand Down

0 comments on commit 9d742f3

Please sign in to comment.