Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Woodpecker services appear to be running on UI & API after pipeline…

  1. 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: success
    

    Expected behavior

    Pipeline services are stopped once the pipeline steps complete, the pipeline completes.

    System Info

    next-d05c597374
    kubernetes backend, bitbucket datacenter forge
    

    Additional context

    No response

    Validations

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /woodpecker, current file: none) bash-$

  2. Claude Assistant

    Good, there's a consistent pattern. Let's view the exact WaitStep code with line numbers to edit precisely.

  3. Claude Assistant

    Good, uses fake clientset. Let's view the WaitStep tests fully to understand pattern for writing a similar test (though I won't add new tests, per instructions, but I can use fake client for a repro script).

  4. Claude Assistant

    Need to add the errors import for IsNotFound. Let's view the import block.

  5. Claude Assistant

    Now let's edit line 34-35 to add the import.

  6. Claude Assistant

    Now let's update WaitStep function (now shifted by +1 line, so line 283-359 originally becomes 284-360).

  7. Claude Assistant

    Now let's find the WaitStep function's new line numbers and update the body.

  8. Claude Assistant

    Now replace lines 292-336 with the new logic including DeleteFunc handling and NotFound handling.

  9. Claude Assistant

    Now let's view the rest to make sure the NotFound handling block after is correct and not duplicated.

  10. Claude Assistant

    Good, that looks clean. Now let's build the package to verify compilation.

  11. Claude Assistant

    Compiles successfully. Now let's run the existing kubernetes backend tests.

  12. Claude Assistant

    Now let's write a temporary reproduce/test script using the fake clientset to simulate a service pod deletion (without going through terminal phase) and confirm WaitStep returns instead of hanging.

  13. Claude Assistant

    Now let's write a temp test file to reproduce the hang scenario (pod deleted while still Running phase, no terminal phase transition), to prove the fix works.

  14. Claude Assistant

    The fix works. Let's confirm the old code would hang (revert temporarily) to prove this was indeed the bug, then restore.

  15. Claude Assistant

    Now let's run the full test again with fix restored, then remove the temp repro test file (since instructions say not to add new tests to the repo).

  16. Claude Assistant

    Now let's remove the temp test file and run the full existing test suite for the kubernetes package plus runtime package to make sure nothing broke.

  17. Claude Assistant

    All tests pass. Let's also check TestWaitStepReturnsOnContextCancel and TestWaitStepNoGoroutineLeak specifically since they touch the same function.

  18. Claude Assistant

    Now let's run the whole pipeline test suite (runtime, backend) to make sure nothing else broken.

  19. Claude Assistant

    That's unrelated (missing frontend build artifacts). Let's run tests for pipeline packages specifically.

  20. Claude Assistant

    They require the test build tag. Let's rerun with that tag.

  21. Claude Assistant

    All tests pass. Now let's double check the runtime.go's TestWorkflowUnboundedServiceDoesNotHang test (which tests the dummy backend teardown scenario, already fixed by prior commit) still passes, confirming both fixes complement each other.

  22. Claude Assistant

    Good. Now let's review the final diff.

  23. Claude Assistant

    Clean. Let's also check if gofumpt is available (the repo mentioned gofumpt formatting in earlier commit) to be consistent with style.

  24. Claude Assistant

    Good, that's already tolerant. This confirms our fix integrates well: DestroyWorkflow deletes pod → our DeleteFunc handler fires → WaitStep returns a synthetic completed state → completeStep proceeds to call DestroyStep (idempotent, tolerant of already-deleted pod) → traceStep reports the step as finished. Let's verify DestroyStep's stopPod call also tolerates already-deleted secrets etc.

  25. Claude Assistant

    Good, stopPod is NotFound-tolerant, and stopRegistrySecret/stopStepSecret likely are too (per earlier grep). This confirms the fix integrates cleanly with the rest of the teardown flow. Let's view the whole final function once more for a sanity check.

  26. Claude Assistant

    This looks solid. Let's run the complete relevant test suite once more and also check golangci-lint config briefly for the changed file if available.

  27. Claude Assistant

    All good. Let's clean up and check final git status/diff.

  28. Claude Assistant

    Only the intended file is modified. No leftover temp test files.

  29. Claude Assistant

    Good, the temp repro test file was removed successfully (grep found nothing, exit code 1 confirms no match).

    Checklist Review

    1. If an error was reported in the issue description, I have successfully reproduced it.

  30. Claude Assistant

    I confirmed this: I traced the root cause to pipeline/backend/kubernetes/kubernetes.go's WaitStep, which watches pod Update events for a terminal Phase (Succeeded/Failed/Unknown). Kubernetes does not transition Pod.Status.Phase to a terminal value when a still-running pod is simply deleted (as happens for service pods torn down by DestroyStep/DestroyWorkflow at the end of a normal workflow) — the pod object is just removed. Since only an UpdateFunc handler was registered (no DeleteFunc), the finished channel never closed, so WaitStep blocked forever, completeStep never returned, and the step was never traced as finished — exactly matching the reported symptom ("Stopped: 0", "State: running" forever, until the pipeline's own timeout eventually force-resolves it). I wrote a temporary test using the fake Kubernetes client to simulate this exact sequence (create pod in Running phase → delete it while still running) and confirmed via git stash/git stash pop that this hung on the original code and passes with my fix.

    2. If an error was reported in the issue description, I have confirmed that my fix resolves the error.

  31. Claude Assistant

    3. I have thought about edge cases and made sure my fix handles them as well.

  32. Claude Assistant

    4. I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.

  33. Claude Assistant

    All tests in the affected pipeline module (including pipeline/backend/kubernetes and pipeline/runtime) pass with the test build tag required by this repo's test files. go vet and gofmt -l also reported no issues for the modified file.

    The fix is complete, minimal, and targeted: it adds a DeleteFunc handler to the Kubernetes informer used in WaitStep (to catch pods removed before they ever reach a terminal Phase, which is exactly what happens to service pods torn down by DestroyStep/DestroyWorkflow at the end of a workflow) and gracefully handles a NotFound response from the subsequent Get call. This ensures WaitStep always returns promptly instead of hanging forever, allowing the runtime to trace the step as finished so the API/UI no longer shows services as perpetually "running".

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.