fix: remove LXC working directory when it completes #1003

Merged
earl-warren merged 2 commits from earl-warren/runner:wip-lxc-leak into main 2025-09-16 19:42:04 +00:00
Contributor

The working directory was not cleaned up upon completion of a LXC job because rc.stopJobContainer() -> rc.cleanUpJobContainer() -> rc.JobContainer.Remove() was never called for LXC containers.

  • stopContainer() and closeContainer() must not call
    rc.stopHostEnvironment(ctx) for LXC containers because
    • it will needlessly be called twice
    • it intercepts the call to
      • rc.stopJobContainer()
      • rc.JobContainer.Close()
  • rc.stopHostEnvironment(ctx) must be called in rc.cleanUpJobContainer which is indirectly called by rc.stopJobContainer()
  • since rc.JobContainer.Close() is a noop, not calling it for LXC containers had no consequence

Resolves forgejo/runner#442

  • bug fixes
    • PR: fix: remove LXC working directory when it completes
The working directory was not cleaned up upon completion of a LXC job because rc.stopJobContainer() -> rc.cleanUpJobContainer() -> rc.JobContainer.Remove() was never called for LXC containers. - stopContainer() and closeContainer() must not call rc.stopHostEnvironment(ctx) for LXC containers because - it will needlessly be called twice - it intercepts the call to - rc.stopJobContainer() - rc.JobContainer.Close() - rc.stopHostEnvironment(ctx) must be called in rc.cleanUpJobContainer which is indirectly called by rc.stopJobContainer() - since rc.JobContainer.Close() is a noop, not calling it for LXC containers had no consequence Resolves forgejo/runner#442 <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - bug fixes - [PR](https://code.forgejo.org/forgejo/runner/pulls/1003): <!--number 1003 --><!--line 0 --><!--description Zml4OiByZW1vdmUgTFhDIHdvcmtpbmcgZGlyZWN0b3J5IHdoZW4gaXQgY29tcGxldGVz-->fix: remove LXC working directory when it completes<!--description--> <!--end release-notes-assistant-->
earl-warren changed title from fix: remove LXC working directory when it completes to WIP: fix: remove LXC working directory when it completes 2025-09-16 10:38:14 +00:00
@ -391,0 +397,4 @@
stdoutStderr, err := exec.Command("find", dir).CombinedOutput()
require.NoError(t, err)
assert.Equal(t, dir, strings.TrimSuffix(string(stdoutStderr), "\n"))
}
Author
Contributor

is there a better way to assert a directory is empty?

is there a better way to assert a directory is empty?
earl-warren marked this conversation as resolved
Contributor

cascading-pr updated at actions/setup-forgejo#682

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/682
earl-warren changed title from WIP: fix: remove LXC working directory when it completes to fix: remove LXC working directory when it completes 2025-09-16 12:22:42 +00:00
earl-warren force-pushed wip-lxc-leak from f1b00080b5
All checks were successful
checks / validate mocks (pull_request) Successful in 47s
checks / build and test (pull_request) Successful in 2m32s
checks / runner exec tests (pull_request) Successful in 22s
checks / runner integration tests (pull_request) Successful in 4m14s
checks / integration tests (pull_request) Successful in 10m42s
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Successful in 26m8s
issue-labels / release-notes (pull_request_target) Successful in 5s
to 9c24e5bfc3
All checks were successful
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / validate mocks (pull_request) Successful in 51s
checks / build and test (pull_request) Successful in 3m8s
checks / runner exec tests (pull_request) Successful in 27s
checks / runner integration tests (pull_request) Successful in 6m3s
checks / integration tests (pull_request) Successful in 12m32s
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Successful in 5s
cascade / forgejo (pull_request_target) Successful in 1m47s
2025-09-16 12:32:24 +00:00
Compare
Contributor

cascading-pr updated at actions/setup-forgejo#682

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/682
mfenniak approved these changes 2025-09-16 17:25:48 +00:00
mfenniak left a comment

Seems to make sense to me. 👍

Seems to make sense to me. 👍
earl-warren deleted branch wip-lxc-leak 2025-09-16 19:42:05 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
forgejo/runner!1003
No description provided.