ISSUE DESCRIPTION Woodpecker services appear to be running on UI & API after pipeline…
- User
ISSUE DESCRIPTION
Woodpecker services appear to be running on UI & API after pipeline completes
Component
server
Describe the bug
Some regression with newer releases (3.14.x) With kubernetes backend and pipelines defining services, the services are not cleaned properly. The pods from kubernetes backend are destroyed properly, but the woodpecker API still show these steps as state=running.
These are only cleaned after the pipeline times out. This prevents timely deploys as pipeline executions are not getting green status (although, as a mitigation, the pipeline waiting services can be cancelled, after which the deploy can be made).
Steps to reproduce
- Install woodpecker next-d05c597374
- Use kubernetes backend
- Define pipeline with services running infinitely, like running postgres
codeservices: - name: postgres image: public.ecr.aws/docker/library/postgres:16-alpine3.21 ports: - 5432 environment: POSTGRES_PASSWORD: somepass POSTGRES_USER: someuser POSTGRES_DB: somedb steps: - name: wait-for-postgres image: public.ecr.aws/docker/library/postgres:16-alpine3.21 environment: DB_HOST: postgres DB_PORT: 5432 MAX_WAIT: 60 commands: - ./scripts/wait-for-postgres.sh- Run the pipeline, observe pods start for the service and the step
- once wait-for-postgres step completes, the pods are destroyed, but API still shows the service as running, also visible on Web UI.
codepr-build > clone (#2): Step: clone Started: 1779195580 Stopped: 1779195594 Type: clone State: success pr-build > postgres (#3): Step: postgres Started: 1779195594 Stopped: 0 Type: service State: running pr-build > wait-for-postgres (#4): Step: wait-for-postgres Started: 1779195596 Stopped: 1779195602 Type: commands State: successExpected behavior
Pipeline services are stopped once the pipeline steps complete, the pipeline completes.
- Assistant
I’ll trace how pipeline services are persisted and finalized, compare service-step handling with regular steps, then patch the server logic and run focused tests. I’ll first inspect the repository layout and recent status.
- Assistant
The repository is Go-based and has no working-tree changes. I’ll now locate service scheduling, step status updates, and pipeline completion paths, especially code that may intentionally skip service steps.
- Assistant
rgis unavailable in the environment, so I’ll use recursivegrepinstead to identify the relevant packages and symbols. - Assistant
The RPC layer contains an explicit “complete still-running children” path and a focused test, which is likely the intended fix or an incomplete implementation. I’ll inspect that code and its tests, then examine the datastore update semantics to see why service completion may not persist.
- Assistant
The current source already has a completion comment, so I need determine whether it only updates in one workflow path or is ineffective for services. I’ll read the complete
Done/workflow-finalization implementation and the step status function. - Assistant
The existing helper does persist running children, but
UpdateStepToStatusSkippeddeliberately converts any started step tosuccess; that is not the reported “stopped=0/running” symptom. More importantly, the helper is only called byDone, and its child query may omit service steps if their workflow parent ID differs. I’ll inspect workflow/step construction and the full history around the related regression. - Assistant
The workflow builder assigns services the same workflow
PPID, so the query should include them. I found a key edge case:Donepasses the agent’sstate.Finisheddirectly; if the backend reports zero (or an older agent omits it), completed services retainFinished=0, matching the report. I’ll inspect RPC protocol and agent completion behavior to confirm whether server should derive a timestamp defensively, and check whether current tests expose this. - Assistant
The agent normally supplies a nonzero finish timestamp, but the server should not trust that optional field when finalizing child steps. I’ll make finalization defensive: derive a completion timestamp when absent, apply the complete returned step object back into the workflow, and use the same timestamp for workflow completion. This preserves the existing “started daemon/service is successful” behavior while guaranteeing no persisted running service has
Finished=0. - Assistant
The patch now guarantees a nonzero terminal timestamp and keeps the in-memory workflow tree exactly synchronized with the persisted child update. I’ll run the focused RPC and pipeline test suites, then inspect the final diff and repository status.
- Assistant
The focused tests could not start because the environment has neither
GOMODCACHEnorGOPATHconfigured, rather than because of a code failure. I’ll inspect Go/module settings and attempt the repository’s normal test command with a temporary cache location if dependencies are available. - Assistant
Go itself is installed and the diff is whitespace-clean; only cache variables are missing. I’ll retry with an isolated temporary
GOPATH/module cache, avoiding any repository changes. - Assistant
The retry progressed to dependency setup but stopped because the sandbox also lacks
HOME/GOCACHE; no compilation occurred. I’ll provide those temporary settings and run the focused tests once more. - Assistant
All focused tests pass with the temporary Go environment. I’ll perform the final diff/status review and then submit the change.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.