Docker runner: Cannot accept stage: 400 Bad Request

Hello,

I have trouble getting the docker runner to work on my Raspberry Pi.
When I try to start a build I only get the error “Cannot accept stage” with error detail saying “400: Bad Request”.
I have checked my configuration multiple times but I don’t see anything wrong with it. The only thing I’m doing differently from the docs is that I use docker-compose with both services in the same file, but I don’t see why that wouldn’t work.

My server+runner docker-compose configuration:

version: '3'

services:
        drone:
                image: "drone/drone:1"
                restart: always
                ports:
                        - "3001:80"

                environment:
                        DRONE_GITEA_CLIENT_ID: <omitted>
                        DRONE_GITEA_CLIENT_SECRET: <omitted
                        DRONE_GITEA_SERVER: <omitted>
                        DRONE_RPC_SECRET: <omitted>
                        DRONE_SERVER_HOST: <omitted>
                        DRONE_SERVER_PROTO: https
                        DRONE_TLS_AUTOCERT: "false"
                        DRONE_AGENTS_ENABLED: "false"
                        DRONE_DATABASE_DRIVER: postgres
                        DRONE_DATABASE_DATASOURCE: <omitted>
                        DRONE_LOGS_TRACE: "true"

                volumes:
                        - /var/lib/drone:/data

        drone-docker-runner:
                image: "drone/drone-runner-docker:1"
                restart: always
                depends_on:
                        - drone
                ports:
                        - "5000:3000"
                links:
                        - drone

                environment:
                        DRONE_RPC_PROTO: http
                        DRONE_RPC_HOST: drone:80 
                        DRONE_RPC_SECRET: <omitted>
                        DRONE_RUNNER_CAPACITY: 1
                        DRONE_RUNNER_NAME: Raspberry Pi
                        DRONE_UI_USERNAME: Sunner
                        DRONE_UI_PASSWORD: <omitted>
                        DRONE_LOGS_TRACE: "true"

                volumes:
                        - /var/run/docker.sock:/var/run/docker.sock

I have omitted some values for security reasons, but I can safely say that the secrets match.
I also don’t seem to have any networking issues, as the server and runner appear to connect successfully. Since they are on the same docker network, there also shouldn’t be any proxy issues here.

My pipeline configuration looks like this (just a test repo for testing the runner):

kind: pipeline
type: docker
name: drone-test

platform:
  os: linux
  arch: arm

steps:
  - name: test
    image: alpine:3.10
    commands:
      - echo "Hallo Drone CI"

My server logs:

...
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}
{"arch":"arm","kernel":"","kind":"pipeline","level":"debug","msg":"manager: request queue item","os":"linux","time":"2020-01-30T18:57:00Z","type":"docker","variant":""}

My runner logs:

...
time="2020-01-30T18:58:21Z" level=debug msg="poller: request stage from remote server" thread=1
time="2020-01-30T18:58:21Z" level=debug msg="stage received" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=error msg="cannot accept stage" error="400 Bad Request" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=debug msg="poller: request stage from remote server" thread=1
time="2020-01-30T18:58:21Z" level=debug msg="stage received" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=error msg="cannot accept stage" error="400 Bad Request" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=debug msg="poller: request stage from remote server" thread=1
time="2020-01-30T18:58:21Z" level=debug msg="stage received" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=error msg="cannot accept stage" error="400 Bad Request" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=debug msg="poller: request stage from remote server" thread=1
time="2020-01-30T18:58:21Z" level=debug msg="stage received" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=error msg="cannot accept stage" error="400 Bad Request" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=debug msg="poller: request stage from remote server" thread=1
time="2020-01-30T18:58:21Z" level=debug msg="stage received" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=error msg="cannot accept stage" error="400 Bad Request" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=debug msg="poller: request stage from remote server" thread=1
time="2020-01-30T18:58:21Z" level=debug msg="stage received" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=error msg="cannot accept stage" error="400 Bad Request" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=debug msg="poller: request stage from remote server" thread=1
time="2020-01-30T18:58:21Z" level=debug msg="stage received" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=error msg="cannot accept stage" error="400 Bad Request" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=debug msg="poller: request stage from remote server" thread=1
time="2020-01-30T18:58:21Z" level=debug msg="stage received" stage.id=83 stage.name=drone-test stage.number=1 thread=1
time="2020-01-30T18:58:21Z" level=error msg="cannot accept stage" error="400 Bad Request" stage.id=83 stage.name=drone-test stage.number=1 thread=1

Is there anything wrong here?

Hi there, I see you have configured a runner (agent) but you have set DRONE_AGENTS_ENABLED to false. This disables runners (agents) and prevents them from establishing a connection.

Ah ok, didn’t know that. I’ve changed the value here to “true”, restarted the containers and restarted the build, but I still get the same error. Anything else that could be an issue?

I recommend look at Builds are Stuck in Pending Status and enabling trace logging in your runner, as suggested in the Network Problems section. This might help you debug further.

I already did that (as can be seen in the docker-compose.yml in my initial post). I only get the 400 Bad Request in my log and nothing else.

please enable the http dumps as shown here:
https://docs.drone.io/runner/docker/configuration/logging/

Ok, that did the trick.
The reason it didn’t work was because I had a space in my runner machine name (DRONE_RUNNER_NAME) and appearently Drone doesn’t like that. It’s working now, thanks for your help

This was helpful. I had the same issue and it was caused by the “DRONE_RUNNER_NAME=Runner 1” having a space in the name. When I removed the space it began working.