Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Woodpecker creates empty pipelines #2901

Closed
5 tasks done
xoxys opened this issue Dec 2, 2023 · 13 comments · Fixed by #2923
Closed
5 tasks done

Woodpecker creates empty pipelines #2901

xoxys opened this issue Dec 2, 2023 · 13 comments · Fixed by #2923
Labels
bug Something isn't working
Milestone

Comments

@xoxys
Copy link
Member

xoxys commented Dec 2, 2023

Component

server

Describe the bug

Woodpecker creates empty pipelines that never start because they are empty:

image
image

Issue occurs in next-621eed6205 while reverting to next-111a0b4ea5 fixed it.

System Info

next-621eed6205

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Checked that the bug isn't fixed in the next version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
  • Check that this is a concrete bug. For Q&A join our Discord Chat Server or the Matrix room.
@xoxys xoxys added the bug Something isn't working label Dec 2, 2023
@qwerty287 qwerty287 added this to the 2.1.0 milestone Dec 3, 2023
@qwerty287
Copy link
Contributor

What do you mean by "empty"? Are all configs filtered out? Or is there no config in the repo?

@xoxys
Copy link
Member Author

xoxys commented Dec 3, 2023

As you can see in the screenshot for the PR event on the same commit a Pipeline is running. There is a repo config but WP creates an empty job for the renovate branch in that example.

@qwerty287
Copy link
Contributor

So the issue seems to be either fetching configs from the forge (which should make the pipeline failing) or persisting the config to DB.

Can you check the logs? (Maybe also with debug logs)

@xoxys
Copy link
Member Author

xoxys commented Dec 7, 2023

Can still reproduce this on latest next release, see https://ci.rknet.org/repos/5

image

It creates an empty pipeline to push events to any branch. The Woodpecker repo in the config has not changed. You can find the config here https://gitea.rknet.org/container/hugo/src/branch/main/.woodpecker This config should ignore any push action to none-default branches. For whatever reason, the push action triggers "something" which leads to an empty pipeline that never starts.

@xoxys
Copy link
Member Author

xoxys commented Dec 7, 2023

Can you check the logs? (Maybe also with debug logs)

Nothing in the regular logs. Will switch to debug later and check again. I'll also try to reproduce it with a local dev setup.

@anbraten
Copy link
Member

anbraten commented Dec 7, 2023

Could you check if it works after removing the --- at the top.

@xoxys
Copy link
Member Author

xoxys commented Dec 7, 2023

Could you check if it works after removing the --- at the top.

Sure, tested doesn't make any difference:

image

@xoxys
Copy link
Member Author

xoxys commented Dec 7, 2023

I'm also able to reproduce this on a local dev setup with woodpecker-main + gitea 1.21

image

❯ tree .woodpecker/
.woodpecker/
└── demo.yml

1 directory, 1 file

❯ cat .woodpecker/demo.yml 
when:
  - event: [pull_request, tag]
  - event: push
    branch:
      - ${CI_REPO_DEFAULT_BRANCH}

steps:
  demo:
    image: 'alpine'
    commands:
      - echo 'Demo'

@xoxys
Copy link
Member Author

xoxys commented Dec 7, 2023

Any idea what PR could have introduced this? As the latest working version for me is next-111a0b4ea5 I can try to use bisect to find the commit which has introduced the issue.

@xoxys
Copy link
Member Author

xoxys commented Dec 7, 2023

Found it:

❯ git bisect good
849b02a433c375edc1a8ebc52bf38d8e13263ba3 is the first bad commit
commit 849b02a433c375edc1a8ebc52bf38d8e13263ba3
Author: qwerty287 <80460567+qwerty287@users.noreply.github.com>
Date:   Sun Nov 26 19:59:36 2023 +0100

    Fix pipeline-related environment (#2876)
    
    closes https://github.com/woodpecker-ci/woodpecker/issues/2672
    
    pipeline model must be persisted first to have some fields like `Number`
    and `ID`

 server/pipeline/create.go | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

Related to #2876

@xoxys
Copy link
Member Author

xoxys commented Dec 7, 2023

Debug log while the empty pipeline is being created in the UI:

{"level":"error","error":"token signature is invalid: signature is invalid","time":"2023-12-07T20:32:39Z","caller":"/build/server/api/hook.go:173","message":"failure to parse token from hook for testorg/woodpecker-test"}
{"level":"debug","ip":"172.22.0.2","latency":1.15212,"method":"POST","path":"/api/hook","status":400,"time":"2023-12-07T20:32:39Z","user-agent":"Go-http-client/1.1","time":"2023-12-07T20:32:39Z","caller":"/build/server/router/middleware/logger.go:59"}
{"level":"debug","pipeline":"demo","time":"2023-12-07T20:32:39Z","caller":"/build/pipeline/stepBuilder.go:158","message":"Marked as skipped, does not match metadata"}
{"level":"debug","repo":"testorg/woodpecker-test","time":"2023-12-07T20:32:39Z","caller":"/build/server/pipeline/create.go:83","message":"ignoring hook: 'when' filters filtered out all steps"}
{"level":"debug","ip":"172.22.0.2","latency":29.213733,"method":"POST","path":"/api/hook","status":204,"time":"2023-12-07T20:32:39Z","user-agent":"Go-http-client/1.1","time":"2023-12-07T20:32:39Z","caller":"/build/server/router/middleware/logger.go:59"}

@xoxys
Copy link
Member Author

xoxys commented Dec 7, 2023

The empty pipelines are not added to the queue, but as they are persisted to the DB now, even if they are skipped anyway, the method GetPipelineList used by the GetPipelines API will list those pipelines as well.

Don't know what's the best way to handle it, I'm also not sure if the original fix from #2876 is the right way, do we really want to persist every pipeline even if they are ignored/empty?

@qwerty287
Copy link
Contributor

No, that's a regression. However, we must persist it first to get the correct env vars. I can check what could be done here, not sure when I have time though (maybe this afternoon but I can't guarantee)

lafriks added a commit that referenced this issue Dec 12, 2023
Fixes: #2901

---------

Co-authored-by: Lauris BH <lauris@nix.lv>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants