Skip to content

Commit

Permalink
feat:support result cache, issue: TencentBlueKing#315
Browse files Browse the repository at this point in the history
  • Loading branch information
tbs60 committed Dec 26, 2024
1 parent b65e0ef commit 3625e34
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,24 @@ func (e *executor) getLocalResultFiles(c *dcSDK.BKDistCommand) *types.LocalTaskE
}

for k, v := range resultmap {
f, err := os.Create(k)
fp := k
if !filepath.IsAbs(fp) {
fp = filepath.Join(e.req.Dir, fp)
}
f, err := os.Create(fp)
if err != nil {
blog.Errorf("executor: create file %s with error: %v", k, err)
blog.Errorf("executor: create file %s with error: %v", fp, err)
return nil
}

_, err = f.Write(rs[v].CompressDataBuf)
if err != nil {
f.Close()
blog.Errorf("executor: save file %s with error: %v", k, err)
blog.Errorf("executor: save file %s with error: %v", fp, err)
return nil
}
f.Close()
blog.Infof("executor: got cache result file %s with key:%s", k, e.preprocessResultKey)
blog.Infof("executor: got cache result file %s with key:%s", fp, e.preprocessResultKey)
}

e.stats.PostWorkSuccess = true
Expand Down Expand Up @@ -256,20 +260,24 @@ func (e *executor) getRemoteResultFiles(c *dcSDK.BKDistCommand) *types.LocalTask
data = outdata
}

f, err := os.Create(k)
fp := k
if !filepath.IsAbs(fp) {
fp = filepath.Join(e.req.Dir, fp)
}
f, err := os.Create(fp)
if err != nil {
blog.Errorf("executor: create file %s with error: %v", k, err)
blog.Errorf("executor: create file %s with error: %v", fp, err)
return nil
}

_, err = f.Write(data)
if err != nil {
f.Close()
blog.Errorf("executor: save file %s with error: %v", k, err)
blog.Errorf("executor: save file %s with error: %v", fp, err)
return nil
}
f.Close()
blog.Infof("executor: got cache result file %s with key:%s", k, e.preprocessResultKey)
blog.Infof("executor: got cache result file %s with key:%s", fp, e.preprocessResultKey)
}

e.stats.PostWorkSuccess = true
Expand Down

0 comments on commit 3625e34

Please sign in to comment.