Compare commits

...

14 Commits

Author SHA1 Message Date
Erik Nobel
a2b335ad6a Github pkg: Bump github package to version 33 (#222) 2020-12-06 10:01:47 +09:00
Tom Bamford
56c57cbf71 ci: Replace deprecated crazy-max buildx action to use alternative docker actions (#197)
Deprecated action `crazy-max/setup-buildx-action@v1` has been replaced with:
  `docker/setup-qemu-action@v1`
  `docker/setup-buildx-action@v1`
  `docker/login-action@v1`
  `docker/build-push-action@v2`

See: https://github.com/crazy-max/ghaction-docker-buildx
2020-12-06 10:00:10 +09:00
Ahmad Hamade
837563c976 Adding priorityClassName to helm chart (#215)
* Adding priorityClassName to helm chart and README file

* removed README and revert chart version
2020-11-30 09:04:25 +09:00
ZacharyBenamram
df99f394b4 Remove 10 minute buffer to token expiration (#214)
Co-authored-by: Zachary Benamram <zacharybenamram@blend.com>
2020-11-30 09:03:27 +09:00
Shinnosuke Sawada
be25715e1e Use TLS for secure docker connection (#192) 2020-11-30 08:57:33 +09:00
Yusuke Kuoka
4ca825eef0 Publish runner images for v2.274.2
Ref #212
2020-11-27 08:49:58 +09:00
Yusuke Kuoka
e5101554b3 Fix release workflow to not use add-path
Fixes #208
2020-11-26 08:39:03 +09:00
Reinier Timmer
ee8fb5a388 parametrized working directory (#185)
* parametrized working directory

* manifests v3.0
2020-11-25 08:55:26 +09:00
Erik Nobel
4e93879b8f [BUG?]: Create mountpoint for /externals/ (#203)
* runner/controller: Add externals directory mount point

* Runner: Create hack for moving content of /runner/externals/ dir

* Externals dir Mount: mount examples for '__e/node12/bin/node' not found error
2020-11-25 08:53:47 +09:00
Shinnosuke Sawada
6ce6737f61 add dockerEnabled document (#193)
Follow-up for #191
2020-11-17 09:31:34 +09:00
Shinnosuke Sawada
4371de9733 add dockerEnabled option (#191)
Add dockerEnabled option for users who does not need docker and want not to run privileged container.
if `dockerEnabled == false`, dind container not run, and there are no privileged container.

Do the same as closed #96
2020-11-16 09:41:12 +09:00
Yusuke Kuoka
1fd752fca2 Use tcp DOCKER_HOST instead of sharing docker.sock (#177)
docker:dind container creates `/var/run/docker.sock` with root user and root group.
so, docker command in runner container needs root privileges to use docker.sock and docker action fails because lack of permission.

Use tcp connection between runner and docker container, so runner container doesn't need root privileges to run docker, and can run docker action.

Fixes #174
2020-11-16 09:32:29 +09:00
Shinnosuke Sawada
a4061d0625 gofmt ed 2020-11-12 09:20:06 +09:00
Shinnosuke Sawada
83857ba7e0 use tcp DOCKER_HOST instead of sharing docker.sock 2020-11-12 08:07:52 +09:00
25 changed files with 197 additions and 89 deletions

View File

@@ -27,46 +27,38 @@ jobs:
- name: actions-runner-dind - name: actions-runner-dind
dockerfile: dindrunner.Dockerfile dockerfile: dindrunner.Dockerfile
env: env:
RUNNER_VERSION: 2.274.1 RUNNER_VERSION: 2.274.2
DOCKER_VERSION: 19.03.12 DOCKER_VERSION: 19.03.12
DOCKERHUB_USERNAME: ${{ github.repository_owner }} DOCKERHUB_USERNAME: ${{ github.repository_owner }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx uses: docker/setup-buildx-action@v1
uses: crazy-max/ghaction-docker-buildx@v1
with: with:
buildx-version: latest version: latest
- name: Build Container Image - name: Login to DockerHub
working-directory: runner uses: docker/login-action@v1
if: ${{ github.event_name == 'pull_request' }}
run: |
docker buildx build \
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \
--platform linux/amd64,linux/arm64 \
--tag ${DOCKERHUB_USERNAME}/${{ matrix.name }}:v${RUNNER_VERSION} \
--tag ${DOCKERHUB_USERNAME}/${{ matrix.name }}:latest \
-f ${{ matrix.dockerfile }} .
- name: Login to GitHub Docker Registry
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
if: ${{ github.event_name == 'push' }} if: ${{ github.event_name == 'push' }}
env: with:
DOCKERHUB_USERNAME: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_ACCESS_TOKEN }} password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Build and Push Container Image - name: Build [and Push]
working-directory: runner uses: docker/build-push-action@v2
if: ${{ github.event_name == 'push' }} with:
run: | context: ./runner
docker buildx build \ file: ./runner/${{ matrix.dockerfile }}
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \ platforms: linux/amd64,linux/arm64
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \ push: ${{ github.event_name != 'pull_request' }}
--platform linux/amd64,linux/arm64 \ build-args: |
--tag ${DOCKERHUB_USERNAME}/${{ matrix.name }}:v${RUNNER_VERSION} \ RUNNER_VERSION=${{ env.RUNNER_VERSION }}
--tag ${DOCKERHUB_USERNAME}/${{ matrix.name }}:latest \ DOCKER_VERSION=${{ env.DOCKER_VERSION }}
-f ${{ matrix.dockerfile }} . --push tags: |
${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}
${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:latest

View File

@@ -6,6 +6,8 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Release name: Release
env:
DOCKERHUB_USERNAME: ${{ github.repository_owner }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
@@ -22,30 +24,33 @@ jobs:
sudo mv ghr_v0.13.0_linux_amd64/ghr /usr/local/bin sudo mv ghr_v0.13.0_linux_amd64/ghr /usr/local/bin
- name: Set version - name: Set version
run: echo "::set-env name=VERSION::$(cat ${GITHUB_EVENT_PATH} | jq -r '.release.tag_name')" run: echo "VERSION=$(cat ${GITHUB_EVENT_PATH} | jq -r '.release.tag_name')" >> $GITHUB_ENV
- name: Upload artifacts - name: Upload artifacts
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make github-release run: make github-release
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: crazy-max/ghaction-docker-buildx@v1 uses: docker/setup-buildx-action@v1
with: with:
buildx-version: latest version: latest
- name: Login to GitHub Docker Registry - name: Login to DockerHub
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin uses: docker/login-action@v1
env: with:
DOCKERHUB_USERNAME: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_ACCESS_TOKEN }} password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v2
with:
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKERHUB_USERNAME }}/actions-runner-controller:${{ env.VERSION }}
- name: Build Container Image
env:
DOCKERHUB_USERNAME: ${{ github.repository_owner }}
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ${DOCKERHUB_USERNAME}/actions-runner-controller:${{ env.VERSION }} \
-f Dockerfile . --push

View File

@@ -9,27 +9,32 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: release-latest name: release-latest
env:
DOCKERHUB_USERNAME: ${{ github.repository_owner }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: crazy-max/ghaction-docker-buildx@v1 uses: docker/setup-buildx-action@v1
with: with:
buildx-version: latest version: latest
- name: Login to GitHub Docker Registry - name: Login to DockerHub
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin uses: docker/login-action@v1
env: with:
DOCKERHUB_USERNAME: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_ACCESS_TOKEN }} password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v2
with:
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKERHUB_USERNAME }}/actions-runner-controller:latest
- name: Build Container Image
env:
DOCKERHUB_USERNAME: ${{ github.repository_owner }}
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ${DOCKERHUB_USERNAME}/actions-runner-controller:latest \
-f Dockerfile . --push

View File

@@ -321,6 +321,8 @@ spec:
requests: requests:
cpu: "2.0" cpu: "2.0"
memory: "4Gi" memory: "4Gi"
# If set to false, there are no privileged container and you cannot use docker.
dockerEnabled: false
# If set to true, runner pod container only 1 container that's expected to be able to run docker, too. # If set to true, runner pod container only 1 container that's expected to be able to run docker, too.
# image summerwind/actions-runner-dind or custom one should be used with true -value # image summerwind/actions-runner-dind or custom one should be used with true -value
dockerdWithinRunnerContainer: false dockerdWithinRunnerContainer: false
@@ -340,6 +342,10 @@ spec:
value: abcd1234 value: abcd1234
securityContext: securityContext:
runAsUser: 0 runAsUser: 0
# if workDir is not specified, the default working directory is /runner/_work
# this setting allows you to customize the working directory location
# for example, the below setting is the same as on the ubuntu-18.04 image
workDir: /home/runner/work
``` ```
## Runner labels ## Runner labels

View File

@@ -59,6 +59,8 @@ type RunnerSpec struct {
// +optional // +optional
Volumes []corev1.Volume `json:"volumes,omitempty"` Volumes []corev1.Volume `json:"volumes,omitempty"`
// +optional
WorkDir string `json:"workDir,omitempty"`
// +optional // +optional
InitContainers []corev1.Container `json:"initContainers,omitempty"` InitContainers []corev1.Container `json:"initContainers,omitempty"`
@@ -84,6 +86,8 @@ type RunnerSpec struct {
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"` TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
// +optional // +optional
DockerdWithinRunnerContainer *bool `json:"dockerdWithinRunnerContainer,omitempty"` DockerdWithinRunnerContainer *bool `json:"dockerdWithinRunnerContainer,omitempty"`
// +optional
DockerEnabled *bool `json:"dockerEnabled,omitempty"`
} }
// ValidateRepository validates repository field. // ValidateRepository validates repository field.

View File

@@ -530,6 +530,11 @@ func (in *RunnerSpec) DeepCopyInto(out *RunnerSpec) {
*out = new(bool) *out = new(bool)
**out = **in **out = **in
} }
if in.DockerEnabled != nil {
in, out := &in.DockerEnabled, &out.DockerEnabled
*out = new(bool)
**out = **in
}
} }
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RunnerSpec. // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RunnerSpec.

View File

@@ -400,6 +400,8 @@ spec:
- name - name
type: object type: object
type: array type: array
dockerEnabled:
type: boolean
dockerdContainerResources: dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements. description: ResourceRequirements describes the compute resource requirements.
properties: properties:
@@ -1531,6 +1533,8 @@ spec:
- name - name
type: object type: object
type: array type: array
workDir:
type: string
type: object type: object
type: object type: object
required: required:

View File

@@ -400,6 +400,8 @@ spec:
- name - name
type: object type: object
type: array type: array
dockerEnabled:
type: boolean
dockerdContainerResources: dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements. description: ResourceRequirements describes the compute resource requirements.
properties: properties:
@@ -1531,6 +1533,8 @@ spec:
- name - name
type: object type: object
type: array type: array
workDir:
type: string
type: object type: object
type: object type: object
required: required:

View File

@@ -393,6 +393,8 @@ spec:
- name - name
type: object type: object
type: array type: array
dockerEnabled:
type: boolean
dockerdContainerResources: dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements. description: ResourceRequirements describes the compute resource requirements.
properties: properties:
@@ -1524,6 +1526,8 @@ spec:
- name - name
type: object type: object
type: array type: array
workDir:
type: string
type: object type: object
status: status:
description: RunnerStatus defines the observed state of Runner description: RunnerStatus defines the observed state of Runner

View File

@@ -25,6 +25,9 @@ spec:
serviceAccountName: {{ include "actions-runner-controller.serviceAccountName" . }} serviceAccountName: {{ include "actions-runner-controller.serviceAccountName" . }}
securityContext: securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }} {{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- with .Values.priorityClassName }}
priorityClassName: "{{ . }}"
{{- end }}
containers: containers:
- args: - args:
- "--metrics-addr=127.0.0.1:8080" - "--metrics-addr=127.0.0.1:8080"

