Fix empty OCI layer extraction and add context cancellation#57
Merged
Conversation
Skip empty tar archives (0-entry layers from ENV/LABEL/CMD instructions) instead of treating them as errors, which was causing layered extraction to fail and fall back to flat extraction. Thread context.Context through all extraction functions so slow or stalled operations can be cancelled. Closes #56 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.
Summary
Fixes two chained bugs that caused VM startup to hang during OCI image extraction (#56):
extractTarandextractTarSharedLimitreturned an error when a tar archive had zero entries. Empty layers are legitimate OCI artifacts produced byENV,LABEL,CMD, etc. — now treated as no-ops with a debug log.extractImage,extractImageLayered,extractTar, andextractTarSharedLimitdid not acceptcontext.Context, so slow/stalled operations (e.g. flat extraction fallback re-downloading layers) could hang indefinitely. All extraction functions now thread context and checkctx.Err()per tar entry. AcontextReaderwrapper enables cancellation during I/O reads.extractImageLayereduseserrgroup.WithContextfor proper propagation to concurrent goroutines.Test plan
TestExtractTar_EmptyArchiveto expect success (was expecting error)TestExtractTarSharedLimit_EmptyArchive— empty archive succeedsTestExtractImageLayered_EmptyLayers— image with real + empty layer extracts correctlyTestExtractTar_ContextCancellation— cancelled context returnscontext.CanceledTestExtractTarSharedLimit_ContextCancellation— same for shared-limit variantcontext.Background()and still passtask fmt && task lint && task test-nocgoall greenCloses #56
🤖 Generated with Claude Code