Run Cleanup on a best-effort basis when a later trial stage fails - #11
Open
magic-peach wants to merge 1 commit into
Open
Run Cleanup on a best-effort basis when a later trial stage fails#11magic-peach wants to merge 1 commit into
magic-peach wants to merge 1 commit into
Conversation
runTrial returned as soon as any stage (Prepare/Create/Start/WaitReady/ Stop/Delete) failed, so Cleanup was only ever reached on the all-succeed path. Since these stages manage real containers, VMs, and netns as root, a failed trial could leak host resources indefinitely. Restructure the stage loop to run per-adapter instead of over one flattened list, and once Prepare has succeeded for an adapter, run its Cleanup on a best-effort basis before returning a failure from any later stage. A cleanup failure is logged but does not replace the original stage error in the trial result. Cleanup is skipped if Prepare itself failed, since no resources exist yet to tear down. Added orchestrator tests using a fake in-package Adapter (no containerd required) covering: cleanup runs after each later-stage failure, cleanup is skipped on Prepare failure, a cleanup failure doesn't mask the original error, and the success path still calls Cleanup exactly once. Fixes urunc-dev#9 Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The trial orchestrator's stage loop (Prepare/Create/Start/WaitReady/Stop/Delete/Cleanup) returned immediately on any stage error, so Cleanup never ran for that adapter. Since this manages real containers/VMs/netns on the host, a failed trial could leak those resources across a benchmark run.
Restructures
runTrialinto a per-adapter loop that tracks whether Prepare succeeded (i.e. whether the adapter may own real resources) and whether Cleanup already ran. On any later-stage failure, Cleanup is invoked on a best-effort basis; if Cleanup itself also fails, that's logged (not fatal) so it doesn't mask the original trial failure being returned. Cleanup is deliberately skipped if Prepare itself failed, since the lifecycle/storage adapters' Cleanup path would panic on a nil Container in that case.Issues Resolved
Fixes #9
Testing
Added 5 tests in
orchestrator_test.goagainst a fake in-package Adapter (no containerd needed): cleanup fires after each later-stage failure, cleanup is skipped when Prepare fails, a cleanup failure doesn't mask the original error, cleanup runs exactly once on the happy path, non-matching adapters are never invoked.go build,go vet,gofmt -l,go test ./...all clean.