Woodpecker services appear to be running on UI & API after pipeline completes Component…
- User
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.
System Info
- Assistant
Now let me look at the kubernetes backend, particularly WaitStep and DestroyWorkflow:
- Assistant
Now I'll implement the fix. Check the import alias convention for k8s api errors:
- Assistant
kubernetes.go imports stdlib
errors, so I'll use thekube_errorsalias. Now the fix: - Assistant
Now add a test verifying WaitStep returns when the pod is deleted:
- Assistant
I accidentally introduced a line break in that comment — fixing:
- Assistant
Transient fork failure during compile. Retry with reduced parallelism:
- Assistant
Odd — runtime has test files. Check for build tags:
- Assistant
The vet complaint is pre-existing in
shutdown.go:37(it carries a//nolint:govetfor golangci-lint), unrelated to my change. Let me verify formatting of the changed files: - Assistant
Formatting is clean. Final diff:
- Assistant
Fixed. Summary of the root cause and the change:
Root cause
Since #6507 ("Fix workflow hang on services"), the pipeline runtime finishes a workflow by calling
DestroyWorkflowafter all stages complete and then waiting (uploadWait.Wait()) for every detached step's background goroutine to trace its final state. This relies on an interface contract: whenDestroyWorkflowkills a running step, that step'sWaitStepmust return (the dummy backend was updated for this contract, but the Kubernetes backend was not — hence the 3.14.x regression).In the Kubernetes backend,
WaitStepwatched pods with an informer registering only , closing only when a pod reached //. A service pod deleted by goes from straight to a event without ever passing a terminal phase via an update, so blocked forever. The pod was gone from the cluster, but the service step's goroutine never traced a final state — the API/UI kept showing until the pipeline timeout canceled the context.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.