View File

@@ -79,3 +79,8 @@ nodeSelector: {}
tolerations: [] tolerations: []
affinity: {} affinity: {}
# Leverage a PriorityClass to ensure your pods survive resource shortages
# ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
# PriorityClass: system-cluster-critical
priorityClassName: ""

View File

@@ -400,6 +400,8 @@ spec:
- name - name
type: object type: object
type: array type: array
dockerEnabled:
type: boolean
dockerdContainerResources: dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements. description: ResourceRequirements describes the compute resource requirements.
properties: properties:
@@ -1531,6 +1533,8 @@ spec:
- name - name
type: object type: object
type: array type: array
workDir:
type: string
type: object type: object
type: object type: object
required: required:

View File

@@ -400,6 +400,8 @@ spec:
- name - name
type: object type: object
type: array type: array
dockerEnabled:
type: boolean
dockerdContainerResources: dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements. description: ResourceRequirements describes the compute resource requirements.
properties: properties:
@@ -1531,6 +1533,8 @@ spec:
- name - name
type: object type: object
type: array type: array
workDir:
type: string
type: object type: object
type: object type: object
required: required:

View File

@@ -393,6 +393,8 @@ spec:
- name - name
type: object type: object
type: array type: array
dockerEnabled:
type: boolean
dockerdContainerResources: dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements. description: ResourceRequirements describes the compute resource requirements.
properties: properties:
@@ -1524,6 +1526,8 @@ spec:
- name - name
type: object type: object
type: array type: array
workDir:
type: string
type: object type: object
status: status:
description: RunnerStatus defines the observed state of Runner description: RunnerStatus defines the observed state of Runner

