Repository navigation
Conversation
When a Firecracker fork's snapshot state cannot be rewritten for its new path, the restore renames the source directory to <id>.fork-bak.<time> and links the source path to the fork while the snapshot loads. Killing the API there left the source ID resolving to the fork, and the backup listed as a second guest. Startup now renames the backup back, under the data directory lock and before instances are listed. It acts only when the link points at a Firecracker fork that records that source. Any other layout is left as it is and logged, and the API still starts. A link with no backup is removed when its target verifies the same way, and an aliased restore replaces a dangling link instead of failing with "file exists". The metadata loader rejects a directory whose metadata names another guest, so a parked source, its link or a fork copy cut short by an older binary can no longer be read as the guest it names. Listings that fail on unreadable guests skip such a directory. Network admission keeps the IP and MAC in a backup reserved until the source is put back.
An allocation is no longer derived from metadata that names another guest, so a fixture without an ID has no allocation.
This branch has not been deployed
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
Startup puts back a Firecracker fork source that a killed restore left renamed aside, and the metadata loader no longer reads a directory as the guest its metadata names.
Split out of #555. Stacked on the fork recovery PR.
Why
When a Firecracker fork's snapshot state cannot be rewritten for its new path, the restore renames the source to
<id>.fork-bak.<time>and links the source path to the fork while the snapshot loads. A kill inside that window leaves the link and the backup in place.What changes
RecoverParkedForkSourcesruns under the data directory lock, before instances are listed, and renames the backup back. It acts only when the link points at a Firecracker fork that records that source. Any other layout is left as it is and logged, and the API still starts.loadMetadatarejects a directory whose metadata names another guest. Listings that fail on unreadable guests skip such a directory.Testing
Unit tests cover the recovered layouts (link with backup, backup alone, dangling link), the refused ones (link to another fork, an ordinary directory at the source path, two backups), recovery going on past a refused source, the listing skip, and the network reservations.
On a staging host I could not make the fallback fire: every fork there rewrote its snapshot state, because source and fork paths have the same length. So the layout was made by hand on a stopped API (source renamed to a backup, source path linked to a pending standby fork that records it):
mainGET /instances/<source id>returned the fork. The backup was listed as the source. Layout unchangedNot covered
listAllocationsholds the alias read lock across the whole guest scan.