Repository navigation
darwin-ci: address review of the tart host scripts (rebased on main) #43710
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
30b7377
darwin-ci: address review of the tart host scripts
Jarred-Sumner f281d68
Merge main into darwin-ci review follow-ups
alii 892406c
darwin-ci: typecheck under exactOptionalPropertyTypes
alii c91f57f
darwin-ci: a failed report copy no longer fails a passing job
alii 2b2a57c
darwin-ci: pin bun 1.4.2 in host.sh
alii 3edb919
darwin-ci: address review of #43710
alii e722283
darwin-ci: format guest.ts
alii 6bcb4fc
darwin-ci: keep the image lock out of /tmp; bake requires a clean pow…
alii 3e82d33
darwin-ci: clear bake's power-off timeout
alii 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
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 |
|---|---|---|
| @@ -1,19 +1,31 @@ | ||
| import { $ } from "bun"; | ||
| import { readdirSync, statSync } from "node:fs"; | ||
| import { homedir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import { succeeds } from "../lib/shell"; | ||
| import { tart } from "../lib/tart"; | ||
|
|
||
| await tart.destroy(`bk-${process.env.BUILDKITE_JOB_ID ?? "none"}`); | ||
| // best effort: a guest that will not delete is logged and left for the next job or the nightly cleanup, and never | ||
| // changes this job's status (a non-zero pre-exit would fail a job whose tests passed, and every later job on the host) | ||
| async function reap(name: string, action: () => Promise<void>): Promise<void> { | ||
| try { | ||
| await action(); | ||
| } catch (error) { | ||
| console.error(`pre-exit: could not remove ${name}: ${error}`); | ||
| } | ||
| } | ||
|
|
||
| const own = `bk-${process.env.BUILDKITE_JOB_ID ?? "none"}`; | ||
| await reap(own, () => tart.destroy(own)); | ||
|
|
||
| // a bk-* guest with no `tart run` behind it belongs to a job that died without its cleanup running | ||
| const vms = join(homedir(), ".tart", "vms"); | ||
| const tenMinutesAgo = Date.now() - 10 * 60_000; | ||
| for (const name of readdirSync(vms).filter((name: string) => name.startsWith("bk-"))) { | ||
| const stat = statSync(join(vms, name), { throwIfNoEntry: false }); | ||
| if (!stat || stat.mtimeMs > tenMinutesAgo) continue; | ||
| if (await succeeds($`pgrep -f ${`tart run ${name}`}`)) continue; | ||
| await tart.remove(name); | ||
| console.log(`pre-exit: reaped orphan guest ${name}`); | ||
| if (await succeeds(["pgrep", "-f", `tart run ${name}`])) continue; | ||
| await reap(name, async () => { | ||
| await tart.remove(name); | ||
| console.log(`pre-exit: reaped orphan guest ${name}`); | ||
| }); | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.