forked from admin/ansible
fix(hermes_infra/gitea): add dedicated act_runner cache-server
The built-in act_runner cache-server binds to an interface unreachable
from per-job container networks (default container.network: ""), so
ACTIONS_CACHE_URL resolves to 192.168.112.21:37051 and every job burns
~9 minutes on:
::warning::Failed to save: reserveCache failed: connect ETIMEDOUT
::warning::Failed to restore: getCacheEntry failed: connect ETIMEDOUT
Measured on PR #15 in admin/brencher (gitea/actions/runs/16):
each of 3 jobs ~12 min wall-clock, of which 9 min is dead air waiting
for cache timeouts.
Run a dedicated act_runner cache-server on the same overlay network and
point the runner at it via external_server. Shared secret comes from a
Docker secret (gitea_cache_secret) read by both services via
ACT_RUNNER_EXTERNAL_SECRET_FILE.
The image's /usr/local/bin/run.sh entrypoint ignores argv and unconditionally
runs 'act_runner register && act_runner daemon' (the runner path), so
cache_server.service.command must call the act_runner binary directly with
the 'cache-server' subcommand: command: ["act_runner", "cache-server"].
Related: admin/brencher#15
Refs: gitea/actions/runs/16 (jobs #248/249/250)
This commit is contained in:
+8
-18
@@ -70,26 +70,16 @@ runner:
|
||||
- "ubuntu-22.04:docker://docker.gitea.com/runner-images:ubuntu-22.04"
|
||||
|
||||
cache:
|
||||
# Enable cache server to use actions/cache.
|
||||
enabled: true
|
||||
# The directory to store the cache data.
|
||||
# If it's empty, the cache data will be stored in $HOME/.cache/actcache.
|
||||
dir: ""
|
||||
# The host of the cache server.
|
||||
# It's not for the address to listen, but the address to connect from job containers.
|
||||
# So 0.0.0.0 is a bad choice, leave it empty to detect automatically.
|
||||
host: ""
|
||||
# The port of the cache server.
|
||||
# 0 means to use a random available port.
|
||||
port: 0
|
||||
# The external cache server URL. Valid only when enable is true.
|
||||
# If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself.
|
||||
# The URL should generally end with "/".
|
||||
# Requires external_secret below to be set to the same value on both this runner and the cache-server.
|
||||
external_server: ""
|
||||
# Shared secret between this runner and the external `act_runner cache-server`. Required when external_server
|
||||
# (or `act_runner cache-server`) is in use: the runner pre-registers each job's ACTIONS_RUNTIME_TOKEN with the
|
||||
# cache-server, and the cache-server enforces bearer auth + per-repo cache isolation.
|
||||
# Point at the dedicated gitea_cache_server container on the `gitea` overlay.
|
||||
# The runner's built-in cache server binds to an interface unreachable from
|
||||
# per-job container networks, causing ~9 min/job wasted on
|
||||
# "reserveCache failed: connect ETIMEDOUT" (see gitea/actions/runs/16 job #248).
|
||||
host: "gitea_cache_server"
|
||||
port: 37051
|
||||
external_server: "http://gitea_cache_server:37051/"
|
||||
# Read from the gitea_cache_secret Docker secret (see stack-compose.yml).
|
||||
external_secret: ""
|
||||
|
||||
container:
|
||||
|
||||
@@ -26,6 +26,7 @@ services:
|
||||
GITEA_RUNNER_NAME: "runner1"
|
||||
GITEA_RUNNER_LABELS: "runner_label1"
|
||||
# GITEA_RUNNER_EPHEMERAL: "1"
|
||||
ACT_RUNNER_EXTERNAL_SECRET_FILE: /run/secrets/gitea_cache_secret
|
||||
networks:
|
||||
- gitea
|
||||
# - nginx_ingress
|
||||
@@ -34,6 +35,33 @@ services:
|
||||
target: /cfg/config.yaml
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
secrets:
|
||||
- gitea_cache_secret
|
||||
|
||||
cache_server:
|
||||
# Bypass /usr/local/bin/run.sh: it ignores argv and unconditionally runs
|
||||
# `act_runner register && act_runner daemon`, which is the wrong mode for
|
||||
# a cache-server. Override the image entrypoint and call the act_runner
|
||||
# binary directly with the `cache-server` subcommand.
|
||||
#
|
||||
# Why entrypoint: [] + command — and not entrypoint: ["act_runner"]:
|
||||
# compose-go merges `entrypoint` and `command` into the Swarm
|
||||
# ContainerSpec.Args, leaving ContainerSpec.Command unset. The image
|
||||
# ENTRYPOINT ([/sbin/tini -- run.sh]) is therefore still used as the
|
||||
# actual process, with the merged Args handed to it as argv. So a
|
||||
# non-empty `entrypoint` doesn't help. We need entrypoint: [] to drop
|
||||
# the image entrypoint, and let the cache-server command run as PID 1.
|
||||
image: docker.io/gitea/act_runner:nightly
|
||||
entrypoint: []
|
||||
command: ["act_runner", "cache-server"]
|
||||
environment:
|
||||
ACT_RUNNER_EXTERNAL_SECRET_FILE: /run/secrets/gitea_cache_secret
|
||||
networks:
|
||||
- gitea
|
||||
volumes:
|
||||
- cache_data:/root/.cache/actcache
|
||||
secrets:
|
||||
- gitea_cache_secret
|
||||
|
||||
networks:
|
||||
nginx_ingress:
|
||||
@@ -45,6 +73,13 @@ configs:
|
||||
runner_config:
|
||||
file: ./config.yaml
|
||||
|
||||
secrets:
|
||||
gitea_cache_secret:
|
||||
# Create once before first deploy (or to rotate):
|
||||
# echo -n "$SECRET" | docker secret create gitea_cache_secret -
|
||||
# Then `docker stack deploy -c stack-compose.yml gitea`.
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
data:
|
||||
driver: local
|
||||
@@ -52,4 +87,5 @@ volumes:
|
||||
type: nfs
|
||||
o: addr=192.168.1.96
|
||||
device: :/root/volumes/gitea
|
||||
# device: :/media/DATA/runtime/gitea
|
||||
# device: :/media/DATA/runtime/gitea
|
||||
cache_data:
|
||||
Reference in New Issue
Block a user