feat(executor/sandbox): 1 cmd each time
This commit is contained in:
parent
9f78569447
commit
df2ade4988
|
@ -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
|
||||
results := make([]stage.ExecutorResult, len(cmds))
|
||||
for i := 0; i < len(cmds); i += 1 {
|
||||
cmd := &cmds[i]
|
||||
if cmd.CopyIn == nil {
|
||||
|
@ -31,23 +32,20 @@ func (e *Sandbox) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
|
|||
cmd.CopyIn[k] = stage.CmdFile{FileID: &fileID}
|
||||
}
|
||||
}
|
||||
}
|
||||
pbCmds := convertPBCmd(cmds)
|
||||
for i, pbCmd := range pbCmds {
|
||||
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))
|
||||
pbRet, err := e.execClient.Exec(context.TODO(), pbReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if pbRet.Error != "" {
|
||||
return nil, fmt.Errorf("sandbox execute error: %s", pbRet.Error)
|
||||
}
|
||||
results := convertPBResult(pbRet.Results)
|
||||
for _, result := range results {
|
||||
pbCmd := convertPBCmd([]stage.Cmd{*cmd})
|
||||
slog.Debug("sandbox execute", "i", i, "pbCmd size", proto.Size(pbCmd[0]))
|
||||
pbReq := &pb.Request{Cmd: pbCmd}
|
||||
slog.Debug("sandbox execute", "pbReq size", proto.Size(pbReq))
|
||||
pbRet, err := e.execClient.Exec(context.TODO(), pbReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if pbRet.Error != "" {
|
||||
return nil, fmt.Errorf("sandbox execute error: %s", pbRet.Error)
|
||||
}
|
||||
result := convertPBResult(pbRet.Results)[0]
|
||||
maps.Copy(e.cachedMap, result.FileIDs)
|
||||
results[i] = result
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user