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
Now add the required imports (
sync/atomicandkube_errors "k8s.io/apimachinery/pkg/api/errors").Assistant
Now let's build to check for errors.
Assistant
Build succeeds. Let's run vet/lint quickly and existing tests for kubernetes backend.
Assistant
That's an unrelated pre-existing issue (missing frontend build artifacts). Let's build only the relevant packages.
Assistant
Ah, need the
testbuild tag.Assistant
All runtime tests pass. Now let's check kubernetes package tests, also run with
-tags testin case relevant, and re-verify vet unrelated warning is pre-existing (not caused by our change).Assistant
Confirmed pre-existing, unrelated. Now let's write a quick test scenario reproducing the kubernetes WaitStep behavior using a fake clientset to validate the fix actually works as intended.
Assistant
No build tag needed. Let's write a temporary test file to validate deletion handling, run it, then remove it (not part of final submission).
Assistant
Both scenarios work correctly. Now let's confirm the old code (without fix) actually hangs in these scenarios, to be sure this is a real regression test.
Assistant
Confirmed this reproduces the reported hang, and our fix resolves it. Now let's remove the temporary test file and run the full existing test suite for the kubernetes package and runtime package to make sure nothing broke.
Assistant
All existing tests pass. Now run the full test suite for the whole repository (excluding areas requiring frontend assets) to double check nothing else broke.
Assistant
Build succeeds across the whole repo. Let's run broader tests (server, pipeline) to ensure nothing else is broken, then clean up the dummy dist dir (not part of the fix).
Assistant
All tests pass. Now remove temporary dist dir since not part of the actual fix (it's just a workaround for local building, not something to submit).
Assistant
Only the intended file is modified. Let's review the final diff for correctness and cleanliness.
Assistant
This looks clean and focused. Let's do a final full test pass with the
testtag across the repo (excluding server which needs DB, but let's at least try).Assistant
No formatting issues. Clean up the temporary dist directory again (not part of submission).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.