Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0571e64b1a
|
||
|
|
7921840604 | ||
|
|
45be4a9fd9
|
||
|
|
02ccd5b8d7 | ||
|
|
2edb7b2b82
|
||
|
|
d472a906ac | ||
|
|
0151b6faf6
|
||
|
|
713d9a922a | ||
|
|
537c620051
|
||
|
|
a7b62868b6 | ||
|
|
84aa607c86
|
||
|
|
57524be30f |
@@ -15,9 +15,9 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-controller:
|
publish-images:
|
||||||
name: publish-controller
|
name: publish-controller
|
||||||
runs-on: [self-hosted, vm]
|
runs-on: [self-hosted, pod]
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-runner:
|
publish-images:
|
||||||
name: publish-runner
|
name: publish-runner
|
||||||
runs-on: [self-hosted, vm]
|
runs-on: [self-hosted, pod]
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|||||||
@@ -5,29 +5,20 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
jwt-svid:
|
jwt-svid:
|
||||||
runs-on: self-hosted
|
runs-on: [self-hosted, pod]
|
||||||
container:
|
|
||||||
volumes:
|
|
||||||
- /run/spire/agent-sockets:/run/spire/agent-sockets:ro
|
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch pinned SPIRE CLI
|
- name: Verify bundled SPIRE CLI
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
archive=/tmp/spire.tar.gz
|
command -v spire-agent
|
||||||
curl --fail --location --silent --show-error \
|
spire-agent -version
|
||||||
--output "$archive" \
|
|
||||||
https://github.com/spiffe/spire/releases/download/v1.15.3/spire-1.15.3-linux-amd64-musl.tar.gz
|
|
||||||
printf '%s %s\n' \
|
|
||||||
ca1a4d1155317bdd2afc7f36663828a10410c7c840e54725b90b4064b0a301c7 \
|
|
||||||
"$archive" | sha256sum --check --status
|
|
||||||
tar -xzf "$archive" -C /tmp spire-1.15.3/bin/spire-agent
|
|
||||||
|
|
||||||
- name: Fetch short-lived zot JWT-SVID
|
- name: Fetch short-lived zot JWT-SVID
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
/tmp/spire-1.15.3/bin/spire-agent api fetch jwt \
|
spire-agent api fetch jwt \
|
||||||
-audience zot \
|
-audience zot \
|
||||||
-socketPath /run/spire/agent-sockets/spire-agent.sock \
|
-socketPath /run/spire/agent-sockets/spire-agent.sock \
|
||||||
>/dev/null
|
>/dev/null
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ RUN groupadd --gid 2000 runner \
|
|||||||
&& useradd --uid 2000 --gid 2000 --groups docker --create-home --shell /bin/bash runner \
|
&& useradd --uid 2000 --gid 2000 --groups docker --create-home --shell /bin/bash runner \
|
||||||
&& printf 'runner ALL=(ALL) NOPASSWD:ALL\n' >/etc/sudoers.d/runner \
|
&& printf 'runner ALL=(ALL) NOPASSWD:ALL\n' >/etc/sudoers.d/runner \
|
||||||
&& chmod 0440 /etc/sudoers.d/runner \
|
&& chmod 0440 /etc/sudoers.d/runner \
|
||||||
&& install -d -o 2000 -g 2000 /data
|
&& install -d -o 2000 -g 2000 /data /workspace
|
||||||
|
|
||||||
COPY --from=runner /usr/local/bin/gitea-runner /usr/local/bin/gitea-runner
|
COPY --from=runner /usr/local/bin/gitea-runner /usr/local/bin/gitea-runner
|
||||||
COPY --from=controller /out/gitea-dynamic-runner /usr/local/bin/gitea-dynamic-runner
|
COPY --from=controller /out/gitea-dynamic-runner /usr/local/bin/gitea-dynamic-runner
|
||||||
COPY --from=spire /opt/spire/bin/spire-agent /opt/spire/bin/spire-agent
|
COPY --from=spire /opt/spire/bin/spire-agent /opt/spire/bin/spire-agent
|
||||||
|
RUN ln -s /opt/spire/bin/spire-agent /usr/local/bin/spire-agent
|
||||||
COPY config/runner.yaml /etc/gitea-runner/config.yaml
|
COPY config/runner.yaml /etc/gitea-runner/config.yaml
|
||||||
COPY --chmod=0755 scripts/gitea-job-started /usr/local/libexec/gitea-job-started
|
COPY --chmod=0755 scripts/gitea-job-started /usr/local/libexec/gitea-job-started
|
||||||
COPY --chmod=0755 scripts/gitea-opensandbox-runner /usr/local/libexec/gitea-opensandbox-runner
|
COPY --chmod=0755 scripts/gitea-opensandbox-runner /usr/local/libexec/gitea-opensandbox-runner
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ type ExecutorConfig struct {
|
|||||||
FacadeSPIFFEID string
|
FacadeSPIFFEID string
|
||||||
WorkloadAPIAddr string
|
WorkloadAPIAddr string
|
||||||
RunnerBinary string
|
RunnerBinary string
|
||||||
|
RunnerConfig string
|
||||||
ListenAddress string
|
ListenAddress string
|
||||||
WorkDir string
|
WorkDir string
|
||||||
Stdout *os.File
|
Stdout *os.File
|
||||||
@@ -35,6 +36,9 @@ func RunExecutor(ctx context.Context, config ExecutorConfig) error {
|
|||||||
if config.RunnerBinary == "" {
|
if config.RunnerBinary == "" {
|
||||||
config.RunnerBinary = "gitea-runner"
|
config.RunnerBinary = "gitea-runner"
|
||||||
}
|
}
|
||||||
|
if config.RunnerConfig == "" {
|
||||||
|
config.RunnerConfig = "/etc/gitea-runner/config.yaml"
|
||||||
|
}
|
||||||
if config.ListenAddress == "" {
|
if config.ListenAddress == "" {
|
||||||
config.ListenAddress = "127.0.0.1:0"
|
config.ListenAddress = "127.0.0.1:0"
|
||||||
}
|
}
|
||||||
@@ -93,7 +97,7 @@ func RunExecutor(ctx context.Context, config ExecutorConfig) error {
|
|||||||
return errors.Join(readyErr, shutdownErr, serverErr)
|
return errors.Join(readyErr, shutdownErr, serverErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
command := exec.CommandContext(ctx, config.RunnerBinary, "daemon", "--once")
|
command := exec.CommandContext(ctx, config.RunnerBinary, runnerArguments(config.RunnerConfig)...)
|
||||||
command.Dir = workDir
|
command.Dir = workDir
|
||||||
command.Stdout = config.Stdout
|
command.Stdout = config.Stdout
|
||||||
command.Stderr = config.Stderr
|
command.Stderr = config.Stderr
|
||||||
@@ -108,6 +112,10 @@ func RunExecutor(ctx context.Context, config ExecutorConfig) error {
|
|||||||
return errors.Join(runnerErr, shutdownErr, serverErr)
|
return errors.Join(runnerErr, shutdownErr, serverErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runnerArguments(configFile string) []string {
|
||||||
|
return []string{"daemon", "--config", configFile, "--once"}
|
||||||
|
}
|
||||||
|
|
||||||
func waitForFacade(ctx context.Context, endpoint string) error {
|
func waitForFacade(ctx context.Context, endpoint string) error {
|
||||||
client := &http.Client{Timeout: 2 * time.Second}
|
client := &http.Client{Timeout: 2 * time.Second}
|
||||||
ticker := time.NewTicker(250 * time.Millisecond)
|
ticker := time.NewTicker(250 * time.Millisecond)
|
||||||
@@ -143,7 +151,8 @@ func ExecutorConfigFromEnvironment() (ExecutorConfig, error) {
|
|||||||
config := ExecutorConfig{
|
config := ExecutorConfig{
|
||||||
AssignmentID: os.Getenv(EnvAssignmentID), Capability: os.Getenv(EnvCapability),
|
AssignmentID: os.Getenv(EnvAssignmentID), Capability: os.Getenv(EnvCapability),
|
||||||
Backend: backend, FacadeURL: os.Getenv(EnvFacadeURL), FacadeSPIFFEID: os.Getenv(EnvFacadeID),
|
Backend: backend, FacadeURL: os.Getenv(EnvFacadeURL), FacadeSPIFFEID: os.Getenv(EnvFacadeID),
|
||||||
RunnerBinary: os.Getenv("GITEA_RUNNER_BINARY"), ListenAddress: "127.0.0.1:0",
|
RunnerBinary: os.Getenv("GITEA_RUNNER_BINARY"), RunnerConfig: os.Getenv("GITEA_RUNNER_CONFIG_FILE"),
|
||||||
|
ListenAddress: "127.0.0.1:0",
|
||||||
Stdout: os.Stdout, Stderr: os.Stderr,
|
Stdout: os.Stdout, Stderr: os.Stderr,
|
||||||
}
|
}
|
||||||
if config.AssignmentID == "" || config.Capability == "" || config.FacadeURL == "" || config.FacadeSPIFFEID == "" {
|
if config.AssignmentID == "" || config.Capability == "" || config.FacadeURL == "" || config.FacadeSPIFFEID == "" {
|
||||||
|
|||||||
@@ -4,11 +4,19 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"reflect"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestRunnerArgumentsLoadJobHooksConfig(t *testing.T) {
|
||||||
|
want := []string{"daemon", "--config", "/etc/gitea-runner/config.yaml", "--once"}
|
||||||
|
if got := runnerArguments("/etc/gitea-runner/config.yaml"); !reflect.DeepEqual(got, want) {
|
||||||
|
t.Fatalf("runner arguments = %q, want %q", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestWaitForFacadeRetriesTransientGatewayFailure(t *testing.T) {
|
func TestWaitForFacadeRetriesTransientGatewayFailure(t *testing.T) {
|
||||||
var requests atomic.Int32
|
var requests atomic.Int32
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, _ *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, _ *http.Request) {
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ if [[ -f /sys/fs/cgroup/cgroup.controllers ]]; then
|
|||||||
'
|
'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo sh -c 'exec nohup dockerd "$@" >/tmp/dockerd.log 2>&1' sh \
|
sudo sh -c 'nohup dockerd "$@" </dev/null >/tmp/dockerd.log 2>&1 &' sh \
|
||||||
--host=unix:///var/run/docker.sock \
|
--host=unix:///var/run/docker.sock \
|
||||||
--storage-driver="$storage_driver" &
|
--storage-driver="$storage_driver"
|
||||||
printf '%s\n' 'waiting for job Docker daemon'
|
printf '%s\n' 'waiting for job Docker daemon'
|
||||||
for ((attempt = 0; attempt < wait_seconds; attempt++)); do
|
for ((attempt = 0; attempt < wait_seconds; attempt++)); do
|
||||||
if docker info >/dev/null 2>&1; then
|
if docker info >/dev/null 2>&1; then
|
||||||
|
|||||||
Reference in New Issue
Block a user