server queue api should ignore missing agent (#6763)

This commit is contained in:
6543
2026-06-22 15:31:21 +02:00
committed by GitHub
parent e3d0281f12
commit b28cdf2e51
2 changed files with 9 additions and 4 deletions
+2 -1
View File
@@ -19,6 +19,7 @@ import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
"go.woodpecker-ci.org/woodpecker/v3/server"
"go.woodpecker-ci.org/woodpecker/v3/server/model"
@@ -138,7 +139,7 @@ func processQueueTasks(store store.Store, tasks []*model.Task, agentNameMap map[
if task.AgentID != 0 {
name, ok := getAgentName(store, agentNameMap, task.AgentID)
if !ok {
return nil, fmt.Errorf("agent not found for task %s", task.ID)
log.Error().Msgf("agent not found for task %s", task.ID)
}
taskResponse.AgentName = name
+7 -3
View File
@@ -130,7 +130,7 @@ func TestGetQueueInfo(t *testing.T) {
assert.Empty(t, got.WaitingOnDeps)
})
t.Run("unknown agent returns internal error", func(t *testing.T) {
t.Run("unknown agent is ignored", func(t *testing.T) {
pipe := seedPipeline(t, s, repo.ID)
info := queue.InfoT{Running: []*model.Task{
{ID: "1", AgentID: 99999, PipelineID: pipe.ID, RepoID: repo.ID},
@@ -142,8 +142,12 @@ func TestGetQueueInfo(t *testing.T) {
tc := newTestContext(t, s)
GetQueueInfo(tc.Ctx)
assert.Equal(t, http.StatusInternalServerError, tc.Recorder.Code)
assert.Contains(t, tc.Recorder.Body.String(), "agent not found")
require.Equal(t, http.StatusOK, tc.Recorder.Code)
var got model.QueueInfo
tc.decodeJSON(t, &got)
require.Len(t, got.Running, 1)
assert.Equal(t, "1", got.Running[0].ID)
assert.Empty(t, got.Running[0].AgentName)
})
t.Run("unknown pipeline returns internal error", func(t *testing.T) {