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
services: - 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.
pr-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.
System Info
next-d05c597374 kubernetes backend, bitbucket datacenter forgeAdditional context
No response
Validations
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Assistant
Now let's check kubernetes_test.go's existing WaitStep tests to understand test setup conventions, in case my change affects them.
Assistant
Now let's implement the fix in kubernetes.go.
Assistant
Now add the
kube_errorsimport alias.Assistant
Now let's build to check for compile errors.
Assistant
That's an unrelated pre-existing issue (missing web dist files). Let's just build the specific package and dependents.
Assistant
Good, builds cleanly. Now let's run go vet and existing tests for kubernetes backend and runtime package.
Assistant
That's a pre-existing lint issue unrelated to our change. Let's confirm it existed before our change too.
Assistant
Good, this file (shutdown.go) is untouched, confirming pre-existing issue. Now run the test suite.
Assistant
All existing tests pass. Let's also run the runtime package tests since they exercise
runDetachedStep/completeSteplogic.Assistant
There's a
testbuild tag. Let's run with that tag.Assistant
All pass. Now let's write a quick reproduction script/test to simulate the scenario: a service pod that's deleted while running (no terminal phase update), verifying WaitStep now returns promptly instead of hanging until context cancellation.
Assistant
Now let's run the full existing test suite for this package plus vet, then remove the temp repro test.
Assistant
Both pass. Now let's remove the temporary repro test file, and double check the docker backend / local backend to see if they have similar issues (not required by issue but worth checking DestroyStep pattern consistency). Let's also check other backends' WaitStep behavior for consistency, but the issue specifically is about kubernetes backend.
Assistant
Let's view the final diff for review.
Assistant
Good - that logic handles setting
Finishedbased onstate.Exitedetc. This is unrelated to our fix scope (server side already knows how to translate states). Let's inspect step_status.go briefly to make sure our State (Exited=true, no error) triggers a "success" finished status correctly.Assistant
Great, this confirms server-side properly marks step as success when
state.Exited=trueand no error/exit code. Our fix produces exactly that. Now let's rerun full test suite for whole pipeline package once more, and check golangci-lint if available.Assistant
All packages pass. Let's also run
go vetfor the whole pipeline tree andgofmtcheck on the modified file.Assistant
No formatting issues, vet is clean. Let's view the final version of the modified function for a sanity read-through.
Assistant
Good, this confirms the analysis. Now let's re-run the full test suite once more (whole repo, excluding web dist issue) and double check with
go vet.Assistant
Confirmed pre-existing (unrelated to our change — missing web dist files). Let's create the dist dir stub to allow full build check, or just skip and test only relevant packages.
Assistant
Good, builds now. Let's build agent, rpc, cli too, then revert the dist stub afterward (not part of the fix).
Assistant
Everything builds. Let's clean up the stub dist directory since it's not part of our fix.
Assistant
Now let's run the full relevant test suite one more time to be certain everything is in order.
Assistant
All tests pass. Let's view the final diff once more for a clean review.
Assistant
This is a comprehensive fix. Let's also double check the golangci-lint config doesn't flag unused imports/vars, and finally do one more full test pass.
Assistant
All relevant tests pass with no failures. Let's do a final full check of the diff and finalize.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.