1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-10-20 19:52:06 +00:00
forgejo-runner/act/container
Earl Warren 413a52605d
fix: remove LXC backend leftovers when the job completes (#1054)
- remove the root of the LXC container after destroying it, with sudo as it may contain files owned by root while the runner id is not root
- os.RemoveAll only for native host runs, it is no longer needed for the LXC backend
- remove the CleanUp function that is an indirection with no use

Resolves forgejo/runner#442

When running the test from a non-root user and without this fix, it fails as follow:

```
go test -v -count=1 -run='TestRunnerLXC' ./internal/app/run
=== RUN   TestRunnerLXC
...
time="2025-10-03T15:05:12+02:00" level=debug msg=stopHostEnvironment
time="2025-10-03T15:05:13+02:00" level=debug msg="HostEnvironment.Remove /tmp/TestRunnerLXC1841090130/001/d29c1256e2912892/hostexecutor"
time="2025-10-03T15:05:13+02:00" level=error msg="Error while stop job container FORGEJO-ACTIONS-TASK-0_WORKFLOW-3ede81fbc69d42e6db70bef5820490fc3e7dc4d9dcbfb64981f2d00f08a30d6e_JOB-job: unlinkat /tmp/TestRunnerLXC1841090130/001/d29c1256e2912892/hostexecutor/some/directory/owned/by/root: permission denied"
=== NAME  TestRunnerLXC
    runner_test.go:469:
        	Error Trace:	/home/earl-warren/software/runner/internal/app/run/runner_test.go:469
        	            				/home/earl-warren/software/runner/internal/app/run/runner_test.go:496
        	Error:      	Received unexpected error:
        	            	Error occurred running finally: unlinkat /tmp/TestRunnerLXC1841090130/001/d29c1256e2912892/hostexecutor/some/directory/owned/by/root: permission denied (original error: <nil>)
        	Test:       	TestRunnerLXC
        	Messages:   	OK
=== NAME  TestRunnerLXC/OK
    testing.go:1679: test executed panic(nil) or runtime.Goexit: subtest may have called FailNow on a parent test
=== NAME  TestRunnerLXC
    testing.go:1267: TempDir RemoveAll cleanup: unlinkat /tmp/TestRunnerLXC1841090130/001/d29c1256e2912892/hostexecutor/some/directory/owned/by/root: permission denied
--- FAIL: TestRunnerLXC (6.84s)
    --- FAIL: TestRunnerLXC/OK (6.84s)
FAIL
FAIL	code.forgejo.org/forgejo/runner/v11/internal/app/run	6.847s
FAIL
```

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- bug fixes
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1054): <!--number 1054 --><!--line 0 --><!--description Zml4OiByZW1vdmUgTFhDIGJhY2tlbmQgbGVmdG92ZXJzIHdoZW4gdGhlIGpvYiBjb21wbGV0ZXM=-->fix: remove LXC backend leftovers when the job completes<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1054
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-10-03 16:14:08 +00:00
..
testdata refactor: filecollector into new package (#2174) 2024-01-30 00:46:45 +00:00
container_types.go chore: bump version to v11 (#940) 2025-09-05 07:29:38 +00:00
docker_auth.go chore: bump version to v11 (#940) 2025-09-05 07:29:38 +00:00
docker_build.go chore: bump version to v11 (#940) 2025-09-05 07:29:38 +00:00
docker_cli.go chore: remove github.com/pkg/errors (#873) 2025-08-28 09:33:52 +00:00
docker_cli_test.go chore: remove github.com/pkg/errors (#873) 2025-08-28 09:33:52 +00:00
docker_images.go chore: bump version to v11 (#940) 2025-09-05 07:29:38 +00:00
docker_images_test.go chore: use t.Context for tests, activate usetesting for lint + add t.TempDir and t.Chdir (#844) 2025-08-11 13:21:42 +00:00
DOCKER_LICENSE fix: support docker create arguments from container.options (#1022) (#1351) 2022-10-06 22:09:43 +00:00
docker_logger.go fix: fixes the build on FreeBSD (#882) 2025-08-18 06:01:33 +00:00
docker_network.go chore: bump version to v11 (#940) 2025-09-05 07:29:38 +00:00
docker_pull.go chore: bump version to v11 (#940) 2025-09-05 07:29:38 +00:00
docker_pull_test.go chore: use t.Context for tests, activate usetesting for lint + add t.TempDir and t.Chdir (#844) 2025-08-11 13:21:42 +00:00
docker_run.go chore: bump version to v11 (#940) 2025-09-05 07:29:38 +00:00
docker_run_test.go chore: bump version to v11 (#940) 2025-09-05 07:29:38 +00:00
docker_stub.go chore: bump version to v11 (#940) 2025-09-05 07:29:38 +00:00
docker_volume.go chore: bump version to v11 (#940) 2025-09-05 07:29:38 +00:00
executions_environment.go chore: modernize code (#857) 2025-08-15 04:54:13 +00:00
host_environment.go fix: remove LXC backend leftovers when the job completes (#1054) 2025-10-03 16:14:08 +00:00
host_environment_test.go chore: use t.Context for tests, activate usetesting for lint + add t.TempDir and t.Chdir (#844) 2025-08-11 13:21:42 +00:00
linux_container_environment_extensions.go chore: modernize code (#857) 2025-08-15 04:54:13 +00:00
linux_container_environment_extensions_test.go chore: use t.Context for tests, activate usetesting for lint + add t.TempDir and t.Chdir (#844) 2025-08-11 13:21:42 +00:00
parse_env_file.go chore: bump version to v11 (#940) 2025-09-05 07:29:38 +00:00
util.go chore: upgrade golangci-lint and address findings (#1904) 2023-07-10 17:12:12 -07:00
util_openbsd_mips64.go feat: Host environment (#1293) 2022-11-16 21:29:45 +00:00
util_plan9.go feat: Host environment (#1293) 2022-11-16 21:29:45 +00:00
util_windows.go feat: Host environment (#1293) 2022-11-16 21:29:45 +00:00