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

kubernetes backend - step name with spaces causes label error #3272

Closed
3 tasks done
metawave opened this issue Jan 24, 2024 · 4 comments · Fixed by #3275
Closed
3 tasks done

kubernetes backend - step name with spaces causes label error #3272

metawave opened this issue Jan 24, 2024 · 4 comments · Fixed by #3275
Labels
backend/kubernetes bug Something isn't working

Comments

@metawave
Copy link

metawave commented Jan 24, 2024

Component

agent

Describe the bug

Having a pipline like:

steps:
  - name: build image
    image: plugins/docker

on a woodpecker 2.2.2 server with kubernetes backend I get the following error:

Pod "wp-01hmywxc67eps76kjkryer0rc6" is invalid: metadata.labels: Invalid value: "build image": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

This has worked before on the 2.1.x version

System Info

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"2.2.2"}

Additional 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.
  • Checked that the bug isn't fixed in the next version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
@metawave metawave added the bug Something isn't working label Jan 24, 2024
@zc-devs
Copy link
Contributor

zc-devs commented Jan 25, 2024

What is expected behavior, apart from This has worked before? What label should be in your opinion?

@metawave
Copy link
Author

metawave commented Jan 25, 2024

@zc-devs I don't expect a certain label on pods (for steps). That's not the problem.

The actual issue is: all pipelines which have spaces in the step-name fail with that error. I'm a bit blocked because I have some pipelines with spaces in the name of steps. All of them failed.

@zc-devs
Copy link
Contributor

zc-devs commented Jan 25, 2024

I understand. As there are couple of solutions, I'm just trying to find out preferable.

I don't expect a certain label on pods

So, would choose auto translation space to hyphen.

@metawave
Copy link
Author

Yes I think that was the behaviour before. The problem has been introduced by #3204 I think, where the step name is now used to label the pod. That wasn't the case before. Now when a step name doesn't correspond to valid k8s-label regex (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?'), it will fail. A translation of non-valid characters (according to label spec) to hyphens would be the best solution for now IMO. It might be worth adding a test in pod_test.go, where a step has a non basic naming, like "build & deploy".

6543 pushed a commit that referenced this issue Jan 26, 2024
fernandrone pushed a commit to quintoandar/woodpecker that referenced this issue Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend/kubernetes bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants