tailscale / github-action

A GitHub Action to connect your workflow to your Tailscale network.
BSD 3-Clause "New" or "Revised" License
551 stars 84 forks source link

failed to connect to local tailscaled #18

Closed scriptsrc closed 2 years ago

scriptsrc commented 2 years ago

Any idea why the action fails to connect to local tailscaled ? The stage then claims Success - but I'm not so sure it actually succeeded.

Run tailscale/github-action@v1
  with:
    authkey: ***
    version: 1.14.0
Run MINOR=$(echo $VERSION | awk -F '.' {'print $2'})
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 14.2M  100 14.2M    0     0  13.3M      0  0:00:01  0:00:01 --:--:-- 13.3M
Run sudo tailscaled 2>~/tailscaled.log &
  sudo tailscaled 2>~/tailscaled.log &
  HOSTNAME="github-$(cat /etc/hostname)"
  until sudo tailscale up --authkey ${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --accept-routes
  do
    sleep 0.5
  done
  shell: /bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    TAILSCALE_AUTHKEY: ***
failed to connect to local tailscaled (which appears to be running). Got error: Get "http://local-tailscaled.sock/localapi/v0/status": dial unix /var/run/tailscale/tailscaled.sock: connect: no such file or directory
Success.

Here's my action.yml:

name: trivy scan dockerfile

on:
  push:
    branches:
      - master
  pull_request:
jobs:
  build:
    name: Build
    runs-on: ubuntu-18.04
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Tailscale
        uses: tailscale/github-action@v1
        with:
          authkey: ${{ secrets.TAILSCALE_AUTHKEY }}

      - name: Build an image from Dockerfile
        run: |
          docker build -t ${{ github.repository }}:${{ github.sha }} .

      - name: Run Trivy vulnerability scanner
        uses: aquasecurity/trivy-action@master
        with:
          image-ref: '${{ github.repository }}:${{ github.sha }}'
          format: 'table'
          exit-code: '1'
          ignore-unfixed: true
          vuln-type: 'os,library'
          severity: 'CRITICAL,HIGH'
scriptsrc commented 2 years ago

Hmm actually a tailscale status works so I'll have to troubleshoot if it's something in our deployment.

DentonGentry commented 2 years ago

A commonly-encountered issue is that if TAILSCALE_AUTHKEY is an ephemeral key, https://tailscale.com/kb/1111/ephemeral-nodes/, which used to only allocate an IPv6 address. Attempting to connect to a Tailscale IPv4 address like 100.x.y.z would fail.

In retrospect limiting it to IPv6 wasn't a good idea, and earlier today we deployed a change which will begin allocating IPv4 addresses even for ephemeral nodes.

So, it is possible that the main problem you ran into is that it couldn't connect to the remote Tailscale node due to the IP address it was passed, and that if you try it again it may work now.

heliumbrain commented 2 years ago

Hello!

I'm having the same issue - After trying with both ephemeral and standard keys. Any idea what can be the issue?

scriptsrc commented 2 years ago

Hey heliumbrain,

It turns out my action is connected. I verified by running a tailscale status after connecting. See if that works for you as well.

The IPv4/IPv6 thing really helped as well. Thanks for that change.

On Thu, Oct 28, 2021 at 6:06 AM heliumbrain @.***> wrote:

Hello!

I'm having the same issue - After trying with both ephemeral and standard keys. Any idea what can be the issue?

— You are receiving this because you authored the thread.

Reply to this email directly, view it on GitHub https://github.com/tailscale/github-action/issues/18#issuecomment-953781008, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5DLJS4WY7XVBMKSYQL2XLUJFDEFANCNFSM5GY2BO6A .

jazzdan commented 2 years ago

Hm, I just tried setting up a github action to connect to Tailscale today and I'm running in to the same issue. It isn't connected, as far as I can tell. It seems to hang forever on Run sudo tailscaled 2>~/tailscaled.log &.

Full logs are available here https://gist.github.com/jazzdan/1a35295fd9b6099bb52c9870fb7ee7ac

jazzdan commented 2 years ago

My problem was that there was a typo in my Tailscale ephemeral key. Repasting the key in to the GitHub actions secret fixed the problem.

gianpaj commented 2 years ago

Same issue...

  sudo tailscaled 2>~/tailscaled.log &
  HOSTNAME="github-$(cat /etc/hostname)"
  until sudo tailscale up --authkey ${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --accept-routes
  do
    sleep 0.5
  done
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    TAILSCALE_AUTHKEY: ***
failed to connect to local tailscaled (which appears to be running). Got error: Get "http://local-tailscaled.sock/localapi/v0/status": dial unix /var/run/tailscale/tailscaled.sock: connect: no such file or directory
Success.

What am I doing wrong?

image

Github action:

image

Github repo config:

image

Tailscale settings Personal key:

image

Thanks