2 Commits

Author SHA1 Message Date
zero@thinky fe7e41e4af fix(commander): missing job id on errors
ci-agent / build (push) Failing after 3m4s
2026-04-04 19:32:04 +03:00
zero@thinky 81d8f71937 feat(backend): drop default on jobs 2026-04-04 19:32:04 +03:00
3 changed files with 28 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{
+15
View File
@@ -0,0 +1,15 @@
CREATE TABLE [jobs_new_17f2f1dd010f] (
[id] INTEGER PRIMARY KEY,
[agent_id] TEXT NOT NULL,
[command] TEXT NOT NULL,
[stdin] TEXT,
[stdout] TEXT,
[stderr] TEXT,
[status] INTEGER,
[created_at] FLOAT DEFAULT CURRENT_TIMESTAMP,
[updated_at] FLOAT DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO [jobs_new_17f2f1dd010f] ([rowid], [id], [agent_id], [command], [stdin], [stdout], [stderr], [status], [created_at], [updated_at])
SELECT [rowid], [id], [agent_id], [command], [stdin], [stdout], [stderr], [status], [created_at], [updated_at] FROM [jobs];
DROP TABLE [jobs];
ALTER TABLE [jobs_new_17f2f1dd010f] RENAME TO [jobs];