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

image value from yaml gets expanded to fully qualified name, breaking local backend #1003

Closed
4 tasks done
thestr4ng3r opened this issue Jun 27, 2022 · 1 comment
Closed
4 tasks done
Labels
bug Something isn't working
Milestone

Comments

@thestr4ng3r
Copy link
Contributor

Component

server

Describe the bug

When parsing the image in a pipeline yaml, the given value is always expanded to a fully qualified docker image name very early:

image = expandImage(container.Image)

For example, if you have image: alpine, you will get docker.io/library/alpine:latest.

First, it is questionable whether this kind of expansion should be done on the server at all, as the docker or podman on the agent machine could figure this out themselves, as @6543 noted on matrix.

But second, this is a major problem for the local backend where the image value is not interpreted as a docker image, but as the name of the shell to run commands in.
Currently there is this hack in place, which tries to chop off the prefix and suffix again:

Command = append(Command, proc.Image[18:len(proc.Image)-7])

So you pass image: bash and proc.Image[18:len(proc.Image)-7] will evaluate to bash. But this of course is only a very fragile workaround. For example it panics and crashes the agent as soon as you pass something like image: /bin/bash, which will not get anything added by the expansion.
This by itself could also be fixed by not reusing the image key for the shell and instead adding an additional one.

System Info

3f73d5b

Additional context

No response

Validations

@6543 6543 added this to the 1.0.0 milestone Jul 1, 2022
@6543 6543 added bug Something isn't working and removed pending:bug labels Jul 1, 2022
6543 added a commit to 6543-forks/woodpecker that referenced this issue Jul 2, 2022
6543 added a commit that referenced this issue Aug 26, 2022
* pipeline compiler should not alter specifyed image

adress #1003
@6543 6543 closed this as completed Aug 26, 2022
@6543 6543 closed this as completed Aug 26, 2022
@6543
Copy link
Member

6543 commented Aug 26, 2022

☝️ race condition 😆

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

No branches or pull requests

2 participants