Skip to content

Commit

Permalink
feat: 增加toolchain发送失败后重试修复 #289
Browse files Browse the repository at this point in the history
  • Loading branch information
flyy1012 committed Sep 5, 2024
1 parent f67bc41 commit 70877a4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
25 changes: 16 additions & 9 deletions src/backend/booster/bk_dist/controller/pkg/manager/remote/mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ func (fsm *fileSendMap) matchOrInsert(desc dcSDK.FileDesc, retry bool) (*types.F

for _, ci := range *c {
if ci.Match(desc) {
//if worker is retrying and not send succeed, try to set send status to sending
//if worker is retrying and send failed before, try to set send status to retrying
if retry && ci.SendStatus == types.FileSendFailed {
ci.SendStatus = types.FileSending
ci.SendStatus = types.FileSendRetrying
return ci, false
}
return ci, true
Expand Down Expand Up @@ -209,15 +209,15 @@ func (fsm *fileSendMap) matchOrInserts(descs []*dcSDK.FileDesc, retry bool) []ma
matched := false
for _, ci := range *c {
if ci.Match(*desc) {
fileMatch := true
//if worker is retrying and send failed, try to set send status to sending
fileMatched := true
//if worker is retrying and send failed before, try to set send status to retrying
if retry && ci.SendStatus == types.FileSendFailed {
fileMatch = false
ci.SendStatus = types.FileSending
fileMatched = false
ci.SendStatus = types.FileSendRetrying
}
result = append(result, matchResult{
info: ci,
match: fileMatch,
match: fileMatched,
})
matched = true
break
Expand Down Expand Up @@ -952,7 +952,7 @@ func (m *Mgr) ensureSingleFile(
for status == types.FileSending {
select {
case <-tick.C:
// 不是发送文件的goroutine,不能修改状态
// 不是发送文件的goroutine,不需要发送failed文件
status, _ = m.checkOrLockSendFile(host.Server, desc, false)
}
}
Expand All @@ -966,6 +966,10 @@ func (m *Mgr) ensureSingleFile(
blog.Debugf("remote: success to ensure single file(%s) for work(%s) to server(%s)",
desc.FilePath, m.work.ID(), host.Server)
return nil
case types.FileSendRetrying:
blog.Infof("remote: single file(%s) for work(%s) to server(%s) is retrying now",
desc.FilePath, m.work.ID(), host.Server)
return nil
default:
return fmt.Errorf("unknown file send status: %s", status.String())
}
Expand Down Expand Up @@ -1063,6 +1067,9 @@ func (m *Mgr) ensureSingleCorkFile(c *corkFile, r matchResult) (err error) {
blog.Debugf("remote: end ensure single cork file(%s) for work(%s) to server(%s) succeed",
desc.FilePath, m.work.ID(), host.Server)
return nil
case types.FileSendRetrying:
blog.Infof("remote: single cork file(%s) for work(%s) to server(%s) is retrying now", desc.FilePath, m.work.ID(), host.Server)
return nil
default:
blog.Errorf("remote: end ensure single cork file(%s) for work(%s) to server(%s), "+
" with unknown status", desc.FilePath, m.work.ID(), host.Server)
Expand Down Expand Up @@ -1271,7 +1278,7 @@ func (m *Mgr) getFailedFileCollectionByHost(server string) ([]*types.FileCollect
}
fcs := make([]*types.FileCollectionInfo, 0)
for _, re := range *target {
if re.SendStatus != types.FileSendSucceed {
if re.SendStatus == types.FileSendFailed {
fcs = append(fcs, re)
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/backend/booster/bk_dist/controller/pkg/types/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,18 @@ const (
FileSending
FileSendSucceed
FileSendFailed
FileSendRetrying
FileSendUnknown = 99
)

var (
fileStatusMap = map[FileSendStatus]string{
FileSendInit: "sendinit",
FileSending: "sending",
FileSendSucceed: "sendsucceed",
FileSendFailed: "sendfailed",
FileSendUnknown: "unknown",
FileSendInit: "sendinit",
FileSending: "sending",
FileSendSucceed: "sendsucceed",
FileSendFailed: "sendfailed",
FileSendRetrying: "sendretrying",
FileSendUnknown: "unknown",
}
)

Expand Down

0 comments on commit 70877a4

Please sign in to comment.