View File

@@ -299,6 +299,7 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
var ( var (
privileged bool = true privileged bool = true
dockerdInRunner bool = runner.Spec.DockerdWithinRunnerContainer != nil && *runner.Spec.DockerdWithinRunnerContainer dockerdInRunner bool = runner.Spec.DockerdWithinRunnerContainer != nil && *runner.Spec.DockerdWithinRunnerContainer
dockerEnabled bool = runner.Spec.DockerEnabled == nil || *runner.Spec.DockerEnabled
) )
runnerImage := runner.Spec.Image runnerImage := runner.Spec.Image
@@ -306,6 +307,11 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
runnerImage = r.RunnerImage runnerImage = r.RunnerImage
} }
workDir := runner.Spec.WorkDir
if workDir == "" {
workDir = "/runner/_work"
}
runnerImagePullPolicy := runner.Spec.ImagePullPolicy runnerImagePullPolicy := runner.Spec.ImagePullPolicy
if runnerImagePullPolicy == "" { if runnerImagePullPolicy == "" {
runnerImagePullPolicy = corev1.PullAlways runnerImagePullPolicy = corev1.PullAlways
@@ -344,6 +350,10 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
Name: "GITHUB_URL", Name: "GITHUB_URL",
Value: r.GitHubClient.GithubBaseURL, Value: r.GitHubClient.GithubBaseURL,
}, },
{
Name: "RUNNER_WORKDIR",
Value: workDir,
},
} }
env = append(env, runner.Spec.Env...) env = append(env, runner.Spec.Env...)
@@ -373,7 +383,7 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
}, },
} }
if !dockerdInRunner { if !dockerdInRunner && dockerEnabled {
pod.Spec.Volumes = []corev1.Volume{ pod.Spec.Volumes = []corev1.Volume{
{ {
Name: "work", Name: "work",
@@ -382,7 +392,13 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
}, },
}, },
{ {
Name: "docker", Name: "externals",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
},
{
Name: "certs-client",
VolumeSource: corev1.VolumeSource{ VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{}, EmptyDir: &corev1.EmptyDirVolumeSource{},
}, },
@@ -391,24 +407,53 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
pod.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{ pod.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{
{ {
Name: "work", Name: "work",
MountPath: "/runner/_work", MountPath: workDir,
}, },
{ {
Name: "docker", Name: "externals",
MountPath: "/var/run", MountPath: "/runner/externals",
},
{
Name: "certs-client",
MountPath: "/certs/client",
ReadOnly: true,
}, },
} }
pod.Spec.Containers[0].Env = append(pod.Spec.Containers[0].Env, []corev1.EnvVar{
{
Name: "DOCKER_HOST",
Value: "tcp://localhost:2376",
},
{
Name: "DOCKER_TLS_VERIFY",
Value: "1",
},
{
Name: "DOCKER_CERT_PATH",
Value: "/certs/client",
},
}...)
pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{ pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{
Name: "docker", Name: "docker",
Image: r.DockerImage, Image: r.DockerImage,
VolumeMounts: []corev1.VolumeMount{ VolumeMounts: []corev1.VolumeMount{
{ {
Name: "work", Name: "work",
MountPath: "/runner/_work", MountPath: workDir,
}, },
{ {
Name: "docker", Name: "externals",
MountPath: "/var/run", MountPath: "/runner/externals",
},
{
Name: "certs-client",
MountPath: "/certs/client",
},
},
Env: []corev1.EnvVar{
{
Name: "DOCKER_TLS_CERTDIR",
Value: "/certs",
}, },
}, },
SecurityContext: &corev1.SecurityContext{ SecurityContext: &corev1.SecurityContext{

View File

@@ -6,7 +6,7 @@ import (
"net/http/httptest" "net/http/httptest"
"time" "time"
"github.com/google/go-github/v32/github" "github.com/google/go-github/v33/github"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/kubernetes/scheme"

View File

@@ -6,7 +6,7 @@ import (
"net/http/httptest" "net/http/httptest"
"strconv" "strconv"
"github.com/google/go-github/v32/github" "github.com/google/go-github/v33/github"
"github.com/gorilla/mux" "github.com/gorilla/mux"
) )

View File

@@ -10,7 +10,7 @@ import (
"time" "time"
"github.com/bradleyfalzon/ghinstallation" "github.com/bradleyfalzon/ghinstallation"
"github.com/google/go-github/v32/github" "github.com/google/go-github/v33/github"
"golang.org/x/oauth2" "golang.org/x/oauth2"
) )
@@ -32,6 +32,7 @@ type Client struct {
GithubBaseURL string GithubBaseURL string
} }
// NewClient creates a Github Client
func (c *Config) NewClient() (*Client, error) { func (c *Config) NewClient() (*Client, error) {
var ( var (
httpClient *http.Client httpClient *http.Client
@@ -84,7 +85,7 @@ func (c *Client) GetRegistrationToken(ctx context.Context, org, repo, name strin
key := getRegistrationKey(org, repo) key := getRegistrationKey(org, repo)
rt, ok := c.regTokens[key] rt, ok := c.regTokens[key]
if ok && rt.GetExpiresAt().After(time.Now().Add(-10*time.Minute)) { if ok && rt.GetExpiresAt().After(time.Now()) {
return rt, nil return rt, nil
} }
@@ -179,25 +180,25 @@ func (c *Client) cleanup() {
func (c *Client) createRegistrationToken(ctx context.Context, owner, repo string) (*github.RegistrationToken, *github.Response, error) { func (c *Client) createRegistrationToken(ctx context.Context, owner, repo string) (*github.RegistrationToken, *github.Response, error) {
if len(repo) > 0 { if len(repo) > 0 {
return c.Client.Actions.CreateRegistrationToken(ctx, owner, repo) return c.Client.Actions.CreateRegistrationToken(ctx, owner, repo)
} else {
return CreateOrganizationRegistrationToken(ctx, c, owner)
} }
return CreateOrganizationRegistrationToken(ctx, c, owner)
} }
func (c *Client) removeRunner(ctx context.Context, owner, repo string, runnerID int64) (*github.Response, error) { func (c *Client) removeRunner(ctx context.Context, owner, repo string, runnerID int64) (*github.Response, error) {
if len(repo) > 0 { if len(repo) > 0 {
return c.Client.Actions.RemoveRunner(ctx, owner, repo, runnerID) return c.Client.Actions.RemoveRunner(ctx, owner, repo, runnerID)
} else {
return RemoveOrganizationRunner(ctx, c, owner, runnerID)
} }
return RemoveOrganizationRunner(ctx, c, owner, runnerID)
} }
func (c *Client) listRunners(ctx context.Context, owner, repo string, opts *github.ListOptions) (*github.Runners, *github.Response, error) { func (c *Client) listRunners(ctx context.Context, owner, repo string, opts *github.ListOptions) (*github.Runners, *github.Response, error) {
if len(repo) > 0 { if len(repo) > 0 {
return c.Client.Actions.ListRunners(ctx, owner, repo, opts) return c.Client.Actions.ListRunners(ctx, owner, repo, opts)
} else {
return ListOrganizationRunners(ctx, c, owner, opts)
} }
return ListOrganizationRunners(ctx, c, owner, opts)
} }
// Validates owner and repo arguments. Both are optional, but at least one should be specified // Validates owner and repo arguments. Both are optional, but at least one should be specified
@@ -214,9 +215,8 @@ func getOwnerAndRepo(org, repo string) (string, string, error) {
func getRegistrationKey(org, repo string) string { func getRegistrationKey(org, repo string) string {
if len(org) > 0 { if len(org) > 0 {
return org return org
} else {
return repo
} }
return repo
} }
func splitOwnerAndRepo(repo string) (string, string, error) { func splitOwnerAndRepo(repo string) (string, string, error) {

View File

@@ -10,7 +10,7 @@ import (
"net/url" "net/url"
"reflect" "reflect"
"github.com/google/go-github/v32/github" "github.com/google/go-github/v33/github"
"github.com/google/go-querystring/query" "github.com/google/go-querystring/query"
) )

View File

@@ -7,7 +7,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-github/v32/github" "github.com/google/go-github/v33/github"
"github.com/summerwind/actions-runner-controller/github/fake" "github.com/summerwind/actions-runner-controller/github/fake"
) )

2
go.mod
View File

@@ -6,7 +6,9 @@ require (
github.com/bradleyfalzon/ghinstallation v1.1.1 github.com/bradleyfalzon/ghinstallation v1.1.1
github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew v1.1.1
github.com/go-logr/logr v0.1.0 github.com/go-logr/logr v0.1.0
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-github/v32 v32.1.1-0.20200822031813-d57a3a84ba04 github.com/google/go-github/v32 v32.1.1-0.20200822031813-d57a3a84ba04
github.com/google/go-github/v33 v33.0.0
github.com/google/go-querystring v1.0.0 github.com/google/go-querystring v1.0.0
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
github.com/kelseyhightower/envconfig v1.4.0 github.com/kelseyhightower/envconfig v1.4.0

4
go.sum
View File

@@ -116,10 +116,14 @@ github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-github/v29 v29.0.2 h1:opYN6Wc7DOz7Ku3Oh4l7prmkOMwEcQxpFtxdU8N8Pts= github.com/google/go-github/v29 v29.0.2 h1:opYN6Wc7DOz7Ku3Oh4l7prmkOMwEcQxpFtxdU8N8Pts=
github.com/google/go-github/v29 v29.0.2/go.mod h1:CHKiKKPHJ0REzfwc14QMklvtHwCveD0PxlMjLlzAM5E= github.com/google/go-github/v29 v29.0.2/go.mod h1:CHKiKKPHJ0REzfwc14QMklvtHwCveD0PxlMjLlzAM5E=
github.com/google/go-github/v32 v32.1.1-0.20200822031813-d57a3a84ba04 h1:wEYk2h/GwOhImcVjiTIceP88WxVbXw2F+ARYUQMEsfg= github.com/google/go-github/v32 v32.1.1-0.20200822031813-d57a3a84ba04 h1:wEYk2h/GwOhImcVjiTIceP88WxVbXw2F+ARYUQMEsfg=
github.com/google/go-github/v32 v32.1.1-0.20200822031813-d57a3a84ba04/go.mod h1:rIEpZD9CTDQwDK9GDrtMTycQNA4JU3qBsCizh3q2WCI= github.com/google/go-github/v32 v32.1.1-0.20200822031813-d57a3a84ba04/go.mod h1:rIEpZD9CTDQwDK9GDrtMTycQNA4JU3qBsCizh3q2WCI=
github.com/google/go-github/v33 v33.0.0 h1:qAf9yP0qc54ufQxzwv+u9H0tiVOnPJxo0lI/JXqw3ZM=
github.com/google/go-github/v33 v33.0.0/go.mod h1:GMdDnVZY/2TsWgp/lkYnpSAh6TrzhANBBwm6k6TTEXg=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=

View File

@@ -1,7 +1,7 @@
FROM ubuntu:18.04 FROM ubuntu:18.04
ARG TARGETPLATFORM ARG TARGETPLATFORM
ARG RUNNER_VERSION=2.274.1 ARG RUNNER_VERSION=2.274.2
ARG DOCKER_VERSION=19.03.12 ARG DOCKER_VERSION=19.03.12
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
@@ -55,7 +55,7 @@ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& usermod -aG docker runner \ && usermod -aG docker runner \
&& echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers && echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers
# Runner download supports amd64 as x64 # Runner download supports amd64 as x64. Externalstmp is needed for making mount points work inside DinD.
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& if [ "$ARCH" = "amd64" ]; then export ARCH=x64 ; fi \ && if [ "$ARCH" = "amd64" ]; then export ARCH=x64 ; fi \
&& mkdir -p /runner \ && mkdir -p /runner \
@@ -64,6 +64,7 @@ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& tar xzf ./runner.tar.gz \ && tar xzf ./runner.tar.gz \
&& rm runner.tar.gz \ && rm runner.tar.gz \
&& ./bin/installdependencies.sh \ && ./bin/installdependencies.sh \
&& mv ./externals ./externalstmp \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY entrypoint.sh /runner COPY entrypoint.sh /runner

View File

@@ -2,7 +2,7 @@ NAME ?= summerwind/actions-runner
DIND_RUNNER_NAME ?= ${NAME}-dind DIND_RUNNER_NAME ?= ${NAME}-dind
TAG ?= latest TAG ?= latest
RUNNER_VERSION ?= 2.273.5 RUNNER_VERSION ?= 2.274.2
DOCKER_VERSION ?= 19.03.12 DOCKER_VERSION ?= 19.03.12
# default list of platforms for which multiarch image is built # default list of platforms for which multiarch image is built

View File

@@ -27,6 +27,10 @@ else
exit 1 exit 1
fi fi
if [ -n "${RUNNER_WORKDIR}" ]; then
WORKDIR_ARG="--work ${RUNNER_WORKDIR}"
fi
if [ -n "${RUNNER_LABELS}" ]; then if [ -n "${RUNNER_LABELS}" ]; then
LABEL_ARG="--labels ${RUNNER_LABELS}" LABEL_ARG="--labels ${RUNNER_LABELS}"
fi fi
@@ -41,7 +45,10 @@ if [ -z "${RUNNER_REPO}" ] && [ -n "${RUNNER_ORG}" ] && [ -n "${RUNNER_GROUP}" ]
fi fi
cd /runner cd /runner
./config.sh --unattended --replace --name "${RUNNER_NAME}" --url "${GITHUB_URL}${ATTACH}" --token "${RUNNER_TOKEN}" ${RUNNER_GROUP_ARG} ${LABEL_ARG} ./config.sh --unattended --replace --name "${RUNNER_NAME}" --url "${GITHUB_URL}${ATTACH}" --token "${RUNNER_TOKEN}" ${RUNNER_GROUP_ARG} ${LABEL_ARG} ${WORKDIR_ARG}
# Hack due to the DinD volumes
mv ./externalstmp/* ./externals/
for f in runsvc.sh RunnerService.js; do for f in runsvc.sh RunnerService.js; do
diff {bin,patched}/${f} || : diff {bin,patched}/${f} || :