1.0.0-rc6: Resources limitation (global) possible?

Hello everybody,
at the moment I try out drone 1.0.0-rc6 and drone latest (single-machine and multi-machine).
In drone 0.8.x I could limit the resources “globally” by setting them as environment variables, so no need to puth these in a .drone.yml:

DRONE_LIMIT_CPU_SHARES=199
DRONE_LIMIT_CPU_SET=1,3

Is this possible in the current (rc)-version of drone without taking these entries in the .drone.yml?
Or is there a way to set these limits for all pipeline steps as variable, so that not every step has to be explicit limited?

Another question would be:
Who basically limits a multi-machine (drone-server or drone-agent)?
With multi-machine, the drone-agent should “deliver” these settings, right?

Example:

# change the cpu shares
LIMIT_CPU_SHARES="199"
# set the cpus allowed to execute containers
LIMIT_CPU_SET="1,3"

Configuration multi-machine (drone-server):

docker run \
  --volume=/var/lib/drone:/data \
  --env=DRONE_GIT_ALWAYS_AUTH=false \
  --env=DRONE_GITEA_SERVER=${DRONE_GITEA_SERVER} \
  --env=DRONE_RPC_SECRET=${DRONE_RPC_SECRET} \
  --env=DRONE_SERVER_HOST=${DRONE_SERVER_HOST} \
  --env=DRONE_SERVER_PROTO=${DRONE_SERVER_PROTO} \
  --env=DRONE_TLS_AUTOCERT=false \
  --env=DRONE_AGENTS_ENABLED=true \
  --publish=80:80 \
  --publish=443:443 \
  --restart=always \
  --detach=true \
  --name=drone \
  drone/drone:1.0.0-rc.6

Configuration multi-machine (drone-agent):

docker run \
  --volume=/var/run/docker.sock:/var/run/docker.sock \
  --env=DRONE_RPC_SERVER=${DRONE_RPC_SERVER} \
  --env=DRONE_RPC_SECRET=${DRONE_RPC_SECRET} \
  --env=DRONE_LIMIT_CPU_SHARES=${LIMIT_CPU_SHARES} \
  --env=DRONE_LIMIT_CPU_SET=${LIMIT_CPU_SET} \
  --env=DRONE_RUNNER_CAPACITY=1 \
  --env=DRONE_RUNNER_NAME=agent-smith \
  --restart=always \
  --detach=true \
  --name=drone-agent \
  drone/agent:1.0.0-rc.6

Unfortunately, my configuration does not work as desired.
On the drone-agent side all available (4) cpu cores are running. The limitation is not executed.

Same behaviour here with drone 1.6.2.
I set resource limits parameters to my agents:

            - "DRONE_MEMORY_LIMIT=4294967296"  # 4Go
            - "DRONE_MEMORY_SWAP_LIMIT=0"
            - "DRONE_CPU_SHARES=100"           # Low CPU priority
            - "DRONE_RUNNER_MAX_PROCS=3"

I see the vars when I docker inspect an agent, but the build containers have no docker resource limitations when I docker inspect them.

You should be using drone/drone-runner-docker instead of drone/agent. The documentation references the former, and the latter was deprecated. You can find the list of valid configuration parameters at https://docs.drone.io/runner/docker/configuration/reference

1 Like

Works like a charm with drone/drone-runner-docker :+1: