Merge pull request 'Add caching for Gitea Actions, improve performance' (#659) from feature/actions_caching into master
Reviewed-on: #659 Reviewed-by: Greg <greg@kosmos.org>
This commit was merged in pull request #659.
This commit is contained in:
+1
-1
Submodule nodes updated: af52918423...528c84f98f
@@ -2,6 +2,20 @@
|
||||
|
||||
This file is used to list changes made in each version of the kosmos_gitea cookbook.
|
||||
|
||||
# 0.2.2
|
||||
|
||||
- Add `config.yaml` for the gitea actions runner, enabling the built-in cache
|
||||
server (listening on the Docker bridge gateway `172.17.0.1`) and bumping
|
||||
`runner.capacity` to 2 for concurrent job execution. Each runner gets a unique
|
||||
cache port derived from `cache_base_port` (8088) + its index in the runners
|
||||
data bag.
|
||||
- Set `container.network` to a user-defined Docker bridge network
|
||||
(`gitea-actions`, subnet `172.20.0.0/16`) so job containers get DNS resolution
|
||||
for service containers (e.g. `redis`) while keeping the cache server reachable
|
||||
at the network gateway `172.20.0.1`.
|
||||
- Open the cache port in the firewall for Docker bridge traffic
|
||||
(`172.20.0.0/16`), fixing `Request timeout` errors from `actions/cache`.
|
||||
|
||||
# 0.1.0
|
||||
|
||||
Initial release.
|
||||
|
||||
@@ -25,3 +25,17 @@ node.default["gitea"]["config"] = {
|
||||
|
||||
node.default["gitea"]["runner"]["version"] = "2.0.0"
|
||||
node.default["gitea"]["runner"]["checksum"] = "447156b33407ee045409f5552bd4a188a315cdd4085b4b498d8d4a9ad26c9f73"
|
||||
node.default["gitea"]["runner"]["cache_base_port"] = 8088
|
||||
node.default["gitea"]["runner"]["config"] = {
|
||||
"runner" => {
|
||||
"capacity" => 2
|
||||
},
|
||||
"container" => {
|
||||
"network" => "gitea-actions" # User-defined bridge network: provides DNS for service containers
|
||||
},
|
||||
"cache" => {
|
||||
"enabled" => true,
|
||||
"host" => "172.20.0.1" # Gateway of the gitea-actions network, reachable from job containers
|
||||
# Port is set per-runner (cache_base_port + index) in the runner recipe
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ maintainer_email 'ops@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/configures Gitea'
|
||||
long_description 'Installs/configures Gitea'
|
||||
version '0.2.1'
|
||||
version '0.2.2'
|
||||
chef_version '>= 14.0'
|
||||
|
||||
depends "firewall"
|
||||
|
||||
@@ -35,14 +35,39 @@ directory "#{working_directory}/runners" do
|
||||
mode "0700"
|
||||
end
|
||||
|
||||
runners.each do |runner|
|
||||
execute "create_gitea_actions_network" do
|
||||
command "docker network create --subnet 172.20.0.0/16 gitea-actions"
|
||||
not_if "docker network inspect gitea-actions"
|
||||
end
|
||||
|
||||
runners.each_with_index do |runner, index|
|
||||
runner_name = "gitea-runner-#{runner["org"]}"
|
||||
runner_dir = "#{working_directory}/runners/#{runner["org"]}"
|
||||
cache_port = node["gitea"]["runner"]["cache_base_port"] + index
|
||||
|
||||
directory runner_dir do
|
||||
mode "0700"
|
||||
end
|
||||
|
||||
runner_config = node["gitea"]["runner"]["config"].to_hash
|
||||
runner_config["cache"] = runner_config["cache"].merge("port" => cache_port)
|
||||
|
||||
firewall_rule "runner_cache_#{runner["org"]}" do
|
||||
command :allow
|
||||
port cache_port
|
||||
protocol :tcp
|
||||
source "172.20.0.0/16"
|
||||
end
|
||||
|
||||
template "#{runner_dir}/config.yaml" do
|
||||
source "runner.config.yaml.erb"
|
||||
mode "0640"
|
||||
owner "root"
|
||||
group "root"
|
||||
variables(config: runner_config)
|
||||
notifies :restart, "service[#{runner_name}]", :delayed
|
||||
end
|
||||
|
||||
bash "register_#{runner["org"]}_runner" do
|
||||
cwd runner_dir
|
||||
code <<-EOF
|
||||
@@ -67,7 +92,7 @@ gitea_runner register \
|
||||
Type: "simple",
|
||||
WorkingDirectory: runner_dir,
|
||||
Environment: "HOME=/root",
|
||||
ExecStart: "/usr/local/bin/gitea_runner daemon",
|
||||
ExecStart: "/usr/local/bin/gitea_runner daemon --config #{runner_dir}/config.yaml",
|
||||
ExecStartPre: "/bin/sleep 3", # Wait for Gitea's API to be up when restarting at the same time
|
||||
Restart: "always",
|
||||
},
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<%= @config.to_yaml.sub(/^---\n/, '') %>
|
||||
Reference in New Issue
Block a user