Repository navigation
Delete forks that a restart interrupted #555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yummybomb
wants to merge
26
commits into
main
Choose a base branch
from
hypeship/recover-interrupted-forks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,241
−172
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
b1374e4
Delete forks that a restart interrupted
yummybomb f7b5f7d
Only delete a pending fork once the process making it is gone
yummybomb dc6ce27
Delete a failed running fork at once and recover interrupted forks in…
yummybomb b582b1c
Keep a finished compression job from restoring a fork's pending mark
yummybomb 5c7f25a
Merge remote-tracking branch 'origin/main' into hypeship/recover-inte…
yummybomb 95fc3c5
Delete a running fork from one place when its source does not come back
yummybomb bfee62a
Do not restart standby compression for a fork that is still pending
yummybomb 28da785
Do not delete by a pending mark that came with a copied directory
yummybomb b1bb0cc
Sync a fork's cleared mark to disk before its request succeeds
yummybomb df92f24
Read a fork's mark again once its owner is known to be gone
yummybomb 2b3b51c
Mark a fork pending again when clearing its mark cannot be synced
yummybomb 6f0bc71
Protect fork recovery from stale writers and inherited state
yummybomb ca207d1
Replace a dangling snapshot source alias left by a killed restore
yummybomb c2597cc
Recover a parked fork source whose link dangles
yummybomb 0857a2d
Sync a fork's cleared mark without holding the alias lock
yummybomb 24ecebb
Delete a failed fork even when its request was cancelled
yummybomb 51fea64
Count interrupted forks found at startup
yummybomb 1b5e91a
Verify guest identity and keep interrupted fork cleanup retryable
yummybomb b22efa8
Delete an interrupted fork even when its TAP cannot be released
yummybomb 74cb091
Free a passthrough device when a delete cannot release it
yummybomb eba917e
Skip guest shutdown when recovering a fork without a passthrough device
yummybomb af5d44e
Stop shadowing syncDir and exporting a reassignable ServerConfig
yummybomb 4a2aca6
Keep a partial fork copy from failing vGPU claims and reconciles
yummybomb 52e360f
Start the API when a parked fork source cannot be recovered
yummybomb 2063699
Refuse to start or restore a fork that is waiting to be deleted
yummybomb cd62612
Guard pending fork transitions and verify cleanup ownership
yummybomb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "os" | ||
| "syscall" | ||
| ) | ||
|
|
||
| // Instance metadata locks are process-local. Hold the directory inode locked | ||
| // until shutdown, before any startup scan can read and write instance records. | ||
| func lockDataDir(path string) (*os.File, error) { | ||
| if err := os.MkdirAll(path, 0755); err != nil { | ||
| return nil, err | ||
| } | ||
| dir, err := os.Open(path) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if err := syscall.Flock(int(dir.Fd()), syscall.LOCK_EX|syscall.LOCK_NB); err != nil { | ||
| dir.Close() | ||
| if errors.Is(err, syscall.EWOULDBLOCK) { | ||
| return nil, fmt.Errorf("another Hypeman process is using this directory: %w", err) | ||
| } | ||
| return nil, err | ||
| } | ||
| return dir, nil | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "syscall" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestServerRefusesSecondWriterBeforeStartup(t *testing.T) { | ||
| const subprocess = "HYPEMAN_TEST_LOCKED_STARTUP" | ||
| if os.Getenv(subprocess) == "1" { | ||
| require.ErrorIs(t, run(), syscall.EWOULDBLOCK) | ||
| return | ||
| } | ||
|
|
||
| path := filepath.Join(t.TempDir(), "data") | ||
| owner, err := lockDataDir(path) | ||
| require.NoError(t, err) | ||
| t.Cleanup(func() { owner.Close() }) | ||
|
|
||
| alias := filepath.Join(t.TempDir(), "same-data") | ||
| require.NoError(t, os.Symlink(path, alias)) | ||
| cfg := filepath.Join(t.TempDir(), "config.yaml") | ||
| require.NoError(t, os.WriteFile(cfg, []byte("data_dir: "+alias+"\njwt_secret: local-test-secret-for-data-dir-lock\n"), 0600)) | ||
| cmd := exec.CommandContext(t.Context(), os.Args[0], "-test.run=^TestServerRefusesSecondWriterBeforeStartup$") | ||
| cmd.Env = append(os.Environ(), subprocess+"=1", "CONFIG_PATH="+cfg, "DATA_DIR="+alias) | ||
| out, err := cmd.CombinedOutput() | ||
| require.NoError(t, err, "%s", out) | ||
| entries, err := os.ReadDir(path) | ||
| require.NoError(t, err) | ||
| require.Empty(t, entries, "the second API must not initialize or recover anything") | ||
|
|
||
| require.NoError(t, owner.Close()) | ||
| next, err := lockDataDir(alias) | ||
| require.NoError(t, err) | ||
| require.NoError(t, next.Close()) | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parked backups listed as unknown guests
Medium Severity
Startup now continues when
RecoverParkedForkSourcescannot put a source back, so*.fork-bak.*directories stay on disk while the API serves.walkMetadataFilestreats those backups as guests, andListInstancesreports each asUnknownbecauseloadMetadatarejects the ID mismatch. Exact lookup maps that same mismatch to 404, so the ghosts appear in the list but cannot be fetched or deleted through the API.Additional Locations (1)
lib/instances/fork_alias_recovery.go#L59-L64Reviewed by Cursor Bugbot for commit 2063699. Configure here.