Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self hosted runners - ARC #106

Closed
alex9fredericks opened this issue Dec 29, 2023 · 6 comments
Closed

Self hosted runners - ARC #106

alex9fredericks opened this issue Dec 29, 2023 · 6 comments

Comments

@alex9fredericks
Copy link

What is the issue?

The issue I'd like to log, just more FYI, is that it seems that you cannot run the GitHub Dagger action, out of the box, with self hosted runners, on Kubernetes. I installed the ARC for GitHub, with Helm, with the quick-start guide. (With Helm, this was actually quite easy to install). I managed to register some runners, and most of the workflows just run fine. For reference, workflows that used the "docker/build-push-action@v4.1.0", did work right away.

Dagger version

dagger v0.9.3

Steps to reproduce

Problem and Solution (1)

The following script works fine with GitHub runners but not with ARC:

name: 40_dagger_demo.yaml
permissions:
  contents: read
  packages: write
on:
  push:
    branches:
      - main
    paths:
      - 'apps/demo/**’
      - '.github/workflows/dagger_demo.yaml'
concurrency:
  group: ${{ github.ref }}-${{ github.workflow }}
  cancel-in-progress: true
jobs:
  build:
    name: build
    # runs-on: ubuntu-latest
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v3
      - name: '* Install dagger-io'
        run: pip install dagger-io
      - name: '* Run Dagger pipeline'
        uses: dagger/dagger-for-github@v5
        with:
          workdir: apps/demo
          verb: run
          args: python main.py "${{ secrets.DAGGER_KEY }}" github_username
          version: "0.9.3"
error

Solution

This is my workaround for the moment!! 😄 :

    steps:
      - name: '* Setup python'
        uses: actions/setup-python@v5
        with:
          python-version: 'pypy3.10'
      - name: '* Check out the repo'
        uses: actions/checkout@v4
      - name: '* Install manual'
        run: pip install anyio dagger-io==0.9.3
      - name: '* Run Dagger Pipeline'
        run: cd $GITHUB_WORKSPACE/apps/demo/ && python main.py "${{ secrets.DAGGER_KEY }}" github_username

Another varation that still does not work (2)

I also tried another variation, based on a suggestion from @marcosnils!
This still produces another error:

name: 40_dagger_demo.yaml
permissions:
  contents: read
  packages: write
on:
  push:
    branches:
      - main
    paths:
      - 'apps/demo/**'
      - '.github/workflows/40_dagger_demo.yaml'
concurrency:
  group: ${{ github.ref }}-${{ github.workflow }}
  cancel-in-progress: true
jobs:
  build:
    name: build
    # ---
    # runs-on: ubuntu-latest
    # ---
    runs-on: self-hosted
    steps:
      - name: '* Setup python'
        uses: actions/setup-python@v5
        with:
          python-version: 'pypy3.10'
      - name: '* Check out the repo'
        uses: actions/checkout@v4
      - name: '* Run Dagger pipeline'
        uses: dagger/dagger-for-github@v5
        with:
          workdir: apps/demo
          verb: run
          args: python main.py "${{ secrets.DAGGER_KEY }}" github_username
          version: "0.9.3"
best-error-2

Log output

No response

@marcosnils
Copy link
Contributor

The following script works fine with GitHub runners but not with ARC:

Just checked this and it happens because summerwind/actions-runner-dind docker image has an old version of python (3.8) that it's not supported by the dagger python SDK.

@marcosnils
Copy link
Contributor

marcosnils commented Dec 29, 2023

Another varation that still does not work (2)

this seemed to work, it's the docker stop part that failed after running the pipeline since it seems like the dagger engine wasn't started. @alex9fredericks could it be possible that the python main.py is not currently running a dagger pipeline in this case?

In any case we should handle this gracefully also.

@alex9fredericks
Copy link
Author

Just checked this and it happens because summerwind/actions-runner-dind docker image has an old version of python (3.8) that it's not supported by the dagger python SDK.

Yes!! This is a big part of the solution. Here is some yaml to get Summerwind’s ubuntu 22.04 runner:

apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: runnerdeploy-for-testing
spec:
  replicas: 1
  template:
    spec:
      repository: git_username/repo
      ephemeral: false
      image: ghcr.io/git_username/actions-runner-dind:ubuntu-22.04  # < nice
      imagePullSecrets:
        - name: regcred

@alex9fredericks could it be possible that the python main.py is not currently running a dagger pipeline in this case?

True, we never get to run a pipeline. The issue is, that the Summerwind image user that runs everything, runner:runner does not have access to the folder /usr/local/, at least, cannot write the dagger binary to it, and therefore the Dagger For GitHub Action fails (here). It would work if you do this, with sudo:

cd /usr/local && { \
curl -sL https://dl.dagger.io/dagger/install.sh 2>/dev/null |  DAGGER_VERSION=0.9.3 sudo sh 

What you can also do, is run a custom version of the Summerwind docker image. Here I change the owernship of the folder /usr/local/bin to runner, and now it all works!

# file
# ---
# /apps/actions-runner-dind/Dockerfile

FROM summerwind/actions-runner-dind:ubuntu-22.04
USER root
RUN apt update -y && \
    apt install -y --no-install-recommends \
    python3-pip \
    && rm -rf /var/lib/apt/lists/*
RUN chown -R runner:runner /usr/local/bin/
USER runner
Screenshot 2023-12-31 at 11 56 20 PM

@marcosnils
Copy link
Contributor

This PR #105 fixes the /use/local path issue. This problem will be resolved in the next release

@jpadams
Copy link
Contributor

jpadams commented Jan 3, 2024

@alex9fredericks Please confirm that you're good to go with the v5.1.0 release 🙏
https://github.com/marketplace/actions/dagger-for-github

@alex9fredericks
Copy link
Author

Hey @jpadams, everything worked fine at the first run! :)

This test was done with a simplified runner image:

FROM summerwind/actions-runner-dind:ubuntu-22.04

USER root
RUN apt update -y && \
    apt install -y --no-install-recommends \
    python3-pip \
    && rm -rf /var/lib/apt/lists/*
USER runner

test1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants