feat(executor/sandbox): 1 cmd each time
All checks were successful
submodules sync / sync (push) Successful in 58s
build / build (push) Successful in 2m14s
build / trigger-build-image (push) Successful in 9s

This commit is contained in:
张泊明518370910136 2025-04-05 05:14:16 -04:00
parent 9f78569447
commit df2ade4988
GPG Key ID: D47306D7062CDA9D

View File

@ -21,6 +21,7 @@ func (e *Sandbox) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
} }
} }
// cannot use range loop since we need to change the value // cannot use range loop since we need to change the value
results := make([]stage.ExecutorResult, len(cmds))
for i := 0; i < len(cmds); i += 1 { for i := 0; i < len(cmds); i += 1 {
cmd := &cmds[i] cmd := &cmds[i]
if cmd.CopyIn == nil { if cmd.CopyIn == nil {
@ -31,12 +32,9 @@ func (e *Sandbox) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
cmd.CopyIn[k] = stage.CmdFile{FileID: &fileID} cmd.CopyIn[k] = stage.CmdFile{FileID: &fileID}
} }
} }
} pbCmd := convertPBCmd([]stage.Cmd{*cmd})
pbCmds := convertPBCmd(cmds) slog.Debug("sandbox execute", "i", i, "pbCmd size", proto.Size(pbCmd[0]))
for i, pbCmd := range pbCmds { pbReq := &pb.Request{Cmd: pbCmd}
slog.Debug("sandbox execute", "i", i, "pbCmd size", proto.Size(pbCmd))
}
pbReq := &pb.Request{Cmd: pbCmds}
slog.Debug("sandbox execute", "pbReq size", proto.Size(pbReq)) slog.Debug("sandbox execute", "pbReq size", proto.Size(pbReq))
pbRet, err := e.execClient.Exec(context.TODO(), pbReq) pbRet, err := e.execClient.Exec(context.TODO(), pbReq)
if err != nil { if err != nil {
@ -45,9 +43,9 @@ func (e *Sandbox) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
if pbRet.Error != "" { if pbRet.Error != "" {
return nil, fmt.Errorf("sandbox execute error: %s", pbRet.Error) return nil, fmt.Errorf("sandbox execute error: %s", pbRet.Error)
} }
results := convertPBResult(pbRet.Results) result := convertPBResult(pbRet.Results)[0]
for _, result := range results {
maps.Copy(e.cachedMap, result.FileIDs) maps.Copy(e.cachedMap, result.FileIDs)
results[i] = result
} }
return results, nil return results, nil
} }