Repository navigation
feat(onboard): add managed bootstrap image runtime #8045
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 225 commits
Commits
Show all changes
236 commits
Select commit
Hold shift + click to select a range
38329e8
feat(onboard): add managed startup profile schema
ericksoa 7f3859a
docs(onboard): clarify startup profile transport encoding
ericksoa 32561a9
fix(onboard): harden managed startup profile
ericksoa 087a9a5
chore(stack): sync PR3.2 with current main
ericksoa e1845dd
fix(onboard): close startup profile contract gaps
ericksoa 244e3e6
chore(stack): sync PR3.2 with current main
ericksoa 2403316
chore(stack): sync PR3.2 with current main
ericksoa ea5bd8a
chore(stack): sync PR3.2 with current main
ericksoa 357081a
feat(onboard): construct managed startup profiles
ericksoa 25d32e0
feat(onboard): map and coordinate startup profiles
ericksoa 094d177
feat(onboard): apply startup profiles in managed images
ericksoa 06f67e5
feat(onboard): add managed shared-state transactions
ericksoa 2a048ae
chore(stack): restack PR3.3 on merged PR3.2
ericksoa 498e521
chore(stack): restack PR3.4a on PR3.3
ericksoa 3206926
chore(stack): restack PR3.4b on PR3.4a
ericksoa f3081cc
chore(stack): restack PR3.5 on PR3.4b
ericksoa 6da5eb2
test(onboard): keep managed startup tests branchless
ericksoa 51126c4
chore(stack): carry PR3.4b guardrail fix into PR3.5
ericksoa bb7a260
chore(stack): restack PR3.4a after PR3.3 merge
ericksoa fafdbd1
chore(stack): restack PR3.4b after PR3.3 merge
ericksoa 0edd158
chore(stack): restack PR3.5 after PR3.3 merge
ericksoa b14013f
test(onboard): cover managed startup fixture CLI
ericksoa 46fbe19
feat(onboard): apply startup profiles in managed images
ericksoa b2027a9
feat(onboard): add managed shared-state transactions
ericksoa c95bdf7
fix(onboard): serialize managed startup transactions
ericksoa 3f3bdbb
feat(onboard): apply startup profiles in managed images
ericksoa 8ff8094
feat(onboard): add managed shared-state transactions
ericksoa 7d1668b
test(onboard): keep transaction races branchless
ericksoa 540494c
chore(stack): inherit PR3.4a guardrail fix
ericksoa 1463687
chore(stack): inherit PR3.4b restack
ericksoa 3a03eeb
merge: resolve conflicts with main
github-actions[bot] d97b259
chore(stack): restack PR3.5 after PR3.4a merge
ericksoa deb1581
chore(stack): refresh PR3.4b validation
ericksoa 0ad91a5
chore(stack): inherit PR3.4b validation refresh
ericksoa a0f12f1
fix(onboard): harden managed startup inputs
ericksoa 27c72f5
fix(runtime): close prior review debt
ericksoa 1c824cc
test(runtime): keep env cleanup branchless
ericksoa 5c6b3f7
fix(runtime): preserve direct image execution
ericksoa 611fdb6
fix(messaging): reject ambiguous channel identities
ericksoa 76c54d4
fix(messaging): require canonical persisted channel ids
ericksoa e41521b
chore(stack): refresh PR3.4b on current main
ericksoa bebfc6c
chore(stack): refresh PR3.5 on current PR3.4b
ericksoa 864e249
chore(stack): refresh PR3.5a on current PR3.5
ericksoa 7cf2a8d
chore(stack): refresh PR3.5b on current PR3.5a
ericksoa 5f9d97d
test(e2e): add cross-runtime foundation
ericksoa abf45b3
test(e2e): keep runtime foundation branchless
ericksoa ed479ae
refactor(runtime): unify provider bundle registry
ericksoa 005b3a7
fix(runtime): harden provider contract boundaries
ericksoa 05cf2a5
fix(runtime): fail closed on managed image cleanup
ericksoa 5c29046
fix(messaging): reject unresolved build hooks
ericksoa 534773b
fix(runtime): close provider lifecycle authority gaps
ericksoa 847e827
chore(stack): refresh PR3.5c on current PR3.5b
ericksoa 77559f7
test(runtime): keep provider parity branchless
ericksoa a2afe77
fix(e2e): harden runtime foundation contracts
ericksoa 13932b9
chore(stack): refresh PR3.4b on current main
ericksoa 5111410
chore(stack): refresh PR3.5 on current PR3.4b
ericksoa 7d51947
chore(stack): refresh PR3.5a on current PR3.5
ericksoa 004b060
test(e2e): verify fixture profiles stay unregistered
ericksoa 771f48c
chore(stack): refresh PR3.5b on current PR3.5a
ericksoa c67afd3
chore(stack): refresh PR3.5c on current PR3.5b
ericksoa 4788d28
test(e2e): expose runtime profile registration state
ericksoa 64f562f
fix(runtime): preserve unproven cleanup authority
ericksoa 15eef1b
chore(stack): refresh PR3.6 on repaired base
ericksoa d73f13a
test(runtime): cover unknown provider doctor result
ericksoa 8f8bcd5
test(runtime): prove provider recovery boundaries
ericksoa f77bff8
fix(runtime): fail closed on retained cleanup ownership
ericksoa bf2fd19
test(rebuild): type cleanup ownership receipt
ericksoa 4316a18
fix(runtime): prove cleanup authority before deletion
ericksoa 062d66b
test(snapshot): mock destructive cleanup authority
ericksoa 75730cf
test(runtime): prove cleanup planning is inert
ericksoa 0b21b79
feat(rebuild): add atomic managed workload replacement
ericksoa 438f79f
fix(rebuild): fail closed across authority cutover
ericksoa 412d69d
docs(rebuild): define deferred recovery ownership
ericksoa cfe84cd
fix(rebuild): bind retained workload authority
ericksoa 827f545
test(rebuild): keep failure matrices linear
ericksoa add3965
test(rebuild): cover invalid provider artifacts
ericksoa 9bbf75d
fix(rebuild): address review feedback
ericksoa 8212bf9
merge: resolve conflicts with main
github-actions[bot] 4960f4d
chore(stack): refresh managed rebuild on current main
ericksoa bf94633
feat(snapshot): preserve managed runtime authority
ericksoa 3a4321d
fix(snapshot): enforce managed authority boundaries
ericksoa 8b19581
feat(snapshot): prepare immutable managed clone handoff
ericksoa 1a91ef2
test(snapshot): keep provider authority cases linear
ericksoa 410d4c9
chore(stack): refresh clone contract on PR3.8
ericksoa fabad32
test(snapshot): keep clone authority cases linear
ericksoa 25aa304
feat(snapshot): add managed clone provider transaction
ericksoa 6d4d858
test(snapshot): satisfy provider transaction CLI typings
ericksoa 94cb164
chore(stack): refresh provider transaction on PR3.9A
ericksoa cbecf7b
feat(snapshot): stage Hermes clone broker activation
ericksoa 888e2f9
test(snapshot): satisfy Hermes broker CLI typings
ericksoa c176a4f
fix(snapshot): use shared immutable boundary
ericksoa 8bc9ea1
feat(onboard): define dormant transactional managed bootstrap
ericksoa 69bcdc4
feat(onboard): add transactional Docker bootstrap adapter
ericksoa 22c198a
test(onboard): satisfy strict Docker bootstrap fixture typing
ericksoa ff836ad
test(snapshot): complete dependency adapter mocks
ericksoa 88ff07b
fix(snapshot): keep clone transaction dormant
ericksoa 5429f52
chore(stack): refresh Hermes clone broker on PR3.9B
ericksoa 101e408
test(snapshot): satisfy Hermes broker growth guard
ericksoa 0c4440c
chore(stack): refresh bootstrap protocol on PR3.9C
ericksoa f251a72
test(onboard): satisfy bootstrap protocol growth guard
ericksoa b7561d1
feat(onboard): persist managed bootstrap transactions
ericksoa 17843c3
chore(stack): refresh Docker bootstrap adapter on protocol
ericksoa 01a554d
test(onboard): linearize Docker bootstrap fixtures
ericksoa a5de860
feat(onboard): bind managed create to runtime providers
ericksoa 844bfb6
fix(snapshot): pin files during authority hashing
ericksoa aeddd24
chore(stack): refresh clone handoff on snapshot security fix
ericksoa f7068d0
chore(stack): refresh provider transaction on clone handoff
ericksoa 122f8c3
merge: refresh managed create on Docker bootstrap
ericksoa 0711807
chore(stack): refresh Hermes broker on provider transaction
ericksoa a396904
chore(stack): refresh bootstrap protocol on Hermes broker
ericksoa 8faa1b4
chore(stack): refresh Docker adapter on bootstrap protocol
ericksoa 4e68970
merge: refresh managed create on Docker bootstrap security fix
ericksoa 3c47ca5
feat(onboard): persist shared-state commit receipts
ericksoa 3e0645f
chore(stack): append runtime lifecycle parent
ericksoa ed60882
fix(snapshot): address restore review findings
ericksoa ed34be3
refactor(onboard): extract managed GPU finalization
ericksoa 7c823d4
fix(snapshot): address clone handoff review findings
ericksoa 361b455
test(runtime): advance managed bootstrap boundary
ericksoa e962454
merge: update PR3.8 review fixes
ericksoa c2e6f06
fix(snapshot): address provider transaction review
ericksoa 9e64898
docs(snapshot): clarify legacy restore retention
ericksoa 738e680
merge: refresh PR3.8 documentation
ericksoa d7d4adc
merge: refresh clone handoff contract
ericksoa e2e556b
chore(stack): append provider lifecycle guardrails
ericksoa 380925a
fix(hermes): address broker transaction review
ericksoa ffacfb3
merge: refresh Hermes broker on provider transaction
ericksoa c3f9fdc
fix(onboard): harden bootstrap dormancy contract
ericksoa d69a390
merge: refresh bootstrap protocol on Hermes broker
ericksoa 0e2ea03
feat(onboard): add managed bootstrap image runtime
ericksoa e587010
test(onboard): update managed cutover fixtures
ericksoa d416d08
chore(stack): append provider lifecycle CI fixes
ericksoa 1fb671d
fix(bootstrap): harden Docker transaction review contracts
ericksoa 93fe6d8
merge: refresh Docker bootstrap adapter on protocol hardening
ericksoa 333b673
fix(onboard): reconcile managed bootstrap after restart
ericksoa 0cf5aac
test(onboard): inventory Docker bootstrap sources
ericksoa b79f034
test(cli): exclude source fixtures from distribution
ericksoa 2984099
fix(onboard): make terminal recovery restart-safe
ericksoa 0aabe5e
merge: refresh managed create on Docker adapter
ericksoa 310ebeb
test(onboard): fence create on restart recovery
ericksoa b3b96bc
merge: refresh durable transactions on managed create
ericksoa 0013772
test(messaging): keep staged channel fixture canonical
ericksoa 4e9c72f
chore(stack): append durable transaction restack
ericksoa c2d8be9
chore(stack): refresh image runtime on recovery
ericksoa 61aa6d6
merge(stack): refresh clone handoff fixture
ericksoa 4bb2b58
merge(stack): refresh managed clone provider
ericksoa b596445
merge(stack): refresh Hermes clone broker
ericksoa e11da6b
merge(stack): refresh bootstrap protocol
ericksoa 889579b
merge(stack): refresh Docker bootstrap adapter
ericksoa 1c32a4d
merge(stack): refresh managed bootstrap create
ericksoa 16f78b4
merge(stack): refresh durable bootstrap transactions
ericksoa 32becd2
Merge commit '16f78b4355816690f9d8516e04bea8e33a81c8f0' into local/pr…
ericksoa e97ecce
merge(stack): refresh managed workload rebuild parity
ericksoa 6b2c464
merge(stack): refresh managed snapshot parity
ericksoa 91c807c
merge(stack): refresh managed clone handoff contract
ericksoa 8ca5867
merge(stack): refresh managed clone provider transaction
ericksoa 2faa95d
merge(stack): refresh Hermes managed clone broker
ericksoa fc9ff91
merge(stack): refresh managed bootstrap protocol
ericksoa 0d3442e
merge(stack): refresh Docker managed bootstrap adapter
ericksoa cd65972
merge(stack): refresh managed bootstrap provider create
ericksoa f72b165
merge(stack): refresh durable bootstrap transactions
ericksoa 0be111d
merge(stack): refresh managed bootstrap recovery
ericksoa 16ba43b
merge(stack): refresh managed bootstrap image runtime
ericksoa 362a70c
chore(stack): refresh managed workload rebuild parity on current main
ericksoa b2374ee
chore(stack): refresh managed snapshot parity parent
ericksoa e09ce8a
chore(stack): refresh managed clone handoff parent
ericksoa aeeb6dd
chore(stack): refresh managed clone provider parent
ericksoa 968c795
chore(stack): refresh Hermes clone broker parent
ericksoa fb0d7aa
chore(stack): refresh managed bootstrap protocol parent
ericksoa 976771e
chore(stack): refresh Docker bootstrap adapter parent
ericksoa ff5b16b
chore(stack): refresh managed bootstrap create parent
ericksoa 998296e
chore(stack): refresh durable bootstrap transaction parent
ericksoa 3be9d84
chore(stack): refresh managed bootstrap recovery parent
ericksoa ff7a040
chore(stack): refresh managed bootstrap image runtime parent
ericksoa ca85ca7
fix(hermes): preserve broker write ownership
ericksoa 8db756d
chore(stack): incorporate Hermes broker review repairs
ericksoa 3e25313
chore(stack): incorporate Hermes broker review repairs
ericksoa 08060dd
chore(stack): incorporate Hermes broker review repairs
ericksoa bcf2ae9
chore(stack): incorporate Hermes broker review repairs
ericksoa f2a5806
test(onboard): linearize transaction recovery cases
ericksoa 743a2f3
chore(stack): incorporate transaction test repairs
ericksoa 2c11802
chore(stack): incorporate transaction test repairs
ericksoa 5aaf988
chore(stack): refresh E2E qualification
ericksoa 5472c30
chore(stack): incorporate prior-slice qualification refresh
ericksoa faa8610
chore(stack): incorporate prior-slice qualification refresh
ericksoa b349b98
merge: resolve conflicts with main
github-actions[bot] 33d1756
merge(stack): restack #8031 onto current main
ericksoa 65f4d68
merge(stack): restack #8032 onto #8031
ericksoa 380d885
merge(stack): restack #8034 onto #8032
ericksoa 6c7f81d
merge(stack): restack #8035 onto #8034
ericksoa 7097017
test(hermes): assert clone cleanup writes no state
ericksoa c1fd385
chore(stack): refresh Hermes review fix on current parent
ericksoa c5db5df
merge(stack): restack #8036 onto repaired #8035
ericksoa 9a7fc82
merge(stack): restack #8037 onto #8036
ericksoa 982be3a
merge(stack): restack #8040 onto #8037
ericksoa b3e6ca6
merge(stack): restack #8041 onto #8040
ericksoa d91ee2c
merge(stack): restack #8043 onto #8041
ericksoa 413367f
merge(stack): restack #8045 onto #8043
ericksoa 8628b8a
fix(hermes): harden broker control recovery
ericksoa bd43818
merge(stack): restack #8036 onto repaired #8035
ericksoa f4a28b9
merge(stack): restack #8037 onto #8036
ericksoa 76e3a0f
merge(stack): restack #8040 onto #8037
ericksoa 333d1c2
merge(stack): restack #8041 onto #8040
ericksoa 502a52e
merge(stack): restack #8043 onto #8041
ericksoa a7b6ef7
merge(stack): restack #8045 onto #8043
ericksoa d7cb7f7
test(hermes): rely on owned child cleanup
ericksoa 53b3404
merge(stack): restack #8036 onto #8035
ericksoa db8e1cd
merge(stack): restack #8037 onto #8036
ericksoa 1edfdc2
merge(stack): restack #8040 onto #8037
ericksoa 00310bf
merge(stack): restack #8041 onto #8040
ericksoa bd57ed7
merge(stack): restack #8043 onto #8041
ericksoa 66d0888
merge(stack): restack #8045 onto #8043
ericksoa a41d7e3
merge: resolve conflicts with main
github-actions[bot] 4699ab7
merge(stack): append final #8032 ancestry
ericksoa 4824fce
merge(stack): append final #8034 ancestry
ericksoa 82a4877
merge(stack): append final #8035 ancestry
ericksoa ad5397a
merge(stack): append final #8036 ancestry
ericksoa 8c12001
merge(stack): append final #8037 ancestry
ericksoa ad6680e
merge(stack): append final #8040 ancestry
ericksoa 4acf574
merge(stack): append final #8041 ancestry
ericksoa 6307510
merge(stack): append final #8043 ancestry
ericksoa 98ce323
merge(stack): restack image runtime on merged recovery
ericksoa a0ef33f
merge(stack): bind image runtime graft to current main
ericksoa 0b7c59f
feat(onboard): construct managed bootstrap image runtime
ericksoa e32b552
fix(onboard): preserve bootstrap runtime layering
ericksoa 3ab61ae
fix(onboard): satisfy bootstrap runtime guardrails
ericksoa 483b187
fix(onboard): satisfy bootstrap runtime guardrails
ericksoa e291c7b
fix(onboard): preserve bootstrap retry authority
ericksoa 42520a6
fix(onboard): preserve bootstrap retry authority
ericksoa debda9f
fix(onboard): bind bootstrap request cleanup
ericksoa 43a79d2
fix(onboard): bind bootstrap request cleanup
ericksoa 5d007c6
fix(onboard): make bootstrap claims crash-safe
ericksoa a4e49f9
fix(onboard): make bootstrap claims crash-safe
ericksoa f4b7bbd
test(onboard): split bootstrap runtime coverage
ericksoa 856a021
test(onboard): isolate replay filesystem setup
ericksoa 30b61ca
Merge branch 'main' into feat/managed-bootstrap-image-runtime
ericksoa 9c67a9a
fix(onboard): preserve replaced bootstrap requests
ericksoa 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,197 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import fs from "node:fs"; | ||
|
|
||
| import { | ||
| applyManagedStartupRootRequest, | ||
| atomicWriteRootFile, | ||
| MANAGED_STARTUP_COMPLETION_FILE, | ||
| MANAGED_STARTUP_RUNTIME_ENV_FILE, | ||
| ManagedStartupImageRuntimeError, | ||
| type ManagedStartupRootApplyResult, | ||
| main as mainManagedStartupImageRuntime, | ||
| readStableRegularFileSnapshot, | ||
| verifyManagedStartupImageCompletion, | ||
| } from "../managed-startup/image-runtime"; | ||
| import { MANAGED_STARTUP_AGENTS, type ManagedStartupAgent } from "../managed-startup/profile"; | ||
| import type { ManagedStartupRootApplyRequest } from "../managed-startup/root-apply"; | ||
| import { | ||
| MANAGED_BOOTSTRAP_COMPLETION_FILE, | ||
| MANAGED_BOOTSTRAP_COMPLETION_MAX_BYTES, | ||
| MANAGED_BOOTSTRAP_ENVELOPE_MAX_BYTES, | ||
| MANAGED_BOOTSTRAP_REQUEST_FILE, | ||
| type ManagedBootstrapImageCompletion, | ||
| parseManagedBootstrapEnvelope, | ||
| parseManagedBootstrapImageCompletion, | ||
| serializeManagedBootstrapImageCompletion, | ||
| } from "./envelope"; | ||
|
|
||
| const SHA256_RE = /^[a-f0-9]{64}$/u; | ||
| type Environment = Record<string, string | undefined>; | ||
|
|
||
| export interface ManagedBootstrapImageRuntimeExpected { | ||
| readonly agent: ManagedStartupAgent; | ||
| readonly profileFingerprint: string; | ||
| readonly bootstrapIdentity: string; | ||
| } | ||
|
|
||
| function fail(message: string): never { | ||
| throw new ManagedStartupImageRuntimeError(message); | ||
| } | ||
|
|
||
| function requireRoot(): void { | ||
| if (process.geteuid?.() !== 0) { | ||
| fail("managed bootstrap image runtime requires container effective uid 0"); | ||
| } | ||
| } | ||
|
|
||
| function exactAgent(value: string): ManagedStartupAgent { | ||
| if (!MANAGED_STARTUP_AGENTS.includes(value as ManagedStartupAgent)) { | ||
| fail(`unsupported agent ${JSON.stringify(value)}`); | ||
| } | ||
| return value as ManagedStartupAgent; | ||
| } | ||
|
|
||
| function readExpected(argv: readonly string[]): ManagedBootstrapImageRuntimeExpected { | ||
| if (argv.length !== 7) { | ||
| fail( | ||
| "usage: managed-startup-image-runtime [--apply-bootstrap-file|--verify-bootstrap-completion] --agent <agent> --profile-fingerprint <sha256> --bootstrap-identity <sha256>", | ||
| ); | ||
| } | ||
| const valueAfter = (flag: string): string => { | ||
| const index = argv.indexOf(flag); | ||
| if (index < 0 || index + 1 >= argv.length) | ||
| fail(`managed bootstrap ${flag} argument is missing`); | ||
| return argv[index + 1] as string; | ||
| }; | ||
| const profileFingerprint = valueAfter("--profile-fingerprint"); | ||
| const bootstrapIdentity = valueAfter("--bootstrap-identity"); | ||
| if (!SHA256_RE.test(profileFingerprint) || !SHA256_RE.test(bootstrapIdentity)) { | ||
| fail("managed bootstrap image runtime identities must encode 32 lowercase-hex bytes"); | ||
| } | ||
| return { | ||
| agent: exactAgent(valueAfter("--agent")), | ||
| profileFingerprint, | ||
| bootstrapIdentity, | ||
| }; | ||
| } | ||
|
|
||
| export function readManagedBootstrapEnvelope( | ||
| expected: ManagedBootstrapImageRuntimeExpected, | ||
| requestFile: string = MANAGED_BOOTSTRAP_REQUEST_FILE, | ||
| ): ManagedStartupRootApplyRequest { | ||
| requireRoot(); | ||
| const { bytes, stat } = readStableRegularFileSnapshot( | ||
| requestFile, | ||
| MANAGED_BOOTSTRAP_ENVELOPE_MAX_BYTES, | ||
| ); | ||
| if ( | ||
| stat.nlink !== 1n || | ||
| stat.uid !== 0n || | ||
| stat.gid !== 0n || | ||
| Number(stat.mode & 0o777n) !== 0o400 | ||
| ) { | ||
| fail("managed bootstrap envelope must be root:root mode 0400 with one link"); | ||
| } | ||
| const envelope = parseManagedBootstrapEnvelope(bytes.toString("utf8")); | ||
| if ( | ||
| envelope.bootstrapIdentity !== expected.bootstrapIdentity || | ||
| envelope.rootApplyRequest.agent !== expected.agent || | ||
| envelope.rootApplyRequest.profileFingerprint !== expected.profileFingerprint | ||
| ) { | ||
| fail("managed bootstrap envelope identity does not match the replacement"); | ||
| } | ||
| return envelope.rootApplyRequest; | ||
| } | ||
|
|
||
| export async function applyManagedBootstrapEnvelope( | ||
| expected: ManagedBootstrapImageRuntimeExpected, | ||
| env: Environment = process.env, | ||
| requestFile: string = MANAGED_BOOTSTRAP_REQUEST_FILE, | ||
| completionFile: string = MANAGED_BOOTSTRAP_COMPLETION_FILE, | ||
| ): Promise<ManagedStartupRootApplyResult> { | ||
| const request = readManagedBootstrapEnvelope(expected, requestFile); | ||
| const result = await applyManagedStartupRootRequest(request, env, { | ||
| bootstrapIdentity: expected.bootstrapIdentity, | ||
| }); | ||
| atomicWriteRootFile( | ||
| completionFile, | ||
| serializeManagedBootstrapImageCompletion({ | ||
| agent: result.agent, | ||
| bootstrapIdentity: expected.bootstrapIdentity, | ||
| profileFingerprint: result.fingerprint, | ||
| transactionPending: result.transactionPending, | ||
| }), | ||
| 0o444, | ||
| ); | ||
| fs.unlinkSync(requestFile); | ||
| return result; | ||
| } | ||
|
|
||
| export function verifyManagedBootstrapImageCompletion( | ||
| expected: ManagedBootstrapImageRuntimeExpected, | ||
| completionFile: string = MANAGED_BOOTSTRAP_COMPLETION_FILE, | ||
| startupCompletionFile: string = MANAGED_STARTUP_COMPLETION_FILE, | ||
| runtimeEnvironmentFile: string = MANAGED_STARTUP_RUNTIME_ENV_FILE, | ||
| ): ManagedBootstrapImageCompletion { | ||
| requireRoot(); | ||
| const { bytes, stat } = readStableRegularFileSnapshot( | ||
| completionFile, | ||
| MANAGED_BOOTSTRAP_COMPLETION_MAX_BYTES, | ||
| ); | ||
| if ( | ||
| stat.nlink !== 1n || | ||
| stat.uid !== 0n || | ||
| stat.gid !== 0n || | ||
| Number(stat.mode & 0o777n) !== 0o444 | ||
| ) { | ||
| fail("managed bootstrap completion must be root:root mode 0444 with one link"); | ||
| } | ||
| const completion = parseManagedBootstrapImageCompletion(bytes.toString("utf8")); | ||
| if ( | ||
| completion.agent !== expected.agent || | ||
| completion.profileFingerprint !== expected.profileFingerprint || | ||
| completion.bootstrapIdentity !== expected.bootstrapIdentity | ||
| ) { | ||
| fail("managed bootstrap completion identity does not match the replacement"); | ||
| } | ||
| verifyManagedStartupImageCompletion( | ||
| expected.agent, | ||
| expected.profileFingerprint, | ||
| startupCompletionFile, | ||
| runtimeEnvironmentFile, | ||
| ); | ||
| return completion; | ||
| } | ||
|
|
||
| export async function main(argv: readonly string[] = process.argv.slice(2)): Promise<void> { | ||
| if (argv[0] === "--apply-bootstrap-file") { | ||
| const expected = readExpected(argv); | ||
| const result = await applyManagedBootstrapEnvelope(expected); | ||
| console.log( | ||
| result.transactionPending | ||
| ? `[managed-startup] applied ${result.agent} profile ${result.fingerprint}; transaction pending` | ||
| : `[managed-startup] ${result.agent} profile ${result.fingerprint} was already complete`, | ||
| ); | ||
| return; | ||
| } | ||
| if (argv[0] === "--verify-bootstrap-completion") { | ||
| const expected = readExpected(argv); | ||
| const completion = verifyManagedBootstrapImageCompletion(expected); | ||
| console.log( | ||
| `[managed-startup] verified ${expected.agent} profile ${expected.profileFingerprint} bootstrap ${expected.bootstrapIdentity}${ | ||
| completion.transactionPending ? "; transaction pending" : "" | ||
| }`, | ||
| ); | ||
| return; | ||
| } | ||
| await mainManagedStartupImageRuntime(argv); | ||
| } | ||
|
|
||
| if (typeof require !== "undefined" && typeof module !== "undefined" && require.main === module) { | ||
| main().catch((error: unknown) => { | ||
| console.error(error instanceof Error ? error.message : String(error)); | ||
| process.exitCode = 1; | ||
| }); | ||
| } | ||
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.