fix(commander): missing job id on errors
ci-agent / build (push) Failing after 3m4s

This commit is contained in:
2026-04-04 19:32:00 +03:00
parent 81d8f71937
commit fe7e41e4af
2 changed files with 13 additions and 14 deletions
+9 -13
View File
@@ -10,15 +10,13 @@ import (
"golang.org/x/sync/errgroup"
)
type CommandExecutor struct {
}
type CommandExecutor struct{}
func (*CommandExecutor) Execute(command *proto.Command) (*proto.FinishedCommand, error) {
func (*CommandExecutor) Execute(command *proto.Command) (fc *proto.FinishedCommand, err error) {
fc = new(proto.FinishedCommand)
fc.Id = command.Id
cmd := exec.Command(command.Command[0], command.Command[1:]...)
var (
stdin io.WriteCloser
err error
)
var stdin io.WriteCloser
if command.Stdin != nil {
stdin, err = cmd.StdinPipe()
if err != nil {
@@ -56,10 +54,8 @@ func (*CommandExecutor) Execute(command *proto.Command) (*proto.FinishedCommand,
if err := eg.Wait(); err != nil {
return nil, err
}
return &proto.FinishedCommand{
Id: command.Id,
Status: int32(cmd.ProcessState.ExitCode()),
Stdout: stdoutbuf.String(),
Stderr: stderrbuf.String(),
}, nil
fc.Status = int32(cmd.ProcessState.ExitCode())
fc.Stdout = stdoutbuf.String()
fc.Stderr = stderrbuf.String()
return
}
+4 -1
View File
@@ -1,8 +1,11 @@
package handlers
import (
"errors"
"fmt"
"net/http"
"os"
"os/exec"
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/backend/internal/grpcsrv/commander"
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/backend/internal/models"
@@ -74,7 +77,7 @@ func (self *JobsHandlers) AddJob(c *gin.Context) {
return err
}
job, err := agent.WaitJob(jid)
if err != nil {
if err != nil && !errors.Is(err, &exec.ExitError{}) {
return err
}
c.JSON(http.StatusCreated, AddJobOut{