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 start by exploring the repository structure and understanding how pipeline services are managed, especially with the Kubernetes backend.
- Assistant
Let me search for how services are cleaned up when a pipeline finishes.
- Assistant
Let me look at the runtime and how services are stopped. Also look at kubernetes backend service handling.
- Assistant
rg is not available, let me use grep instead.
- Assistant
Let me inspect how services are handled when the workflow completes.
- Assistant
Let me read the step.go file fully, especially around detached/service handling.
- Assistant
Let me read the rest of the file around runDetachedStep.
- Assistant
Continue reading.
- Assistant
Looking at how the workflow tears down services.
- Assistant
Inspecting the Kubernetes backend for WaitStep and DestroyWorkflow behavior.
- Assistant
Let me read the WaitStep and DestroyWorkflow implementations carefully.
- Assistant
Confirming how Docker waits for steps and whether pod deletion is observed.
- Assistant
Let me also look at docker WaitStep - does DestroyWorkflow stop containers first so Wait returns?
- Assistant
Inspecting DestroyWorkflow and DestroyStep implementations as well as related tests.
- Assistant
Checking recent changes and dummy backend behavior related to this bug.
- Assistant
Looking at related prior fixes for this issue.
- Assistant
Looking at the dummy backend contract and stopPod handling.
- Assistant
Checking stopPod and existing WaitStep tests.
- Assistant
Checking when the runtime context is canceled relative to DestroyWorkflow.
- Assistant
Inspecting how WaitStep historically handled finished or missing pods.
- Assistant
Looking at prior related Kubernetes wait/destroy changes.
- Assistant
Checking the server-side fix and the expected step state when a service is destroyed.
- Assistant
Checking stopPod deletion options and what happens to pod phase.
- Assistant
Checking default stop timeout and any open issues related to this.
- Assistant
Confirming the root cause: after DestroyWorkflow deletes pods, WaitStep neither observes Delete events nor handles an already-missing pod. Implementing the fix.
- Assistant
Implementing WaitStep to handle pod deletion and already-missing pods.
- Assistant
Now replacing the WaitStep function.
- Assistant
Updating tests to cover pod deletion and already-deleted cases.
- Assistant
Adding tests covering pod deletion and already-deleted scenarios.
- Assistant
Verifying the end of the test file is intact.
- Assistant
Fixing the missing closing brace in the test.
- Assistant
Checking makeEngine/makeStep helpers and running the tests.
- Assistant
The guidelines forbid adding tests to the repo — reverting test-file changes and using a temporary script instead.
- Assistant
Running existing Kubernetes backend tests and verifying the WaitStep changes compile.
- Assistant
Need to set GOPATH.
- Assistant
Writing a temporary test script for the new scenarios.
- Assistant
All scenarios passed. Running runtime tests and verifying the final diff.
- Assistant
Checking why runtime tests weren't discovered.
- Assistant
Reviewing the final WaitStep implementation once more.
- Assistant
Formatting the change and verifying makeEngine path still works.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.