actions / runner

The Runner for GitHub Actions :rocket:
https://github.com/features/actions
MIT License
4.77k stars 932 forks source link

RUNNER_TEMP not mounted in docker based actions #1984

Open jnystad opened 2 years ago

jnystad commented 2 years ago

Env var RUNNERTEMP points to /home/runner/work/_temp but this directory is not mounted on docker based actions. Contents from previous job steps that are output to this directory is therefore not available. An example is Azure/aks-set-context which stores the resulting kubeconfig in kubeconfig[timestamp] directly under RUNNER_TEMP. This kubeconfig is therefore not available in docker actions.

Steps to reproduce the behavior:

  1. Use Azure/aks-set-context
  2. Use a docker action relying on kubeconfig

Expected behavior Docker action should have the RUNNER_TEMP directory mounted at the same path.

Runner Version and Platform

Current runner version: '2.294.0' Operating System Ubuntu 20.04.4 LTS

What's not working?

"kubectl" config use-context my-context W0707 12:34:48.857696 29 loader.go:221] Config not found: /home/runner/work/_temp/kubeconfig_1657197285854

nikola-jokic commented 2 years ago

Hi @jnystad,

Thank you for submitting this issue! The feature flag for translating paths is currently off. There was an issue with translating paths for some actions, so we turned off the feature flag until we figure out the best way to translate those inputs. After we finalize the fix, I think that this issue will be resolved :relaxed:

jnystad commented 2 years ago

Perhaps, but I fail to see the _temp root directory mapped or mounted anywhere. Also, docker actions mount ${RUNNER_TEMP}/_github_home as /github/home, while $HOME in other actions are /home/runner. This is also not mapped, as far as I can tell.

Is this intentional? I'm sure what Azure does may not be recommended, but if it's expected to work across docker and non-docker actions, it should probably be consistent.

chancez commented 1 year ago

I also have the problem that a javascript action I'm using writes into /home/runnner/.config but my own docker based action doesn't mount that at all. Even if it was mounted somewhere else and the location was exported as a different env-var that would help.

gerwinjansen commented 1 year ago

I would like to transfer a test result file from one workflow step to another. I found ${{ runner.temp }} in the Github documentation.

The test result publisher is a docker-based action. I combined this with the above example:

- name: Publish test results
  uses: EnricoMi/publish-unit-test-result-action@v2
  if: always()
  id: test-results
  with:
    files: "${{ runner.temp }}/TestResults/*.trx"

But it results in Warning: Could not find any files for /opt/actions-runner/_work/_temp/TestResults/*.trx

When I replace ${{ runner.temp }} with ${{ github.workspace }} in both test runner and publisher, it works. So the official documentation seems broken for docker-based actions...

@nikola-jokic: what is the status of the translating paths issue? Do you have a link to the issue so I can watch it?

nikola-jokic commented 1 year ago

Hey @gerwinjansen,

If the github.workspace works and the runner.temp doesn't, I assume the translation is correct. Can you please provide an example workflow, so I can reproduce the issue?

The PR for translation is: https://github.com/actions/runner/pull/2517, but it is merged and part of the latest release

gerwinjansen commented 1 year ago

Hi @nikola-jokic,

Here is the reproduce: https://github.com/gerwinjansen/runner-temp-not-mounted-on-docker-based-action The workflow steps:

- name: Run unit tests
  run: cp ${{ github.workspace }}/example.trx ${{ runner.temp }}/example.trx

- name: Publish test results
  uses: EnricoMi/publish-unit-test-result-action@v2
  with:
    files: "${{ runner.temp }}/example.trx"

And the relevant console output

Run cp /home/runner/work/runner-temp-not-mounted-on-docker-based-action/runner-temp-not-mounted-on-docker-based-action/example.trx /home/runner/work/_temp/example.trx

[command]/usr/bin/docker run --name ghcri...... <removed for brevity>
  -e "RUNNER_TEMP"
  -v "/var/run/docker.sock":"/var/run/docker.sock"
  -v "/home/runner/work/_temp/_github_home":"/github/home"
  -v "/home/runner/work/_temp/_github_workflow":"/github/workflow"
  -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands"
  -v "/home/runner/work/runner-temp-not-mounted-on-docker-based-action/runner-temp-not-mounted-on-docker-based-action":"/github/workspace"

##[warning]Could not find any files for /home/runner/work/_temp/example.trx

Looks like the volume mount for runner.temp is missing.

nwalfield commented 1 year ago

As a workaround for this, I copy the files that I need to /home/runner/work/_temp/_github_home, which is mounted as /github/home in the docker container.

gerwinjansen commented 1 year ago

@nikola-jokic : did the reproduction above help you analyze the issue?

backdround commented 10 months ago

As a workaround for now, use:

:warning: Warning: If you are using docker for your job then use /github/home everywhere!

Thanks @nwalfield

gerwinjansen commented 10 months ago

@nikola-jokic : did the reproduction above help you analyze the issue?

artificial-aidan commented 10 months ago

As a workaround for now, use:

  • /runner/_work/_temp/_github_home in your steps
  • /github/home in the docker container

⚠️ Warning: If you are using docker for your job then use /github/home everywhere!

Thanks @nwalfield

Small correction.

I also had to make the _github_home directory. But maybe that's because it was a hosted runner?

artificial-aidan commented 10 months ago

It seems to just be a problem with runner.temp not being mounted into the container.

Simple action:

      - uses: docker://ubuntu:latest
        with:
          entrypoint: /bin/bash
          args: -c "echo /github/home/ && ls -al /github/home/"

Command that runs:

/usr/local/bin/docker run --name ubuntulatest_8f7ed3 --label 865e75 --workdir /github/workspace --rm -e "CI_REG" -e "GH_REG" -e "DOCKER_REG" -e "DOCKER_BUILDKIT" -e "IMG_NAME" -e "DOCKER_METADATA_OUTPUT_VERSION" -e "DOCKER_METADATA_OUTPUT_TAGS" -e "DOCKER_METADATA_OUTPUT_LABELS" -e "DOCKER_METADATA_OUTPUT_JSON" -e "DOCKER_METADATA_OUTPUT_BAKE_FILE" -e "INPUT_ENTRYPOINT" -e "INPUT_ARGS" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_EVENT_PATH" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "GITHUB_ACTION" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true --entrypoint "/bin/bash" -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/runner/_work/_temp/_github_home":"/github/home" -v "/runner/_work/_temp/_github_workflow":"/github/workflow" -v "/runner/_work/_temp/_runner_file_commands":"/github/file_commands" -v "/runner/_work/***/***":"/github/workspace" ubuntu:latest -c "echo /github/home/ && ls -al /github/home/"

Temp folder isn't mounted.