Feature request - drone agents set port from env variable

Hello! I’d like to continue.

https://github.com/drone/drone/issues/2281

So, i am massively misunderstanding, maybe.

We’ve got:

1 drone server
2 drone agents
1 host

Lets take a look at http://docs.drone.io/installation/

version: '2'

services:
  drone-server:
    image: drone/drone:0.8

    ports:
      - 80:8000
      - 9000
    volumes:
      - /var/lib/drone:/var/lib/drone/
    restart: always
    environment:
      - DRONE_OPEN=true
      - DRONE_HOST=${DRONE_HOST}
      - DRONE_GITHUB=true
      - DRONE_GITHUB_CLIENT=${DRONE_GITHUB_CLIENT}
      - DRONE_GITHUB_SECRET=${DRONE_GITHUB_SECRET}
      - DRONE_SECRET=${DRONE_SECRET}

  drone-agent:
    image: drone/agent:0.8

    command: agent
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=drone-server:9000
      - DRONE_SECRET=${DRONE_SECRET}

You’re telling me, that DRONE_SERVER env var will change port agent is listening on.
I can’t see how.

Atm i’ve got one server and two agents on single host, agent’s are both listening to port 3000, it’s being port_mapped to random port on host. Everything is working, but clearly it’s not best practice, since agent doesn’t know port_mapped port, and there are errors in logs:

Dec 14 14:21:31 frankenci logz server frankenci ci0[1530]: INFO: 2017/12/14 14:21:31 grpc: Server.Serve failed to create ServerTransport:  connection error: desc = "transport: write tcp 172.17.0.2:9000->10.132.0.2:38194: write: broken pipe"
Dec 14 14:21:41 frankenci logz server frankenci ci0[1530]: INFO: 2017/12/14 14:21:41 grpc: Server.Serve failed to create ServerTransport:  connection error: desc = "transport: write tcp 172.17.0.2:9000->10.132.0.2:38206: write: broken pipe"
Dec 14 14:21:51 frankenci logz server frankenci ci0[1530]: INFO: 2017/12/14 14:21:51 transport: http2Server.HandleStreams failed to receive the preface from client: read tcp 172.17.0.2:9000->10.132.0.2:38220: read: connection reset by peer
Dec 14 14:22:01 frankenci logz server frankenci ci0[1530]: INFO: 2017/12/14 14:22:01 grpc: Server.Serve failed to create ServerTransport:  connection error: desc = "transport: write tcp 172.17.0.2:9000->10.132.0.2:38234: write: broken pipe"
Dec 14 14:22:11 frankenci logz server frankenci ci0[1530]: INFO: 2017/12/14 14:22:11 grpc: Server.Serve failed to create ServerTransport:  connection error: desc = "transport: write tcp 172.17.0.2:9000->10.132.0.2:38248: write: broken pipe"

So i’d like to set some variable to tell drone agent to listen to different port, and start using docker hostmode for example.

Thanks a lot in advance! Hope i’m just dumb and there is solution)

Typically you do not need to run multiple agents on a single server. Such a configuration would not be recommended for a real world production installation. If you want to increase build concurrency you should instead set the DRONE_MAX_PROCS agent environment variable.

Atm i’ve got one server and two agents on single host, agent’s are both listening to port 3000, it’s being port_mapped to random port on host. Everything is working, but clearly it’s not best practice, since agent doesn’t know port_mapped port, and there are errors in logs:

Those errors in your logs have nothing to do with the agent listening on port 3000. The agents open port 3000 for internal Docker health checks only. The errors in your logs indicate the agents are having problems connecting with the server on port 9000. Specifically, the connection is being broken by something on your host machine.

So i’d like to set some variable to tell drone agent to listen to different port, and start using docker hostmode for example.

So in summary, the agents are not listening on a port. The docker server is listening on port 9000, and the agents are connecting to this port. The sample configuration (at https://docs.drone.io/server/overview/) is the optimal configuration, and should not require any changes, assuming a properly configured host machine.

Thanks a lot! Gona check network/dns, since they’re connecting via service discovery.