Open liv-io opened 6 months ago
@liv-io I found a bug that could be related to this.
It's currently open as PR: https://github.com/woodpecker-ci/woodpecker/pull/3770
Is it possible for you to try this out and check if it fixes the bug? Or do you still have this issue?
Is it possible for you to try this out and check if it fixes the bug? Or do you still have this issue?
@qwerty287 Yes, certainly. Thanks for your efforts. Please give me a few days, but I should be able to send you a feedback hopefully this week.
@qwerty287 Your branch has already been merged into 2.6.0, right?
I quickly made the update from 2.5.0 to 2.6.0 and removed the DOCKER_HOST
environment variable.
When starting woodpecker-agent
it immediately exits with:
{"level":"info","time":"2024-06-15T12:09:14Z","message":"log level: info"}
{"level":"info","time":"2024-06-15T12:09:14Z","message":"no agent config found at '/etc/woodpecker/agent.conf', start with defaults"}
{"level":"error","engine":"docker","time":"2024-06-15T12:09:14Z","message":"selected backend engine is unavailable"}
{"level":"fatal","error":"selected backend engine docker is unavailable","time":"2024-06-15T12:09:14Z","message":"error running agent"}
If I add the environment variable again, the woodpecker-agent
starts fine:
export DOCKER_HOST="unix://run/podman/podman.sock"
Your branch has already been merged into 2.6.0, right?
Yes.
When starting woodpecker-agent it immediately exits with:
Did you start with the CLI argument?
If you don't use "standard" docker (e.g. podman) it is necessary to set an env var or the CLI argument. It only worked with DOCKER_HOST
before, and now it should also work with the CLI argument and WOODPECKER_BACKEND_DOCKER_HOST
.
Did you start with the CLI argument?
Yes, I believe so. This is the command I am running.
Command:
exec /usr/local/bin/woodpecker-agent \
--grpc-token <token> \
--backend-engine docker \
--backend-docker-ipv6 false \
--backend-docker-host unix://run/podman/podman.sock \
--backend-docker-tls-verify false \
--grpc-skip-insecure true \
--healthcheck true \
--hostname woodpecker-agent \
--log-level info \
--grpc-secure false
Output:
8:49AM INF log level: info
8:49AM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
8:49AM ERR selected backend engine is unavailable engine=docker
8:49AM FTL error running agent error="selected backend engine docker is unavailable"
The moment I export the environment variable:
Command:
export DOCKER_HOST="unix://run/podman/podman.sock"
exec /usr/local/bin/woodpecker-agent \
--grpc-token <token> \
--backend-engine docker \
--backend-docker-ipv6 false \
--backend-docker-host unix://run/podman/podman.sock \
--backend-docker-tls-verify false \
--grpc-skip-insecure true \
--healthcheck true \
--hostname woodpecker-agent \
--log-level info \
--grpc-secure false
Output:
8:51AM INF log level: info
8:51AM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
8:51AM ERR could not persist agent config at '/etc/woodpecker/agent.conf' error="open /etc/woodpecker/agent.conf: no such file or directory"
8:51AM INF starting Woodpecker agent with version '2.6.0' and backend 'docker' using platform 'linux/amd64' running up to 1 pipelines in parallel
Is it possible for you to compile/run a custom binary so we can some debugging prints?
Is it possible for you to compile/run a custom binary so we can some debugging prints?
Yes, certainly. It is a busy week for me, but I can try to build/run a custom release. Is there a branch I can try?
Not yet, I'll try some things later this week but it's also busy for me ;)
@liv-io Here you go: https://github.com/qwerty287/woodpecker/tree/debug-print
I only changed 3 lines.
@qwerty287 Thanks a lot!
This is the output I get.
Without environment variable:
6:27PM INF log level: info
6:27PM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: docker host: ''
DOCKER DEBUG: cli context ok
DOCKER DEBUG: flag not set, checking default
6:27PM ERR selected backend engine is unavailable engine=docker
6:27PM FTL error running agent error="selected backend engine docker is unavailable"
With environment variable:
6:29PM INF log level: info
6:29PM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: docker host: 'unix://run/podman/podman.sock'
DOCKER DEBUG: cli context ok
6:29PM ERR could not persist agent config at '/etc/woodpecker/agent.conf' error="open /etc/woodpecker/agent.conf: no such file or directory"
6:29PM INF starting Woodpecker agent with version 'dev' and backend 'docker' using platform 'linux/amd64' running up to 1 pipelines in parallel
Let me know if I need to provide additional details.
Thanks for your help.
Did you use the CLI flag in both cases? If not, can you try this?
It seems to work without the --backend-engine docker
flag.
Command:
/usr/local/bin/woodpecker-agent \
--grpc-token <token> \
--backend-docker-ipv6 false \
--backend-docker-host unix://run/podman/podman.sock \
--backend-docker-tls-verify false \
--grpc-skip-insecure true \
--healthcheck true \
--hostname woodpecker-agent \
--log-level info \
--grpc-secure false
Output:
7:44PM INF log level: info
7:44PM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: cli context ok
DOCKER DEBUG: flag not set, checking default
DOCKER DEBUG: docker host: ''
7:44PM ERR could not persist agent config at '/etc/woodpecker/agent.conf' error="open /etc/woodpecker/agent.conf: no such file or directory"
7:44PM INF starting Woodpecker agent with version 'dev' and backend 'local' using platform 'linux/amd64' running up to 1 pipelines in parallel
Also when adding the environment variable (again without the --backend-engine docker
flag).
Command:
export DOCKER_HOST="unix://run/podman/podman.sock"
/usr/local/bin/woodpecker-agent \
--grpc-token <token> \
--backend-docker-ipv6 false \
--backend-docker-host unix://run/podman/podman.sock \
--backend-docker-tls-verify false \
--grpc-skip-insecure true \
--healthcheck true \
--hostname woodpecker-agent \
--log-level info \
--grpc-secure false
Output:
7:48PM INF log level: info
7:48PM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: cli context ok
DOCKER DEBUG: docker host: 'unix://run/podman/podman.sock'
DOCKER DEBUG: cli context ok
7:48PM ERR could not persist agent config at '/etc/woodpecker/agent.conf' error="open /etc/woodpecker/agent.conf: no such file or directory"
7:48PM INF starting Woodpecker agent with version 'dev' and backend 'docker' using platform 'linux/amd64' running up to 1 pipelines in parallel
I mean the backend-docker-host
flag.
This one is the problem. In your case, the engine is selected correctly, but it then fails because the docker backend says it's not available. It should work however.
Can you check the branch again? I added some more prints
I don't quite understand. Sorry for confusing things.
Since I am not using Docker, but Podman I thought specifying the --backend-docker-host
flag (or the environment variable export DOCKER_HOST="unix://run/podman/podman.sock"
) is a must since the path is different.
I ran a version of your latest branch/commit. These are the results:
All flags, without environment variable:
/usr/local/bin/woodpecker-agent --grpc-token <token> --backend-engine docker --backend-docker-ipv6 false --backend-docker-host unix://run/podman/podman.sock --backend-docker-tls-verify false --grpc-skip-insecure true --healthcheck true --hostname woodpecker-agent --log-level info --grpc-secure false
4:11PM INF log level: info
4:11PM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: docker host: ''
DOCKER DEBUG: cli context ok
DOCKER DEBUG: IsSet false, Str
DOCKER DEBUG: flag not set, checking default
4:11PM ERR selected backend engine is unavailable engine=docker
4:11PM FTL error running agent error="selected backend engine docker is unavailable"
All flags, with environment variable:
export DOCKER_HOST="unix://run/podman/podman.sock"
/usr/local/bin/woodpecker-agent --grpc-token <token> --backend-engine docker --backend-docker-ipv6 false --backend-docker-host unix://run/podman/podman.sock --backend-docker-tls-verify false --grpc-skip-insecure true --healthcheck true --hostname woodpecker-agent --log-level info --grpc-secure false
4:11PM INF log level: info
4:11PM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: docker host: 'unix://run/podman/podman.sock'
DOCKER DEBUG: cli context ok
DOCKER DEBUG: IsSet true, Str unix://run/podman/podman.sock
4:11PM ERR could not persist agent config at '/etc/woodpecker/agent.conf' error="open /etc/woodpecker/agent.conf: no such file or directory"
4:11PM INF starting Woodpecker agent with version 'dev' and backend 'docker' using platform 'linux/amd64' running up to 1 pipelines in parallel
Without --backend-docker-host
, without environment variable:
/usr/local/bin/woodpecker-agent --grpc-token <token> --backend-engine docker --backend-docker-ipv6 false --backend-docker-tls-verify false --grpc-skip-insecure true --healthcheck true --hostname woodpecker-agent --log-level info --grpc-secure false
4:11PM INF log level: info
4:11PM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: docker host: ''
DOCKER DEBUG: cli context ok
DOCKER DEBUG: IsSet false, Str
DOCKER DEBUG: flag not set, checking default
4:11PM ERR selected backend engine is unavailable engine=docker
4:11PM FTL error running agent error="selected backend engine docker is unavailable"
Without --backend-docker-host
, with environment variable:
export DOCKER_HOST="unix://run/podman/podman.sock"
/usr/local/bin/woodpecker-agent --grpc-token <token> --backend-engine docker --backend-docker-ipv6 false --backend-docker-tls-verify false --grpc-skip-insecure true --healthcheck true --hostname woodpecker-agent --log-level info --grpc-secure false
4:12PM INF log level: info
4:12PM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: docker host: 'unix://run/podman/podman.sock'
DOCKER DEBUG: cli context ok
DOCKER DEBUG: IsSet true, Str unix://run/podman/podman.sock
4:12PM ERR could not persist agent config at '/etc/woodpecker/agent.conf' error="open /etc/woodpecker/agent.conf: no such file or directory"
4:12PM INF starting Woodpecker agent with version 'dev' and backend 'docker' using platform 'linux/amd64' running up to 1 pipelines in parallel
Without --backend-engine docker
, without environment variable:
/usr/local/bin/woodpecker-agent --grpc-token <token> --backend-engine docker --backend-docker-ipv6 false --backend-docker-host unix://run/podman/podman.sock --backend-docker-tls-verify false --grpc-skip-insecure true --healthcheck true --hostname woodpecker-agent --log-level info --grpc-secure false
4:24PM INF log level: info
4:24PM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: docker host: ''
DOCKER DEBUG: cli context ok
DOCKER DEBUG: IsSet false, Str
DOCKER DEBUG: flag not set, checking default
4:24PM ERR selected backend engine is unavailable engine=docker
4:24PM FTL error running agent error="selected backend engine docker is unavailable"
Without --backend-engine docker
, with environment variable:
export DOCKER_HOST="unix://run/podman/podman.sock"
/usr/local/bin/woodpecker-agent --grpc-token <token> --backend-engine docker --backend-docker-ipv6 false --backend-docker-host unix://run/podman/podman.sock --backend-docker-tls-verify false --grpc-skip-insecure true --healthcheck true --hostname woodpecker-agent --log-level info --grpc-secure false
4:25PM INF log level: info
4:25PM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: docker host: 'unix://run/podman/podman.sock'
DOCKER DEBUG: cli context ok
DOCKER DEBUG: IsSet true, Str unix://run/podman/podman.sock
4:25PM ERR could not persist agent config at '/etc/woodpecker/agent.conf' error="open /etc/woodpecker/agent.conf: no such file or directory"
4:25PM INF starting Woodpecker agent with version 'dev' and backend 'docker' using platform 'linux/amd64' running up to 1 pipelines in parallel
The problem is: The backend is correctly selected, but the docker backend says it is not available. If you set a custom host, it should actually work however… The cli parser lib does not recognise the flag somehow.
The only reason I can currently imagine is that there is some problem with the boolean flags. Can you try running the agent without all options that are not required? E.g. backend-docker-ipv6
.
The only case that's interesting here is without env var, but with flag.
Huh, it seems like your intuition was right. Thanks a lot for your help by the way!
I simply removed the --backend-docker-ipv6 false
flag (without specifying the env var) and this is the output:
7:44AM INF log level: info
7:44AM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: docker host: 'unix://run/podman/podman.sock'
DOCKER DEBUG: cli context ok
DOCKER DEBUG: IsSet true, Str unix://run/podman/podman.sock
7:44AM ERR could not persist agent config at '/etc/woodpecker/agent.conf' error="open /etc/woodpecker/agent.conf: no such file or directory"
7:44AM INF starting Woodpecker agent with version 'dev' and backend 'docker' using platform 'linux/amd64' running up to 1 pipelines in parallel
It selects the docker
backend (and the socket path is correct too).
Do you want me to test more variations of my command?
Can you try --backend-docker-ipv6=false
?
Seems to work :+1:
/usr/local/bin/woodpecker-agent --grpc-token <token> --backend-engine docker --backend-docker-ipv6=false --backend-docker-host unix://run/podman/podman.sock --backend-docker-tls-verify false --grpc-skip-insecure true --healthcheck true --hostname woodpecker-agent --log-level info --grpc-secure false
1:44PM INF log level: info
1:44PM INF no agent config found at '/etc/woodpecker/agent.conf', start with defaults
DOCKER DEBUG: docker host: 'unix://run/podman/podman.sock'
DOCKER DEBUG: cli context ok
DOCKER DEBUG: IsSet true, Str unix://run/podman/podman.sock
1:44PM ERR could not persist agent config at '/etc/woodpecker/agent.conf' error="open /etc/woodpecker/agent.conf: no such file or directory"
1:44PM INF starting Woodpecker agent with version 'dev' and backend 'docker' using platform 'linux/amd64' running up to 1 pipelines in parallel
Am I supposed to use the equal sign for all --
(double dash) options?
You can do, that makes it more clear.
I can open an issue in the parser library to find out why this doesn't work if you think that's helpful
The woodpecker-agent --help
command does not mention the equal sign for any of the commands.
...
--backend-docker-ipv6 backend docker enable IPV6 (default: false) [$WOODPECKER_BACKEND_DOCKER_ENABLE_IPV6]
--backend-docker-network value backend docker network [$WOODPECKER_BACKEND_DOCKER_NETWORK]
--backend-docker-volumes value backend docker volumes (comma separated) [$WOODPECKER_BACKEND_DOCKER_VOLUMES]
...
Would you update the output or leave as is?
I can open an issue in the parser library to find out why this doesn't work if you think that's helpful
Do you think both options (with and without equal sign) should work? If yes, maybe we it is worth creating a ticket. Which parser library is being used?
Do you think both options (with and without equal sign) should work? If yes, maybe we it is worth creating a ticket.
I need to check that too first, but I think it should work.
Which parser library is being used?
I need to check that too first, but I think it should work.
It seems adding an equal sign to all "long options" (with double dash) does not work. I can provide additional details if this is valuable.
Thanks for finding the library!
Component
agent
Describe the bug
When running
woodpacker-agent
without a configuration file but only command-line arguments, the backend engine cannot be defined. Somehow the argument--backend-engine
does not work and it falls back to local.The following command does not select the
docker
backend:While the agent starts, it immediately prints the following message to the logs (
backend 'local'
):When I export the environment variable
DOCKER_HOST
and run the same command again, the correct backend is selected:The log output is (
backend 'docker'
):System Info
Output of
https://<your-woodpecker-instance>/version
:Additional info on my setup:
Containerfile: https://github.com/liv-io/oci-containers/blob/main/woodpecker-agent/Containerfile
Entrypoint/CMD script: https://github.com/liv-io/oci-containers/blob/main/woodpecker-agent/cmd.sh
Additional context
No response
Validations
next
version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]