@outerlayer/cli 0.36.0-next.20261102135508 → 0.36.0-next.20261102211600
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-setup-OYOTPYAR.js +39 -0
- package/dist/{agent-subcommand-Z6SOLWZW.js → agent-subcommand-3VJ6PKAT.js} +6 -5
- package/dist/{artifact-link-cmd-ZCMQIT5Y.js → artifact-link-cmd-ZPQXVG5O.js} +2 -2
- package/dist/{bridge-4KPODDN7.js → bridge-RECR25EL.js} +8 -7
- package/dist/{build-KYXFZQ33.js → build-NIKF353A.js} +14 -14
- package/dist/{build-disk-W6AL5WHI.js → build-disk-GKLJQNYQ.js} +12 -12
- package/dist/build-info.json +1 -1
- package/dist/{builder-IMNOEYV7.js → builder-THQ62YNF.js} +11 -11
- package/dist/caller-6EKJ6C43.js +22 -0
- package/dist/{check-WWX32IGY.js → check-WODTIKPR.js} +59 -59
- package/dist/{chunk-GFZ7PELR.js → chunk-2ICED253.js} +5 -5
- package/dist/{chunk-DTCTXDJP.js → chunk-2QXA7T6F.js} +5 -2
- package/dist/{chunk-6JLYU322.js → chunk-32GBZ7HD.js} +3 -3
- package/dist/{chunk-YJQ7YA7J.js → chunk-3FZVQRTC.js} +4 -4
- package/dist/{chunk-URHS76GV.js → chunk-3PDRASIP.js} +9 -9
- package/dist/{chunk-TKY3SDXH.js → chunk-44B523ZQ.js} +28 -20
- package/dist/{chunk-KRCU66AM.js → chunk-4K3VEJEE.js} +8 -8
- package/dist/{chunk-TJIFYV2Z.js → chunk-4UADHJ6P.js} +7 -7
- package/dist/{chunk-DTQPDMHG.js → chunk-5QMSZFA2.js} +2 -2
- package/dist/{chunk-B5SWBFVE.js → chunk-66UG5SL4.js} +3 -3
- package/dist/{chunk-ENMX3VQ7.js → chunk-6IDMWODX.js} +6 -6
- package/dist/{chunk-ULBYRPAP.js → chunk-77MUGWQT.js} +1 -1
- package/dist/{chunk-B2P72DAE.js → chunk-7AVQ67PS.js} +1 -1
- package/dist/{chunk-ZSRMJOAK.js → chunk-BF7P3J2H.js} +3 -3
- package/dist/{chunk-FRMAQ3C4.js → chunk-D2SEASHI.js} +6 -6
- package/dist/{chunk-K2G3VB7W.js → chunk-DLHOKPNF.js} +1 -1
- package/dist/{chunk-QKOJ22OV.js → chunk-DUGZCKCF.js} +18 -18
- package/dist/{chunk-VUH7KKVD.js → chunk-FB7HGLRK.js} +3 -3
- package/dist/{chunk-WVAXJOWG.js → chunk-FCMEWS3G.js} +5 -5
- package/dist/{chunk-PMA67TIN.js → chunk-FH4CX3CS.js} +3 -3
- package/dist/{chunk-LSLK4RS4.js → chunk-G3BUOMCF.js} +1 -0
- package/dist/{chunk-3YEPLVNW.js → chunk-GQ4GMFHO.js} +8 -8
- package/dist/{chunk-ATKCHMFD.js → chunk-H5QZSOBB.js} +1 -1
- package/dist/{chunk-BUYXEU7J.js → chunk-HHD5P4TU.js} +8 -8
- package/dist/{chunk-PIZA7OG2.js → chunk-HKJCNBUB.js} +1 -1
- package/dist/{chunk-2YC3TXWX.js → chunk-HOHY6ORJ.js} +1 -1
- package/dist/{chunk-VAYVTUU4.js → chunk-HYDNEYVD.js} +5 -5
- package/dist/{chunk-IKFAJTLZ.js → chunk-I6GHP6U7.js} +1 -1
- package/dist/{chunk-J2OMKFYB.js → chunk-IBFBBUBJ.js} +3 -3
- package/dist/{chunk-BSPJI5T7.js → chunk-IEFSDAVW.js} +1 -1
- package/dist/{chunk-CSBW4LGL.js → chunk-IJC4JL6B.js} +5 -5
- package/dist/{chunk-YYQ5NOT5.js → chunk-JFPDRFAR.js} +3 -3
- package/dist/{chunk-T5QBWM6M.js → chunk-KG5BQFSO.js} +1 -1
- package/dist/{chunk-B36NSEUM.js → chunk-KIY2AUHY.js} +1 -1
- package/dist/{chunk-4DLJ343I.js → chunk-KTL7GFQ3.js} +1 -1
- package/dist/{chunk-FTP7SE6Y.js → chunk-L6GYPZEV.js} +3 -3
- package/dist/{chunk-RF4JHGGB.js → chunk-L6OJH3E5.js} +7 -7
- package/dist/{chunk-O3MJAHLI.js → chunk-LJNFUD3U.js} +6 -6
- package/dist/{chunk-I4DM7SNX.js → chunk-LTAMZ36E.js} +1 -1
- package/dist/{chunk-6KH3NMIT.js → chunk-M7AIU22N.js} +124 -1099
- package/dist/{chunk-SJJXDU2J.js → chunk-MDP3QN7U.js} +7 -7
- package/dist/{chunk-DG3M5DZU.js → chunk-MFLIYXNY.js} +1 -1
- package/dist/{chunk-6HDXRDC5.js → chunk-MSEDA6A2.js} +2 -2
- package/dist/{chunk-ENBOAE2W.js → chunk-MZQAYZY4.js} +66 -25
- package/dist/{chunk-NXQK2I3G.js → chunk-NAQWMYQ2.js} +1 -1
- package/dist/{chunk-WACPWYMH.js → chunk-NJMJHUJL.js} +22 -7
- package/dist/{chunk-D5I5SSPU.js → chunk-OATJFN2P.js} +7 -7
- package/dist/{chunk-PBGNX3PS.js → chunk-OQZ2B5AN.js} +1 -1
- package/dist/{chunk-CXJC3JLN.js → chunk-P7W7SXX7.js} +3 -3
- package/dist/{chunk-YMVRCSKD.js → chunk-PJ3KUE3L.js} +7 -5
- package/dist/{chunk-E3TP4QTM.js → chunk-PLB2IBJV.js} +1 -1
- package/dist/{chunk-L2BA2HXM.js → chunk-PN4LWT5F.js} +1 -1
- package/dist/{chunk-AQE6E54X.js → chunk-QU4FBCRH.js} +9 -9
- package/dist/{chunk-LO4CK734.js → chunk-REXQKAY7.js} +1 -1
- package/dist/{chunk-K7N6LAPC.js → chunk-S3GZ74UE.js} +4 -4
- package/dist/{chunk-4XXBV37R.js → chunk-SFPDEBBO.js} +6 -6
- package/dist/{chunk-CSVJGW3I.js → chunk-STNWA5ZZ.js} +2 -2
- package/dist/{chunk-HTRDL42C.js → chunk-TI32Q3VB.js} +1 -1
- package/dist/{chunk-I6U6QPN6.js → chunk-TOP4K2T6.js} +1138 -80
- package/dist/{chunk-XIDDJSQU.js → chunk-U37FB7ER.js} +2 -2
- package/dist/{chunk-6B3V6EGQ.js → chunk-UJD3DINB.js} +8 -8
- package/dist/{chunk-BZSJ77MO.js → chunk-UKQCIZ3R.js} +1 -1
- package/dist/{chunk-LHHDX7FB.js → chunk-UQ2YFDGP.js} +5 -5
- package/dist/{chunk-FWSVWPMS.js → chunk-V6V3NN5G.js} +1 -1
- package/dist/{chunk-HRHWA6TZ.js → chunk-V7ZAPEVS.js} +1 -1
- package/dist/{chunk-D4VGJQY7.js → chunk-VK4MMRYC.js} +1 -1
- package/dist/{chunk-LSZUTI6O.js → chunk-VNXITMKE.js} +1 -1
- package/dist/{chunk-FOSYM7TQ.js → chunk-X4QHDRXT.js} +2 -2
- package/dist/{chunk-XEWG4AB2.js → chunk-XCXBR74S.js} +739 -253
- package/dist/{chunk-Y4E7IS7H.js → chunk-YPVJ46Y3.js} +2 -2
- package/dist/{chunk-MVPOYQQY.js → chunk-Z4ASKZKN.js} +1 -1
- package/dist/{chunk-H2NJG3TE.js → chunk-ZFDUXKTM.js} +4 -4
- package/dist/{chunk-D6EXW4EB.js → chunk-ZM2SKQJD.js} +2 -2
- package/dist/{chunk-CDG475ZP.js → chunk-ZPFBNCXW.js} +10 -9
- package/dist/{chunk-3UFX6KH2.js → chunk-ZSHBICCL.js} +34 -37
- package/dist/{claude-launcher-LGKJZH33.js → claude-launcher-Z6WBFSRK.js} +10 -9
- package/dist/{cli-Q5L64EEG.js → cli-KBXHOMUN.js} +148 -148
- package/dist/{command-CGEFJZNC.js → command-FPLHTT7R.js} +53 -53
- package/dist/config-RKV7FRY5.js +21 -0
- package/dist/{connect-cmd-RUBP466E.js → connect-cmd-ZG7BPIXQ.js} +14 -14
- package/dist/{container-start-JRF3SBUA.js → container-start-3NWIL4A3.js} +51 -51
- package/dist/{context-cleanup-3K2AOECJ.js → context-cleanup-ZKAL6X5I.js} +6 -5
- package/dist/{context-show-cmd-4UXO5WQJ.js → context-show-cmd-AM46ZKCT.js} +15 -15
- package/dist/{control-plane-launch-AAH4YH56.js → control-plane-launch-HW2Y53YI.js} +16 -15
- package/dist/{demo-record-cmd-2OKCGST7.js → demo-record-cmd-T4227FWF.js} +9 -8
- package/dist/{demo-voice-cmd-GEPX7GIG.js → demo-voice-cmd-YSESUTE5.js} +23 -23
- package/dist/dist-64LM4JF4.js +7 -0
- package/dist/{docker-5VWK335X.js → docker-JC6S6KH3.js} +11 -11
- package/dist/{doctor-EQM3JRZI.js → doctor-U3MU6GP5.js} +53 -53
- package/dist/emit-artifact-cmd-J643XZ46.js +43 -0
- package/dist/{emit-cmd-RO4L4PFZ.js → emit-cmd-PTOSSDQK.js} +9 -8
- package/dist/emit-criteria-cmd-BARZ3MBZ.js +34 -0
- package/dist/{emit-demo-cmd-Y2Y6LEL7.js → emit-demo-cmd-OAC6RTSK.js} +23 -23
- package/dist/{emit-finding-cmd-VECM64UR.js → emit-finding-cmd-BUTFI2GD.js} +17 -17
- package/dist/{emit-result-cmd-2ERWFDUN.js → emit-result-cmd-4E4KX3QZ.js} +21 -21
- package/dist/{emit-step-cmd-V2ET66N4.js → emit-step-cmd-7CAJHMEQ.js} +17 -17
- package/dist/{exec-client-54XKNPTI.js → exec-client-G6B7G3IN.js} +9 -8
- package/dist/find-unit-MX6XITYC.js +23 -0
- package/dist/{findings-cmd-QJPPF6BY.js → findings-cmd-N66FJR3J.js} +17 -17
- package/dist/{fleet-readiness-DKAPHAZN.js → fleet-readiness-KFTMEUAI.js} +16 -15
- package/dist/governing-source-TO6RRWYS.js +40 -0
- package/dist/{guest-init-5QZRGP62.js → guest-init-J3TELWJG.js} +10 -9
- package/dist/{hook-fast-VXROB4KF.js → hook-fast-Y4LO3YE7.js} +4 -4
- package/dist/{hook-install-GDNRMML4.js → hook-install-DOEXRPO5.js} +6 -5
- package/dist/{hook-wrap-fast-LWWKKPGK.js → hook-wrap-fast-L5PCBVNI.js} +3 -3
- package/dist/host-checks-AGWZAK4R.js +78 -0
- package/dist/{host-key-HLLV37NV.js → host-key-EOTN4362.js} +9 -8
- package/dist/{image-tag-PBWQBATH.js → image-tag-VHP22FMX.js} +9 -8
- package/dist/index.js +6 -6
- package/dist/{init-Y2URPVVY.js → init-B575TM3R.js} +49 -49
- package/dist/init-LADDJ3MR.js +78 -0
- package/dist/{init-cmd-XNANUDIW.js → init-cmd-5Q2ICZBK.js} +31 -31
- package/dist/{init-update-EFCTKF6D.js → init-update-AJF4YJ6I.js} +26 -26
- package/dist/{install-cmd-RHFUZFV4.js → install-cmd-GO3D5F6X.js} +11 -10
- package/dist/{layout-7XMC7S6K.js → layout-KSD373US.js} +6 -5
- package/dist/{login-browser-QH4KYG3F.js → login-browser-NUQQYH5J.js} +2 -2
- package/dist/{logs-E7MGQINH.js → logs-QV3LNNUJ.js} +8 -7
- package/dist/loop-5CEZVTIU.js +89 -0
- package/dist/machine-CSH5K23R.js +78 -0
- package/dist/{machine-skills-HR4RNRNR.js → machine-skills-IMGN27M7.js} +6 -5
- package/dist/{mcp-install-cmd-SMPLT43Q.js → mcp-install-cmd-25PA5RAI.js} +6 -5
- package/dist/{mcp-serve-cmd-XXERT673.js → mcp-serve-cmd-7USDWMS4.js} +10 -9
- package/dist/{paths-F2ZR2EKC.js → paths-L3SEA2QQ.js} +8 -7
- package/dist/pending-3EMMPNC7.js +17 -0
- package/dist/{pidfile-7M7O2M7T.js → pidfile-ROXIFSGN.js} +9 -8
- package/dist/{record-YCJ6DZOY.js → record-7OMLXGTG.js} +9 -8
- package/dist/{relay-I2T43PPB.js → relay-663SG53Q.js} +6 -5
- package/dist/{relay-protocol-GI2GC2AM.js → relay-protocol-4V3F6HSZ.js} +6 -5
- package/dist/runner-env-YMBCAQXO.js +23 -0
- package/dist/{runner-identity-Y5ZFCC7V.js → runner-identity-QBFVMEXN.js} +11 -11
- package/dist/{runner-key-R47C6374.js → runner-key-SUZKSV54.js} +49 -49
- package/dist/{session-sender-UPACLRGG.js → session-sender-RI5VITPP.js} +22 -22
- package/dist/{shell-function-GYD2ZQQG.js → shell-function-D2T55XFG.js} +2 -2
- package/dist/{spec-cmd-7QRE2SZK.js → spec-cmd-IPFZNBCZ.js} +18 -18
- package/dist/{starter-pack-IMKIUA56.js → starter-pack-OLH6O4YX.js} +7 -6
- package/dist/state-ZWCWEDKQ.js +17 -0
- package/dist/{status-BQEYEG2V.js → status-KSO5RNWL.js} +49 -49
- package/dist/{statusline-fast-NUVHCNRX.js → statusline-fast-36U3TOCL.js} +3 -3
- package/dist/{sync-cmd-NBLYEPQG.js → sync-cmd-DML4SI6Y.js} +21 -21
- package/dist/update-steps-OVKM7RAH.js +79 -0
- package/dist/{watch-IHV4V3HZ.js → watch-X3AKYTTF.js} +29 -26
- package/dist/{work-claim-cmd-WGTSU5IT.js → work-claim-cmd-SIHUKNW4.js} +24 -24
- package/dist/{work-cmd-HKOJU5FJ.js → work-cmd-Z2JX53KE.js} +17 -17
- package/dist/work-comment-cmd-D2OQTFBW.js +37 -0
- package/dist/{work-demo-cmd-J4AZAIVP.js → work-demo-cmd-Z2PRJSY3.js} +17 -17
- package/dist/{work-logs-cmd-UOO4JVLG.js → work-logs-cmd-4UICP6PY.js} +17 -17
- package/dist/{work-open-pr-cmd-QFRDDBAM.js → work-open-pr-cmd-BZOYVVM6.js} +18 -18
- package/dist/{work-pr-cmd-3Q2D5RQT.js → work-pr-cmd-6PQLQD66.js} +17 -17
- package/dist/{work-proofs-cmd-7Y3HGT7C.js → work-proofs-cmd-SWESTSKA.js} +19 -19
- package/dist/{work-proofs-record-QPUM6DY4.js → work-proofs-record-55B24QNH.js} +27 -27
- package/dist/{work-stop-cmd-SD2ZRMSY.js → work-stop-cmd-6JXCQ277.js} +17 -17
- package/package.json +3 -3
- package/dist/agent-setup-Q3HDN23U.js +0 -39
- package/dist/caller-NLRE272L.js +0 -22
- package/dist/config-T22KVOOT.js +0 -21
- package/dist/dist-VVZIGSAF.js +0 -7
- package/dist/emit-artifact-cmd-TA3MPHLU.js +0 -43
- package/dist/emit-criteria-cmd-NMTUV2KM.js +0 -34
- package/dist/find-unit-CNAPU7XQ.js +0 -23
- package/dist/governing-source-7PZ6DAJU.js +0 -40
- package/dist/host-checks-WAPO5X7X.js +0 -78
- package/dist/init-EK3PUU6W.js +0 -78
- package/dist/loop-L6TX6OR4.js +0 -89
- package/dist/machine-VJKAY2GX.js +0 -78
- package/dist/pending-VOFQRXP4.js +0 -16
- package/dist/runner-env-YW55JVU7.js +0 -23
- package/dist/state-VAHBIMS5.js +0 -16
- package/dist/update-steps-VGKNGWTZ.js +0 -79
- package/dist/work-comment-cmd-H3JCWQ2J.js +0 -37
- package/dist/{chunk-TPMLB3VZ.js → chunk-A6RI6KTI.js} +1 -1
- package/dist/{chunk-P6PHY33P.js → chunk-F3T5QJ24.js} +1 -1
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { itemsSentence, criteriaOf, hostItemsOf, loadCitationFinder, testFileMatcher, MAX_TEST_FILE_BYTES, MAX_TEST_FILES, criterionInputs, uncitedIds, planCriteria, parseJudgeAnswer, inCriteriaOrder, oneLineReason, judgedItems, IdScan, firstInPathOrder, isSearchCandidate } from './chunk-
|
|
3
|
+
import { itemsSentence, criteriaOf, hostItemsOf, loadCitationFinder, testFileMatcher, MAX_TEST_FILE_BYTES, MAX_TEST_FILES, criterionInputs, uncitedIds, planCriteria, parseJudgeAnswer, inCriteriaOrder, oneLineReason, judgedItems, IdScan, firstInPathOrder, isSearchCandidate } from './chunk-X4QHDRXT.js';
|
|
4
4
|
import { zodProblem } from './chunk-I3LTIAOR.js';
|
|
5
5
|
import { sha256OfFile, downloadPinned, VoiceDownloadError } from './chunk-2PGI6RDE.js';
|
|
6
|
-
import { hasStoredCredential, AGENT_COMMANDS, storeAgentCredential, credentialFromStdin, isAgentName } from './chunk-
|
|
7
|
-
import { upgradedStarterText } from './chunk-
|
|
8
|
-
import { HELPER_PATH, HELPER_RECORD, DOCKERD_LOG } from './chunk-
|
|
9
|
-
import { senderPidfile } from './chunk-
|
|
10
|
-
import { installScrubContext } from './chunk-
|
|
6
|
+
import { hasStoredCredential, AGENT_COMMANDS, storeAgentCredential, credentialFromStdin, isAgentName } from './chunk-S3GZ74UE.js';
|
|
7
|
+
import { upgradedStarterText } from './chunk-UQ2YFDGP.js';
|
|
8
|
+
import { HELPER_PATH, HELPER_RECORD, DOCKERD_LOG } from './chunk-IBFBBUBJ.js';
|
|
9
|
+
import { senderPidfile } from './chunk-PJ3KUE3L.js';
|
|
10
|
+
import { installScrubContext } from './chunk-ZSHBICCL.js';
|
|
11
11
|
import { readsJobState, READ_JOB_STATE_FORMATS, jobStateFormatOf } from './chunk-ZVB57WI6.js';
|
|
12
|
-
import { runnerImageVersion } from './chunk-
|
|
13
|
-
import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey } from './chunk-
|
|
12
|
+
import { runnerImageVersion } from './chunk-77MUGWQT.js';
|
|
13
|
+
import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey } from './chunk-STNWA5ZZ.js';
|
|
14
14
|
import { receiveFiles } from './chunk-NN33FYXG.js';
|
|
15
|
-
import { readDefaultBranchFiles, readDefaultBranchHead, cloneRepository, buildRepositoryImage, fetchCommit, readBranchHead, diffBetween, prepareImageBuild, KEY_PREFIX, TAG_HOST, SHARED_OWNER, SHARED_NAME, universalBase, metadataFromLabels, writeRecord } from './chunk-
|
|
16
|
-
import { FETCHED_DIR, toolsDockerfile, FETCHED_FFMPEG, FETCHED_GH, FETCHED_TINI, FETCHED_HEADLESS_SHELL, FETCHED_PLAYWRIGHT_FFMPEG, FETCHED_VOICE_DIR } from './chunk-
|
|
15
|
+
import { readDefaultBranchFiles, readDefaultBranchHead, cloneRepository, buildRepositoryImage, fetchCommit, readBranchHead, diffBetween, prepareImageBuild, KEY_PREFIX, TAG_HOST, SHARED_OWNER, SHARED_NAME, universalBase, metadataFromLabels, writeRecord } from './chunk-4UADHJ6P.js';
|
|
16
|
+
import { FETCHED_DIR, toolsDockerfile, FETCHED_FFMPEG, FETCHED_GH, FETCHED_TINI, FETCHED_HEADLESS_SHELL, FETCHED_PLAYWRIGHT_FFMPEG, FETCHED_VOICE_DIR } from './chunk-BF7P3J2H.js';
|
|
17
17
|
import { isSameProcess, startTimeOf } from './chunk-JBJTC3UU.js';
|
|
18
18
|
import { currentCliBuild } from './chunk-OGFGZQA3.js';
|
|
19
|
-
import { vmExecArgs, runExec, execCapture, waitForAgent } from './chunk-
|
|
20
|
-
import { socketPathProblem, vsockLinks, linkVsockSockets, GUEST_CID, LEASE_LINK } from './chunk-
|
|
21
|
-
import { describeCallFailure, shortClaim, retrySend, commandWithShim, logStamp, createRunnerLog, formatDuration, removeKeptContext, formatClock, stageGovernedContext, keptContextTree, removeStagedContext, WORKFLOW_PERMISSION_REASON, refusalCode, resolveGoverningSource, prefetchGovernedContext, controlPlaneTokenFailure, keepStagedContext, pinnedSourceOf, shimScript } from './chunk-
|
|
22
|
-
import { writeDockerClientConfig } from './chunk-
|
|
23
|
-
import { runnerCredentialProblem, builtinKind, keyRunnerFactory, optionalEgress, isBuiltinContainer, isBuiltinProcess, isBuiltinVm, egressSummary, DEFAULT_CHECK_TIME_LIMIT_MINUTES, DEFAULT_SETUP_MINUTES, allowHostProblem, systemClock, emptyEgressCounts, hostAllowed, imageBuildOf, DEFAULT_SAVED_STATE_MAX_BYTES } from './chunk-
|
|
24
|
-
import { formatBytes, volumeBytes, allocatedBytes, DEFAULT_BUILD_DISK, DEFAULT_CACHE_DISK, freeBytes } from './chunk-
|
|
25
|
-
import { writeJobFile, readJobFile, spawnRun, RUNNER_LABEL, BUILD_LABEL, NETWORK_HELPER_MEMORY, createDockerHost, builderSpec, containerExecArgs, childEnvironment, readDu, withAnswerProtocol, judgeCommand, MAX_REPORT_BYTES, readJobFileChecked, NETWORK_READY_FILE, networkHelperName,
|
|
26
|
-
import { universalImagePending, RecipeError, writeSanitizedRecipe, classifyProperties, DOCKER_FEATURE } from './chunk-
|
|
27
|
-
import { postJson, WorkCommandError, getJson, isSignatureRefusal } from './chunk-
|
|
28
|
-
import { sanitizeTerminal, planArtifactUpload } from './chunk-
|
|
29
|
-
import { scrubText, MIN_SCRUBBED_LITERAL, setCustomScrubbers, setLocalIdentity, setRepoRoot, forkFor, parseTranscript, scrubDeep } from './chunk-6KH3NMIT.js';
|
|
19
|
+
import { vmExecArgs, runExec, execCapture, waitForAgent } from './chunk-V7ZAPEVS.js';
|
|
20
|
+
import { socketPathProblem, vsockLinks, linkVsockSockets, GUEST_CID, LEASE_LINK } from './chunk-ZFDUXKTM.js';
|
|
21
|
+
import { describeCallFailure, shortClaim, retrySend, commandWithShim, logStamp, createRunnerLog, formatDuration, removeKeptContext, formatClock, stageGovernedContext, keptContextTree, removeStagedContext, WORKFLOW_PERMISSION_REASON, refusalCode, resolveGoverningSource, prefetchGovernedContext, controlPlaneTokenFailure, keepStagedContext, pinnedSourceOf, shimScript } from './chunk-GQ4GMFHO.js';
|
|
22
|
+
import { writeDockerClientConfig } from './chunk-HOHY6ORJ.js';
|
|
23
|
+
import { runnerCredentialProblem, builtinKind, keyRunnerFactory, optionalEgress, isBuiltinContainer, isBuiltinProcess, isBuiltinVm, egressSummary, DEFAULT_WORKSPACE_KEEP_DAYS, DEFAULT_CHECK_TIME_LIMIT_MINUTES, DEFAULT_SETUP_MINUTES, allowHostProblem, systemClock, emptyEgressCounts, hostAllowed, imageBuildOf, DEFAULT_SAVED_STATE_MAX_BYTES } from './chunk-NJMJHUJL.js';
|
|
24
|
+
import { formatBytes, volumeBytes, allocatedBytes, DEFAULT_BUILD_DISK, DEFAULT_CACHE_DISK, freeBytes } from './chunk-YPVJ46Y3.js';
|
|
25
|
+
import { writeJobFile, readJobFile, spawnRun, RUNNER_LABEL, BUILD_LABEL, NETWORK_HELPER_MEMORY, createDockerHost, builderSpec, containerExecArgs, childEnvironment, readDu, withAnswerProtocol, judgeCommand, MAX_REPORT_BYTES, parseSize, runnerLabelValue, readJobFileChecked, NETWORK_READY_FILE, networkHelperName, prepareRunArgs, containerRunArgs, JUDGE_MAX_TURNS, WORKSPACE_LABEL, homeCopyRunArgs, networkHelperRunArgs, JUDGE_DIR, HASH_ARGV, parseProgramHash, identityScript, identityArgs, parseIdentity, mountableHome, homeCopyScript, homeCopyArgs, COMMAND_DIR, JUDGE_PROGRAM, MAX_ITEMS_BYTES, JUDGE_ITEMS, JUDGE_REPORT, identityRunArgs, SAVED_STATE_LABEL } from './chunk-ZPFBNCXW.js';
|
|
26
|
+
import { universalImagePending, RecipeError, writeSanitizedRecipe, classifyProperties, DOCKER_FEATURE } from './chunk-UKQCIZ3R.js';
|
|
27
|
+
import { postJson, WorkCommandError, getJson, isSignatureRefusal } from './chunk-QU4FBCRH.js';
|
|
28
|
+
import { sanitizeTerminal, planArtifactUpload } from './chunk-F3T5QJ24.js';
|
|
30
29
|
import { readCloudConfig } from './chunk-HWVMRETT.js';
|
|
31
|
-
import { signerFor } from './chunk-
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import { firecrackerArch, MICROVM_ARCHES, FIRECRACKER_VERSION, hostHelperPinned, builderDiskPinned, guestAssetsPinned, runnerAgentNamed, credentialForms, orList, credentialShapes, credentialAgent, agentCredential, strippedVariables, builtInEnvironment, builtInNames, buildAgent, AGENT_CREDENTIAL_MISSING, RUNNER_WORDED_REASONS, UNKNOWN_TRACKING_REASON, UNKNOWN_TRANSPORT_REASON, GUEST_HELPER_SHA256, GUEST_ASSETS_BASE_URL, GUEST_KERNEL_SHA256, JAILER_BINARY_SHA256, FIRECRACKER_BINARY_SHA256, FIRECRACKER_SHA256, GUEST_ASSETS_VERSION, BUILDER_DISK_VERSION, credentialHandOffKey, runnerAgents, currentAgentCredential, removedAgentCredentialValues, managedAgentCredential, RELAY_USER, realFdStorePort, networkHelperPinned, NETWORK_HELPER_SHA256, universalImagePinned, UNIVERSAL_IMAGE, MAX_MALFORMED_SESSIONS, MALFORMED_REASON, JOIN_WAIT_MS, FFMPEG_STATIC, FFMPEG_BUILD_TAG, GH_SHA256, GH_VERSION, TINI_SHA256, TINI_VERSION, HEADLESS_SHELL, HEADLESS_SHELL_BASE_URL, PLAYWRIGHT_FFMPEG, PLAYWRIGHT_FFMPEG_BASE_URL, VOICE_PACK_FILES, BUILDER_DISK_SHA256, BUILDER_DISK_BASE_URL, DEFAULT_BASE_IMAGE, MAX_OPEN_STREAMS, STREAM_RESET_RATE, STREAM_RESET_BURST, STREAM_WINDOW, SESSION_WINDOW, targetOfPath, agentVersionOf, fdName, RELAY_ID, DOCKER_DESKTOP_REASON } from './chunk-
|
|
37
|
-
import { defaultAgents, parsePolicy, AGENTS_SKILLS_BASE, OUTERLAYER_SKILLS_BASE, resolvePackRoot, orderSessions, extractFacts, sessionsToTimeline } from './chunk-
|
|
38
|
-
import { CheckItemsSchema, downconvertSession } from './chunk-WUKLQWGY.js';
|
|
30
|
+
import { signerFor } from './chunk-I6GHP6U7.js';
|
|
31
|
+
import { vmAssetsDir, RUNNER_DIR_MODE, RUNNER_FILE_MODE, runnerDir, buildDir, jobsDir, storeScopes, spoolDir, orgStoreIn, rootfsDir, imagesDir, sessionsDir, builderCacheDiskPath, buildsDir, ghConfigDir, runnerDirOfBuild, mirrorDir, orgHomeDir, jobConsolePath, vsockPath, workspacesDir, builderConsolePath, rootfsPathFor, diskTemplatesDir, deliveryDir, SHIM_DIR } from './chunk-2QXA7T6F.js';
|
|
32
|
+
import { CHECKOUT_DIR, JOB_MOUNT, buildEnvironment, parseIsolation, proxyEnvironment, withProxyWarningHidden, containerLocalAddress, destinationEnvironment, withHooksPath, startBuildServices, sharedUserEnvironment, headerVariables, authorEnvironment, withTunnelRecord, commitIdentityRecord, repositoriesOf, RELAY_PORT, repositoryPath, lifecycleWorkdir, CHECK_ITEMS_FILE, checkEnvironment, withMiseVariables, checkoutPath, EVAL_INPUT_DIR, isMiseVariableAllowed, BUILD_HOME, primaryOf } from './chunk-P7W7SXX7.js';
|
|
33
|
+
import { sharedSkillNames, skillConflictMessage } from './chunk-32GBZ7HD.js';
|
|
34
|
+
import { versionAtLeast, MINIMUM_CLAUDE_VERSION } from './chunk-IEFSDAVW.js';
|
|
35
|
+
import { firecrackerArch, MICROVM_ARCHES, FIRECRACKER_VERSION, hostHelperPinned, builderDiskPinned, guestAssetsPinned, runnerAgentNamed, credentialForms, orList, credentialShapes, credentialAgent, agentCredential, strippedVariables, builtInEnvironment, builtInNames, buildAgent, AGENT_CREDENTIAL_MISSING, RUNNER_WORDED_REASONS, UNKNOWN_TRACKING_REASON, UNKNOWN_TRANSPORT_REASON, GUEST_HELPER_SHA256, GUEST_ASSETS_BASE_URL, GUEST_KERNEL_SHA256, JAILER_BINARY_SHA256, FIRECRACKER_BINARY_SHA256, FIRECRACKER_SHA256, GUEST_ASSETS_VERSION, BUILDER_DISK_VERSION, credentialHandOffKey, runnerAgents, currentAgentCredential, removedAgentCredentialValues, managedAgentCredential, RELAY_USER, realFdStorePort, networkHelperPinned, NETWORK_HELPER_SHA256, universalImagePinned, UNIVERSAL_IMAGE, MAX_MALFORMED_SESSIONS, MALFORMED_REASON, JOIN_WAIT_MS, FFMPEG_STATIC, FFMPEG_BUILD_TAG, GH_SHA256, GH_VERSION, TINI_SHA256, TINI_VERSION, HEADLESS_SHELL, HEADLESS_SHELL_BASE_URL, PLAYWRIGHT_FFMPEG, PLAYWRIGHT_FFMPEG_BASE_URL, VOICE_PACK_FILES, BUILDER_DISK_SHA256, BUILDER_DISK_BASE_URL, DEFAULT_BASE_IMAGE, MAX_OPEN_STREAMS, STREAM_RESET_RATE, STREAM_RESET_BURST, STREAM_WINDOW, SESSION_WINDOW, targetOfPath, agentVersionOf, fdName, RELAY_ID, DOCKER_DESKTOP_REASON } from './chunk-5QMSZFA2.js';
|
|
36
|
+
import { defaultAgents, parsePolicy, AGENTS_SKILLS_BASE, OUTERLAYER_SKILLS_BASE, resolvePackRoot, legacyAgent, orderSessions, extractFacts, sessionsToTimeline } from './chunk-TOP4K2T6.js';
|
|
39
37
|
import { MAINTAINED_SKILLS } from './chunk-CDDED64E.js';
|
|
40
38
|
import { resolveVersion } from './chunk-RA3O54FC.js';
|
|
41
39
|
import { homeFromEnv } from './chunk-352DHUTP.js';
|
|
40
|
+
import { scrubText, MIN_SCRUBBED_LITERAL, setCustomScrubbers, setLocalIdentity, setRepoRoot, forkFor, scrubDeep } from './chunk-M7AIU22N.js';
|
|
41
|
+
import { CheckItemsSchema, downconvertSession } from './chunk-WUKLQWGY.js';
|
|
42
42
|
import { randomUUID, randomBytes, createHash } from 'crypto';
|
|
43
43
|
import { rmSync, mkdirSync, existsSync, readFileSync, mkdtempSync, statSync, appendFileSync, writeFileSync, readdirSync, accessSync, constants, openSync, closeSync, chmodSync, renameSync, rmdirSync, createReadStream, lstatSync, unlinkSync, realpathSync, writeSync, truncateSync, cpSync, fstatSync, readSync, createWriteStream, copyFileSync, linkSync } from 'fs';
|
|
44
44
|
import { join, dirname, isAbsolute, delimiter, sep, basename, relative, resolve } from 'path';
|
|
@@ -1237,11 +1237,11 @@ function ask(socketPath, request, timeoutMs) {
|
|
|
1237
1237
|
const conn = createConnection(socketPath);
|
|
1238
1238
|
let text2 = "";
|
|
1239
1239
|
let settled = false;
|
|
1240
|
-
const settle = (
|
|
1240
|
+
const settle = (finish2) => {
|
|
1241
1241
|
if (settled) return;
|
|
1242
1242
|
settled = true;
|
|
1243
1243
|
conn.destroy();
|
|
1244
|
-
|
|
1244
|
+
finish2();
|
|
1245
1245
|
};
|
|
1246
1246
|
conn.setTimeout(timeoutMs, () => settle(() => reject(new Error(`the helper at ${socketPath} did not answer within ${Math.round(timeoutMs / 1e3)} seconds`))));
|
|
1247
1247
|
conn.on("connect", () => conn.write(`${JSON.stringify(request)}
|
|
@@ -2475,16 +2475,18 @@ async function deliver(input, staged) {
|
|
|
2475
2475
|
if (recorded.status !== 0) return { ok: false, reason: failure("recording the delivery failed", recorded) };
|
|
2476
2476
|
return { ok: true };
|
|
2477
2477
|
}
|
|
2478
|
-
async function checkOut(input, entry, restored) {
|
|
2478
|
+
async function checkOut(input, entry, restored, fromItemDisk) {
|
|
2479
2479
|
const { exec, log, tag } = input;
|
|
2480
2480
|
const path = checkoutPath(entry);
|
|
2481
|
-
const failed = (reason) => ({ ok: false, reason, ...restored ? { restoreFailed: true } : {} });
|
|
2481
|
+
const failed = (reason) => ({ ok: false, reason, ...restored ? { restoreFailed: true } : {}, ...restored && fromItemDisk ? { fromItemDisk: true } : {} });
|
|
2482
|
+
const what = fromItemDisk ? "kept" : "saved";
|
|
2482
2483
|
if (restored) {
|
|
2483
|
-
|
|
2484
|
+
const steps = fromItemDisk ? [["git", "reset", "--hard", "-q"]] : [["git", "reset", "--hard", "-q"], ["git", "clean", "-fdq"]];
|
|
2485
|
+
for (const argv of steps) {
|
|
2484
2486
|
const cleaned = await exec(argv, path, { quiet: true });
|
|
2485
2487
|
if (cleaned.status !== 0) {
|
|
2486
2488
|
const detail = gitErrorLine(cleaned.stderr);
|
|
2487
|
-
return failed(`the
|
|
2489
|
+
return failed(`the ${what} checkout of ${entry.repository} could not be cleaned (${argv[1]} exit ${cleaned.status})${detail === "" ? "" : `: ${detail}`}`);
|
|
2488
2490
|
}
|
|
2489
2491
|
}
|
|
2490
2492
|
} else {
|
|
@@ -2508,7 +2510,7 @@ async function checkOut(input, entry, restored) {
|
|
|
2508
2510
|
} catch (err) {
|
|
2509
2511
|
if (err instanceof BranchPrepareError) {
|
|
2510
2512
|
const reason = entry.primary ? err.message : `${entry.repository}: ${err.message}`;
|
|
2511
|
-
return failed(restored ? `the
|
|
2513
|
+
return failed(restored ? `the ${what} checkout of ${entry.repository} could not be switched to ${entry.branch}: ${err.message}` : reason);
|
|
2512
2514
|
}
|
|
2513
2515
|
throw err;
|
|
2514
2516
|
}
|
|
@@ -2533,9 +2535,10 @@ async function runBuildSteps(input) {
|
|
|
2533
2535
|
const rewrite = await exec(["git", "config", "--global", `url.http://127.0.0.1:${RELAY_PORT}/github.com/.insteadOf`, "https://github.com/"], "/build/work");
|
|
2534
2536
|
if (rewrite.status !== 0) return { ok: false, reason: `configuring the build's git remote failed (exit ${rewrite.status})` };
|
|
2535
2537
|
const restored = input.setup?.restored === true;
|
|
2538
|
+
const fromItemDisk = input.setup?.restored === true && input.setup.fromItemDisk === true;
|
|
2536
2539
|
const heads = [];
|
|
2537
2540
|
const keyCommits = input.setup?.keyCommits ?? {};
|
|
2538
|
-
const first = await checkOut(input, { ...primary, primary: true }, restored);
|
|
2541
|
+
const first = await checkOut(input, { ...primary, primary: true }, restored, fromItemDisk);
|
|
2539
2542
|
if (!first.ok) return first;
|
|
2540
2543
|
startCommit = first.startCommit;
|
|
2541
2544
|
heads.push({ repository: primary.repository, head: first.head, startCommit: first.startCommit, keyCommit: keyCommits[primary.repository] });
|
|
@@ -2546,7 +2549,7 @@ async function runBuildSteps(input) {
|
|
|
2546
2549
|
}
|
|
2547
2550
|
for (const entry of repositories.filter((candidate) => candidate.repository !== primary.repository)) {
|
|
2548
2551
|
if (input.aborted()) return aborted();
|
|
2549
|
-
const checked = await checkOut(input, { ...entry, primary: false }, restored);
|
|
2552
|
+
const checked = await checkOut(input, { ...entry, primary: false }, restored, fromItemDisk);
|
|
2550
2553
|
if (!checked.ok) return checked;
|
|
2551
2554
|
heads.push({ repository: entry.repository, head: checked.head, startCommit: checked.startCommit, keyCommit: keyCommits[entry.repository] });
|
|
2552
2555
|
}
|
|
@@ -2659,11 +2662,11 @@ function savedStatesDir(runnerDirPath) {
|
|
|
2659
2662
|
}
|
|
2660
2663
|
function writeRecord2(dir, record) {
|
|
2661
2664
|
mkdirSync(dir, { recursive: true, mode: RUNNER_DIR_MODE });
|
|
2662
|
-
const
|
|
2663
|
-
const partial = `${
|
|
2665
|
+
const target2 = join(dir, `${record.id}.json`);
|
|
2666
|
+
const partial = `${target2}.partial`;
|
|
2664
2667
|
writeFileSync(partial, `${JSON.stringify(record, null, 2)}
|
|
2665
2668
|
`, { mode: RUNNER_FILE_MODE });
|
|
2666
|
-
renameSync(partial,
|
|
2669
|
+
renameSync(partial, target2);
|
|
2667
2670
|
}
|
|
2668
2671
|
function isRecord(value) {
|
|
2669
2672
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -2802,14 +2805,149 @@ function unread(reason, log) {
|
|
|
2802
2805
|
log(`this build starts from no saved state and saves none: ${reason}`);
|
|
2803
2806
|
return { keyCommits: {}, noSave: `its key files could not be read: ${reason}` };
|
|
2804
2807
|
}
|
|
2808
|
+
var RECORD_FILE = "record.json";
|
|
2809
|
+
var DISK_FILE = "disk.ext4";
|
|
2810
|
+
var WORK_ITEM_ID2 = /^[A-Za-z0-9_-]{1,64}$/;
|
|
2811
|
+
function itemDiskDir(configPath, organizationId, workItemId) {
|
|
2812
|
+
if (!WORK_ITEM_ID2.test(workItemId)) throw new Error(`cannot keep a disk for the work item ${JSON.stringify(workItemId)}`);
|
|
2813
|
+
return join(workspacesDir(configPath, organizationId), workItemId);
|
|
2814
|
+
}
|
|
2815
|
+
function isRecord2(value) {
|
|
2816
|
+
if (typeof value !== "object" || value === null) return false;
|
|
2817
|
+
const r = value;
|
|
2818
|
+
return typeof r.workItemId === "string" && typeof r.claimId === "string" && typeof r.queue === "string" && typeof r.imageId === "string" && typeof r.diskBytes === "number" && (r.kind === "disk" || r.kind === "volume" && typeof r.volume === "string") && typeof r.bytes === "number" && typeof r.keptAt === "string" && Number.isFinite(Date.parse(r.keptAt));
|
|
2819
|
+
}
|
|
2820
|
+
function readItemDisk(dir) {
|
|
2821
|
+
let parsed;
|
|
2822
|
+
try {
|
|
2823
|
+
parsed = JSON.parse(readFileSync(join(dir, RECORD_FILE), "utf8"));
|
|
2824
|
+
} catch {
|
|
2825
|
+
return void 0;
|
|
2826
|
+
}
|
|
2827
|
+
if (!isRecord2(parsed) || parsed.workItemId !== basename(dir)) return void 0;
|
|
2828
|
+
if (parsed.kind === "volume") return { dir, record: parsed };
|
|
2829
|
+
const path = join(dir, DISK_FILE);
|
|
2830
|
+
try {
|
|
2831
|
+
if (!statSync(path).isFile()) return void 0;
|
|
2832
|
+
} catch {
|
|
2833
|
+
return void 0;
|
|
2834
|
+
}
|
|
2835
|
+
return { dir, record: parsed, path };
|
|
2836
|
+
}
|
|
2837
|
+
function swapInItemDisk(dir, incoming) {
|
|
2838
|
+
const older = readItemDisk(dir);
|
|
2839
|
+
const outgoing = join(dirname(dir), `.${basename(dir)}.${randomBytes(4).toString("hex")}.old`);
|
|
2840
|
+
let hadOlder = true;
|
|
2841
|
+
try {
|
|
2842
|
+
renameSync(dir, outgoing);
|
|
2843
|
+
} catch (err) {
|
|
2844
|
+
if (err.code !== "ENOENT") throw err;
|
|
2845
|
+
hadOlder = false;
|
|
2846
|
+
}
|
|
2847
|
+
try {
|
|
2848
|
+
renameSync(incoming, dir);
|
|
2849
|
+
} catch (err) {
|
|
2850
|
+
if (hadOlder) renameSync(outgoing, dir);
|
|
2851
|
+
throw err;
|
|
2852
|
+
}
|
|
2853
|
+
rmSync(outgoing, { recursive: true, force: true });
|
|
2854
|
+
return older;
|
|
2855
|
+
}
|
|
2856
|
+
function stagingItemDiskDir(dir) {
|
|
2857
|
+
const parent = dirname(dir);
|
|
2858
|
+
mkdirSync(parent, { recursive: true, mode: 448 });
|
|
2859
|
+
const staging = join(parent, `.${basename(dir)}.${randomBytes(4).toString("hex")}.partial`);
|
|
2860
|
+
mkdirSync(staging, { mode: 448 });
|
|
2861
|
+
return staging;
|
|
2862
|
+
}
|
|
2863
|
+
function listItemDisks(configPath, scope) {
|
|
2864
|
+
const where = workspacesDir(configPath, scope);
|
|
2865
|
+
let names;
|
|
2866
|
+
try {
|
|
2867
|
+
names = readdirSync(where);
|
|
2868
|
+
} catch {
|
|
2869
|
+
return [];
|
|
2870
|
+
}
|
|
2871
|
+
const kept = [];
|
|
2872
|
+
for (const name of names) {
|
|
2873
|
+
if (!WORK_ITEM_ID2.test(name)) continue;
|
|
2874
|
+
const found = readItemDisk(join(where, name));
|
|
2875
|
+
if (found !== void 0) kept.push(found);
|
|
2876
|
+
}
|
|
2877
|
+
return kept;
|
|
2878
|
+
}
|
|
2879
|
+
function listLeftovers(configPath, scope) {
|
|
2880
|
+
const where = workspacesDir(configPath, scope);
|
|
2881
|
+
let names;
|
|
2882
|
+
try {
|
|
2883
|
+
names = readdirSync(where);
|
|
2884
|
+
} catch {
|
|
2885
|
+
return [];
|
|
2886
|
+
}
|
|
2887
|
+
const found = [];
|
|
2888
|
+
for (const name of names) {
|
|
2889
|
+
if (!name.startsWith(".") && (!WORK_ITEM_ID2.test(name) || readItemDisk(join(where, name)) !== void 0)) continue;
|
|
2890
|
+
try {
|
|
2891
|
+
found.push({ path: join(where, name), mtimeMs: lstatSync(join(where, name)).mtimeMs });
|
|
2892
|
+
} catch {
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
return found;
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
// src/runner/workspace/restore.ts
|
|
2899
|
+
var DISK_REASON_TEXT = {
|
|
2900
|
+
no_kept_disk: "no disk is kept for the work item on this host",
|
|
2901
|
+
other_image: "the kept disk was made on another image",
|
|
2902
|
+
other_disk_size: "the kept disk was made with another runner.build.disk size",
|
|
2903
|
+
disk_not_restored: "the kept disk could not be copied",
|
|
2904
|
+
checkout_not_switched: "the kept checkout could not be switched to the branch",
|
|
2905
|
+
build_type_cannot_restore: "this build type cannot restore a disk"
|
|
2906
|
+
};
|
|
2907
|
+
function itemDiskDecision(input) {
|
|
2908
|
+
if (input.queue !== "amend") return { state: void 0 };
|
|
2909
|
+
if (!input.builtin) return { state: { restored: false, reason: "build_type_cannot_restore" } };
|
|
2910
|
+
let kept;
|
|
2911
|
+
try {
|
|
2912
|
+
kept = readItemDisk(itemDiskDir(input.configPath, input.organizationId, input.workItemId));
|
|
2913
|
+
} catch {
|
|
2914
|
+
kept = void 0;
|
|
2915
|
+
}
|
|
2916
|
+
if (kept === void 0) return { state: { restored: false, reason: "no_kept_disk" } };
|
|
2917
|
+
if (kept.record.imageId !== input.imageId) return { state: { restored: false, reason: "other_image" } };
|
|
2918
|
+
if (kept.record.diskBytes !== input.diskBytes) return { state: { restored: false, reason: "other_disk_size" } };
|
|
2919
|
+
if (kept.record.kind !== input.backend) return { state: { restored: false, reason: "disk_not_restored" } };
|
|
2920
|
+
return { kept, state: { restored: true, fromClaimId: kept.record.claimId } };
|
|
2921
|
+
}
|
|
2922
|
+
async function discardItemDisk(kept, removeVolume, onError) {
|
|
2923
|
+
try {
|
|
2924
|
+
if (kept.record.kind === "volume" && kept.record.volume !== void 0) {
|
|
2925
|
+
const removed = await removeVolume(kept.record.volume);
|
|
2926
|
+
if (removed !== void 0 && removed.status !== 0 && !/no such volume/i.test(removed.stderr ?? "")) {
|
|
2927
|
+
onError(`could not remove the volume ${kept.record.volume} of the kept disk: ${removed.stderr?.trim() ?? `exit ${removed.status}`}`);
|
|
2928
|
+
return;
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
rmSync(kept.dir, { recursive: true, force: true });
|
|
2932
|
+
} catch (err) {
|
|
2933
|
+
onError(`could not remove the kept disk of work item ${kept.record.workItemId}: ${describeCallFailure(err)}`);
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2805
2936
|
|
|
2806
2937
|
// src/runner/saved-state/provision.ts
|
|
2807
|
-
var isRetryFresh = (value) => typeof value === "object" && value !== null &&
|
|
2938
|
+
var isRetryFresh = (value) => typeof value === "object" && value !== null && value.retryFresh === true;
|
|
2808
2939
|
async function provisionWithFreshFallback(input) {
|
|
2809
2940
|
const first = await input.attempt(true);
|
|
2810
2941
|
if (!isRetryFresh(first)) return first;
|
|
2811
2942
|
input.log(`${first.reason}; provisioning the build again from a fresh disk`);
|
|
2812
|
-
return await input.attempt(false);
|
|
2943
|
+
if (first.itemDisk === void 0) return await input.attempt(false);
|
|
2944
|
+
const second = await input.attempt(true, first.itemDisk);
|
|
2945
|
+
if (!isRetryFresh(second)) return second;
|
|
2946
|
+
input.log(`${second.reason}; provisioning the build again from a fresh disk`);
|
|
2947
|
+
return await input.attempt(false, first.itemDisk);
|
|
2948
|
+
}
|
|
2949
|
+
function keptDiskPlan() {
|
|
2950
|
+
return { keyCommits: {}, noSave: "it starts from the work item's kept disk" };
|
|
2813
2951
|
}
|
|
2814
2952
|
function clockOf(now) {
|
|
2815
2953
|
return now ?? (() => /* @__PURE__ */ new Date());
|
|
@@ -2833,7 +2971,8 @@ function setupInputFor(input) {
|
|
|
2833
2971
|
return {
|
|
2834
2972
|
timeoutMs: minutes * 6e4,
|
|
2835
2973
|
limitMinutes: minutes,
|
|
2836
|
-
restored: input.plan.restore !== void 0,
|
|
2974
|
+
restored: input.plan.restore !== void 0 || input.fromItemDisk === true,
|
|
2975
|
+
...input.fromItemDisk === true ? { fromItemDisk: true } : {},
|
|
2837
2976
|
keyCommits: input.plan.keyCommits,
|
|
2838
2977
|
...input.withoutBuildVariables === true ? { withoutBuildVariables: true } : {},
|
|
2839
2978
|
// A plan has a key exactly when the build may save a state. A build that starts from one is not asked to save.
|
|
@@ -2856,7 +2995,11 @@ async function discardUnusableState(input) {
|
|
|
2856
2995
|
return { retryFresh: true, reason: `saved state ${input.record.id} could not be used: ${input.reason}` };
|
|
2857
2996
|
}
|
|
2858
2997
|
function settleFailedSteps(steps, on) {
|
|
2859
|
-
return steps.restoreFailed === true ? on.giveUp(steps.reason) : on.bail(steps.reason, steps.aborted === true);
|
|
2998
|
+
return steps.restoreFailed === true ? on.giveUp(steps.reason, steps.fromItemDisk === true) : on.bail(steps.reason, steps.aborted === true);
|
|
2999
|
+
}
|
|
3000
|
+
async function discardUnusableItemDisk(input) {
|
|
3001
|
+
await discardItemDisk(input.kept, input.removeVolume, input.onError);
|
|
3002
|
+
return { retryFresh: true, reason: `the kept disk of claim ${shortClaim(input.kept.record.claimId)} could not be used: ${input.reason}`, itemDisk: input.why };
|
|
2860
3003
|
}
|
|
2861
3004
|
var FREEZE_DEADLINE_SECONDS = 12 * 60;
|
|
2862
3005
|
function freezeScript() {
|
|
@@ -3156,9 +3299,13 @@ async function writeEvalInput(request) {
|
|
|
3156
3299
|
const parsed = [];
|
|
3157
3300
|
const copiedByTrace = /* @__PURE__ */ new Map();
|
|
3158
3301
|
let sessionsUnavailable;
|
|
3302
|
+
const capture = legacyAgent(request.agents).adapter.capture;
|
|
3159
3303
|
if (!request.transcripts.ok) {
|
|
3160
3304
|
sessionsUnavailable = request.transcripts.reason;
|
|
3161
3305
|
log.error(`${tag} the sessions could not be copied for the checks' input: ${sessionsUnavailable}`);
|
|
3306
|
+
} else if (capture === void 0) {
|
|
3307
|
+
sessionsUnavailable = "the legacy agent has no capture part to read the transcripts with";
|
|
3308
|
+
log.error(`${tag} the sessions could not be read for the checks' input: ${sessionsUnavailable}`);
|
|
3162
3309
|
} else {
|
|
3163
3310
|
const { copied, missed } = request.transcripts;
|
|
3164
3311
|
scrubbing(request.scrub, request.job.commitIdentity?.author, () => {
|
|
@@ -3170,7 +3317,7 @@ async function writeEvalInput(request) {
|
|
|
3170
3317
|
const stem = options.fallbackId ?? transcript.path;
|
|
3171
3318
|
let session = null;
|
|
3172
3319
|
try {
|
|
3173
|
-
session =
|
|
3320
|
+
session = capture.parseText(transcript.content, options).session;
|
|
3174
3321
|
} catch {
|
|
3175
3322
|
}
|
|
3176
3323
|
const traceId = traceIdForSession(session?.id ?? stem);
|
|
@@ -3323,10 +3470,10 @@ function unitNameFor(buildId) {
|
|
|
3323
3470
|
return `outerlayer-build-${buildId}`;
|
|
3324
3471
|
}
|
|
3325
3472
|
function linkIn(buildDir2, name, source) {
|
|
3326
|
-
const
|
|
3327
|
-
rmSync(
|
|
3473
|
+
const target2 = join(buildDir2, name);
|
|
3474
|
+
rmSync(target2, { force: true });
|
|
3328
3475
|
try {
|
|
3329
|
-
linkSync(source,
|
|
3476
|
+
linkSync(source, target2);
|
|
3330
3477
|
} catch (err) {
|
|
3331
3478
|
if (err.code === "EXDEV") {
|
|
3332
3479
|
throw new Error(`${source} and ${buildDir2} are on different file systems, so the build's files cannot be linked into its jail`);
|
|
@@ -3521,10 +3668,10 @@ async function mountGuestHome(runtime, state, agentUser, known) {
|
|
|
3521
3668
|
}
|
|
3522
3669
|
var NODE_IN_GUEST = "/opt/outerlayer/bin/node";
|
|
3523
3670
|
var NO_FOLDER = 3;
|
|
3524
|
-
async function unpackIntoGuest(runtime, state, dir,
|
|
3525
|
-
const script = opts.readOnly === true ? `set -e; rm -rf ${
|
|
3671
|
+
async function unpackIntoGuest(runtime, state, dir, target2, opts = {}) {
|
|
3672
|
+
const script = opts.readOnly === true ? `set -e; rm -rf ${target2}; mkdir -p ${target2}; tar -x --no-same-owner -C ${target2}; chmod -R a+rX,a-w ${target2}` : `set -e; mkdir -p ${target2}; tar -x --no-same-owner -C ${target2}; chmod -R a+rX ${target2}`;
|
|
3526
3673
|
const result = await asRoot(runtime, state, ["/bin/sh", "-c", script], tarOf(dir));
|
|
3527
|
-
if (result.status !== 0) throw new Error(`unpacking into ${
|
|
3674
|
+
if (result.status !== 0) throw new Error(`unpacking into ${target2} in the guest failed (exit ${result.status}): ${firstLine3(result.stderr)}`);
|
|
3528
3675
|
}
|
|
3529
3676
|
async function deliverCommitHooks(input) {
|
|
3530
3677
|
await unpackIntoGuest(input.runtime, input.state, input.hooksDir, GUEST_HOOKS_DIR);
|
|
@@ -3587,11 +3734,11 @@ async function keepSockets(runtime, buildId, listeners, leaseServer, line2, erro
|
|
|
3587
3734
|
}
|
|
3588
3735
|
async function provisionMicroVm(input) {
|
|
3589
3736
|
return provisionWithFreshFallback({
|
|
3590
|
-
attempt: (allowRestore) => provisionMicroVmOnce(input, allowRestore),
|
|
3737
|
+
attempt: (allowRestore, itemDiskFailed) => provisionMicroVmOnce(input, allowRestore, itemDiskFailed),
|
|
3591
3738
|
log: (line2) => input.log.line(`#${input.item.number} ${line2}`)
|
|
3592
3739
|
});
|
|
3593
3740
|
}
|
|
3594
|
-
async function provisionMicroVmOnce(input, allowRestore) {
|
|
3741
|
+
async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
|
|
3595
3742
|
const { config, runtime, item, itemKey, jobDir, log, tokens } = input;
|
|
3596
3743
|
const managed = config.managed === true;
|
|
3597
3744
|
const { vm } = runtime;
|
|
@@ -3656,7 +3803,10 @@ async function provisionMicroVmOnce(input, allowRestore) {
|
|
|
3656
3803
|
if (!obtained.ok) return obtained.aborted === true ? { ok: false, reason: obtained.reason, aborted: true } : fail(obtained.reason);
|
|
3657
3804
|
const { report } = obtained.built;
|
|
3658
3805
|
const tagged = taggedLog(log, tag);
|
|
3659
|
-
const
|
|
3806
|
+
const itemDisk = input.workItemId === void 0 ? { state: void 0 } : itemDiskFailed !== void 0 ? { state: { restored: false, reason: itemDiskFailed } } : itemDiskDecision({ queue: input.queue ?? "implement", builtin: true, backend: "disk", configPath: config.configPath, organizationId: input.organizationId, workItemId: input.workItemId, imageId: report.imageId, diskBytes: limits2.diskBytes });
|
|
3807
|
+
const keptDisk = itemDisk.kept;
|
|
3808
|
+
if (itemDisk.state?.restored === false) tagged(`this agent job starts without a kept disk: ${DISK_REASON_TEXT[itemDisk.state.reason]}`);
|
|
3809
|
+
const plan = keptDisk !== void 0 ? keptDiskPlan() : await planSavedState({
|
|
3660
3810
|
config,
|
|
3661
3811
|
repositories,
|
|
3662
3812
|
base: savedStateBase(report),
|
|
@@ -3728,6 +3878,10 @@ async function provisionMicroVmOnce(input, allowRestore) {
|
|
|
3728
3878
|
await bail(reason);
|
|
3729
3879
|
return discardUnusableState({ record: plan.restore.record, reason, dir: savedStatesPath, removeVolume: async () => void 0, onError: (line2) => log.error(`${tag} ${line2}`) });
|
|
3730
3880
|
};
|
|
3881
|
+
const giveUpItemDisk = async (reason, why) => {
|
|
3882
|
+
await bail(reason);
|
|
3883
|
+
return discardUnusableItemDisk({ kept: keptDisk, reason, why, removeVolume: async () => void 0, onError: (line2) => log.error(`${tag} ${line2}`) });
|
|
3884
|
+
};
|
|
3731
3885
|
if (input.aborted()) return bail("", true);
|
|
3732
3886
|
let imageConfig;
|
|
3733
3887
|
if (madeInBuilder !== void 0) {
|
|
@@ -3779,12 +3933,15 @@ async function provisionMicroVmOnce(input, allowRestore) {
|
|
|
3779
3933
|
if (restore !== void 0 && (restore.kind !== "disk" || restore.path === void 0)) return giveUpState(`the saved state is a ${restore.kind}, not a disk this runner can copy; provisioning the build again from a fresh disk`);
|
|
3780
3934
|
const restoreStartedAt = Date.now();
|
|
3781
3935
|
try {
|
|
3782
|
-
await createBuildDisk({ host: vm.rootfs, runnerDir: runnerDirPath, bytes: limits2.diskBytes, dest: state.buildDisk, memoryBytes: limits2.memoryBytes, source: restore?.path });
|
|
3936
|
+
await createBuildDisk({ host: vm.rootfs, runnerDir: runnerDirPath, bytes: limits2.diskBytes, dest: state.buildDisk, memoryBytes: limits2.memoryBytes, source: keptDisk?.path ?? restore?.path });
|
|
3783
3937
|
} catch (err) {
|
|
3938
|
+
if (keptDisk !== void 0) return giveUpItemDisk(`the kept disk could not be copied: ${describeCallFailure(err)}`, "disk_not_restored");
|
|
3784
3939
|
if (restore !== void 0) return giveUpState(`the saved disk could not be copied: ${describeCallFailure(err)}`);
|
|
3785
3940
|
throw err;
|
|
3786
3941
|
}
|
|
3787
|
-
if (
|
|
3942
|
+
if (keptDisk?.path !== void 0) {
|
|
3943
|
+
tagged(`restored the disk that claim ${shortClaim(keptDisk.record.claimId)} kept: ${formatBytes(allocatedBytes(keptDisk.path))} allocated, copied in ${formatDuration(Date.now() - restoreStartedAt)}`);
|
|
3944
|
+
} else if (restore?.path !== void 0) {
|
|
3788
3945
|
tagged(`restored saved state ${restore.id}: ${formatBytes(allocatedBytes(restore.path))} allocated, copied in ${formatDuration(Date.now() - restoreStartedAt)}`);
|
|
3789
3946
|
}
|
|
3790
3947
|
writeFileSync(
|
|
@@ -3999,15 +4156,15 @@ async function provisionMicroVmOnce(input, allowRestore) {
|
|
|
3999
4156
|
...input.requireBuildSkill === true ? { requireBuildSkill: true } : {},
|
|
4000
4157
|
// A build on the universal image, or on an image built from it, chooses and installs its runtimes.
|
|
4001
4158
|
...runtimeStepInput(report, services),
|
|
4002
|
-
setup: setupInputFor({ setupMinutes: config.build?.setupMinutes, plan, saveState, withoutBuildVariables: managed }),
|
|
4159
|
+
setup: setupInputFor({ setupMinutes: config.build?.setupMinutes, plan, saveState, withoutBuildVariables: managed, fromItemDisk: keptDisk !== void 0 }),
|
|
4003
4160
|
afterSave: releaseGhConfig
|
|
4004
4161
|
});
|
|
4005
|
-
if (!steps.ok) return settleFailedSteps(steps, { giveUp: giveUpState, bail });
|
|
4162
|
+
if (!steps.ok) return settleFailedSteps(steps, { giveUp: (reason, fromItemDisk) => fromItemDisk ? giveUpItemDisk(reason, "checkout_not_switched") : giveUpState(reason), bail });
|
|
4006
4163
|
state.startCommit = steps.startCommit;
|
|
4007
4164
|
keepRuntimeStep(state, steps);
|
|
4008
4165
|
keepMissingSetupScripts(state, steps);
|
|
4009
4166
|
if (steps.controlPlane !== void 0) environment.controlPlane = steps.controlPlane;
|
|
4010
|
-
return { ok: true, workdir: CHECKOUT_DIR, state, environment };
|
|
4167
|
+
return { ok: true, workdir: CHECKOUT_DIR, state, environment, ...itemDisk.state === void 0 ? {} : { disk: itemDisk.state } };
|
|
4011
4168
|
}
|
|
4012
4169
|
async function waitForDocker(runtime, state, agentUser, now) {
|
|
4013
4170
|
const grant = `[ -S ${DOCKER_SOCKET} ] && chgrp "$(id -g ${shellQuote(agentUser)})" ${DOCKER_SOCKET} && chmod 660 ${DOCKER_SOCKET}`;
|
|
@@ -4451,13 +4608,26 @@ async function stopBuildMicroVm(runtime, state, jobDir) {
|
|
|
4451
4608
|
await runtime.vm.firecracker.stop(state.firecracker);
|
|
4452
4609
|
if (runtime.vm.firecracker.alive(state.firecracker)) throw new Error(`the microVM (pid ${state.firecracker.pid}) is still running after it was stopped`);
|
|
4453
4610
|
}
|
|
4454
|
-
async function
|
|
4611
|
+
async function flushBuildDisk(runtime, state) {
|
|
4612
|
+
if (!isRunning(runtime, state)) return { ok: false, reason: "the microVM was gone before its writes could be flushed" };
|
|
4613
|
+
try {
|
|
4614
|
+
const flushed = await asRoot(runtime, state, ["sync", "-f", "/build"]);
|
|
4615
|
+
if (flushed.status === 0) return { ok: true };
|
|
4616
|
+
return { ok: false, reason: `the build disk could not be flushed (exit ${flushed.status})${said(flushed.stderr)}` };
|
|
4617
|
+
} catch (err) {
|
|
4618
|
+
return { ok: false, reason: `the build disk could not be flushed (${describeCallFailure(err)})` };
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
async function cleanupMicroVm(runtime, state, jobDir, warn, onBuildDisk, keepDisk) {
|
|
4455
4622
|
const failures = [];
|
|
4623
|
+
let stopFailed = false;
|
|
4456
4624
|
if (jobDir !== void 0) await copyHookErrors(runtime, state, jobDir);
|
|
4625
|
+
const flushed = keepDisk === void 0 ? void 0 : await flushBuildDisk(runtime, state);
|
|
4457
4626
|
if (state.jailed !== void 0) {
|
|
4458
4627
|
try {
|
|
4459
4628
|
await stopJailed(runtime.vm.helper, state);
|
|
4460
4629
|
} catch (err) {
|
|
4630
|
+
stopFailed = true;
|
|
4461
4631
|
failures.push(describeCallFailure(err));
|
|
4462
4632
|
}
|
|
4463
4633
|
}
|
|
@@ -4465,6 +4635,7 @@ async function cleanupMicroVm(runtime, state, jobDir, warn, onBuildDisk) {
|
|
|
4465
4635
|
try {
|
|
4466
4636
|
await runtime.vm.firecracker.stop(state.firecracker);
|
|
4467
4637
|
} catch (err) {
|
|
4638
|
+
stopFailed = true;
|
|
4468
4639
|
failures.push(`the microVM (pid ${state.firecracker.pid}) was not stopped: ${describeCallFailure(err)}`);
|
|
4469
4640
|
}
|
|
4470
4641
|
}
|
|
@@ -4482,6 +4653,16 @@ async function cleanupMicroVm(runtime, state, jobDir, warn, onBuildDisk) {
|
|
|
4482
4653
|
failures.push(`the build disk's peak size was not recorded: ${describeCallFailure(err)}`);
|
|
4483
4654
|
}
|
|
4484
4655
|
}
|
|
4656
|
+
const stillRunning = vmAlive(runtime, state);
|
|
4657
|
+
if (stillRunning && keepDisk !== void 0) warn?.("the build's disk was not kept: the microVM is still running");
|
|
4658
|
+
else if (flushed !== void 0 && !flushed.ok && !stopFailed) warn?.(`the build's disk was not kept: ${flushed.reason}`);
|
|
4659
|
+
if (keepDisk !== void 0 && flushed?.ok === true && !stopFailed && !stillRunning && state.buildDisk !== void 0 && existsSync(state.buildDisk)) {
|
|
4660
|
+
try {
|
|
4661
|
+
await keepDisk();
|
|
4662
|
+
} catch (err) {
|
|
4663
|
+
warn?.(`the build's disk was not kept: ${describeCallFailure(err)}`);
|
|
4664
|
+
}
|
|
4665
|
+
}
|
|
4485
4666
|
if (state.buildDisk !== void 0) deleteBuildDisk(state.buildDisk);
|
|
4486
4667
|
runtime.leases.get(state.buildId)?.close();
|
|
4487
4668
|
runtime.leases.delete(state.buildId);
|
|
@@ -4788,8 +4969,8 @@ function normalize(address) {
|
|
|
4788
4969
|
const zone = address.indexOf("%");
|
|
4789
4970
|
return (zone === -1 ? address : address.slice(0, zone)).toLowerCase();
|
|
4790
4971
|
}
|
|
4791
|
-
function parseTarget(
|
|
4792
|
-
const match = /^\[([^\]]+)\]:(\d+)$/.exec(
|
|
4972
|
+
function parseTarget(target2) {
|
|
4973
|
+
const match = /^\[([^\]]+)\]:(\d+)$/.exec(target2) ?? /^([^:\[\]]+):(\d+)$/.exec(target2);
|
|
4793
4974
|
if (match === null) return void 0;
|
|
4794
4975
|
const port = Number(match[2]);
|
|
4795
4976
|
return port >= 1 && port <= 65535 ? { host: match[1], port } : void 0;
|
|
@@ -5052,29 +5233,29 @@ ${body}`);
|
|
|
5052
5233
|
};
|
|
5053
5234
|
async function tunnelConnect(req, client, head) {
|
|
5054
5235
|
client.on("error", () => client.destroy());
|
|
5055
|
-
const
|
|
5056
|
-
if (
|
|
5236
|
+
const target2 = parseTarget(req.url ?? "");
|
|
5237
|
+
if (target2 === void 0) {
|
|
5057
5238
|
client.end("HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-Length: 0\r\n\r\n");
|
|
5058
5239
|
return;
|
|
5059
5240
|
}
|
|
5060
5241
|
const over = admit();
|
|
5061
5242
|
if (over !== void 0) {
|
|
5062
|
-
const refusal = refuseOverLimit(
|
|
5243
|
+
const refusal = refuseOverLimit(target2.host, over);
|
|
5063
5244
|
reply(client, refusal.status, refusal.body);
|
|
5064
5245
|
return;
|
|
5065
5246
|
}
|
|
5066
5247
|
client.once("close", release);
|
|
5067
|
-
const decision = await decide(
|
|
5248
|
+
const decision = await decide(target2.host, target2.port);
|
|
5068
5249
|
if (!decision.ok) {
|
|
5069
5250
|
reply(client, decision.status, decision.body);
|
|
5070
5251
|
return;
|
|
5071
5252
|
}
|
|
5072
|
-
const upstream = openConnection({ address: decision.address, port:
|
|
5253
|
+
const upstream = openConnection({ address: decision.address, port: target2.port });
|
|
5073
5254
|
upstream.setTimeout(connectTimeoutMs);
|
|
5074
5255
|
const failed = (err) => {
|
|
5075
5256
|
upstream.destroy();
|
|
5076
|
-
logBadGateway(`could not connect to ${
|
|
5077
|
-
reply(client, 502, `could not connect to ${
|
|
5257
|
+
logBadGateway(`could not connect to ${target2.host}:${target2.port}, ${err === void 0 ? "ETIMEDOUT" : errorCode(err)}`);
|
|
5258
|
+
reply(client, 502, `could not connect to ${target2.host}
|
|
5078
5259
|
`);
|
|
5079
5260
|
};
|
|
5080
5261
|
const timedOut = () => failed();
|
|
@@ -5097,7 +5278,7 @@ ${body}`);
|
|
|
5097
5278
|
const metered = limits2.sendBytesPerSecond > 0 ? meter() : void 0;
|
|
5098
5279
|
if (metered === void 0) client.once("end", buildEnded);
|
|
5099
5280
|
else metered.once("end", buildEnded);
|
|
5100
|
-
reached(
|
|
5281
|
+
reached(target2.host);
|
|
5101
5282
|
client.write("HTTP/1.1 200 Connection Established\r\n\r\n");
|
|
5102
5283
|
if (metered !== void 0) {
|
|
5103
5284
|
if (head.length > 0) metered.write(head);
|
|
@@ -5438,7 +5619,7 @@ function runWithSpawn(spawnFn = spawn) {
|
|
|
5438
5619
|
let stderr = "";
|
|
5439
5620
|
let timer;
|
|
5440
5621
|
let settled = false;
|
|
5441
|
-
const
|
|
5622
|
+
const finish2 = (result) => {
|
|
5442
5623
|
if (settled) return;
|
|
5443
5624
|
settled = true;
|
|
5444
5625
|
if (timer !== void 0) clearTimeout(timer);
|
|
@@ -5448,12 +5629,12 @@ function runWithSpawn(spawnFn = spawn) {
|
|
|
5448
5629
|
try {
|
|
5449
5630
|
child = spawnFn(file, args, { env, stdio: ["ignore", "pipe", "pipe"] });
|
|
5450
5631
|
} catch (err) {
|
|
5451
|
-
|
|
5632
|
+
finish2({ error: err instanceof Error ? err : new Error(String(err)) });
|
|
5452
5633
|
return;
|
|
5453
5634
|
}
|
|
5454
5635
|
timer = setTimeout(() => {
|
|
5455
5636
|
child.kill("SIGKILL");
|
|
5456
|
-
|
|
5637
|
+
finish2({ error: new Error(`it did not finish in ${timeoutMs / 1e3}s`) });
|
|
5457
5638
|
}, timeoutMs);
|
|
5458
5639
|
child.stdout?.on("data", (chunk) => {
|
|
5459
5640
|
stdout += String(chunk);
|
|
@@ -5461,8 +5642,8 @@ function runWithSpawn(spawnFn = spawn) {
|
|
|
5461
5642
|
child.stderr?.on("data", (chunk) => {
|
|
5462
5643
|
stderr += String(chunk);
|
|
5463
5644
|
});
|
|
5464
|
-
child.on("error", (err) =>
|
|
5465
|
-
child.on("close", (status, signal) =>
|
|
5645
|
+
child.on("error", (err) => finish2({ error: err }));
|
|
5646
|
+
child.on("close", (status, signal) => finish2({ status, signal }));
|
|
5466
5647
|
});
|
|
5467
5648
|
}
|
|
5468
5649
|
async function deliverMavenSettings(build, workdir, base, run, timeoutMs = MAVEN_WRITE_TIMEOUT_MS) {
|
|
@@ -5891,6 +6072,288 @@ async function provisionProcess(input) {
|
|
|
5891
6072
|
function cleanupProcess(runtime, state) {
|
|
5892
6073
|
return closeHostBuild(runtime, state);
|
|
5893
6074
|
}
|
|
6075
|
+
var SAVED_FOLDERS = ["home", "work"];
|
|
6076
|
+
function stopProcessesScript() {
|
|
6077
|
+
return [
|
|
6078
|
+
"me=$$; uid=$(id -u); n=0; pass=0",
|
|
6079
|
+
"while [ $pass -lt 25 ]; do",
|
|
6080
|
+
' left=""',
|
|
6081
|
+
" for p in /proc/[0-9]*; do",
|
|
6082
|
+
" pid=${p##*/}",
|
|
6083
|
+
' [ "$pid" = "$me" ] && continue',
|
|
6084
|
+
` info=$(sed -n -e 's/^State:[[:space:]]*\\(.\\).*/S=\\1/p' -e 's/^Uid:[[:space:]]*\\([0-9]*\\).*/U=\\1/p' "$p/status" 2>/dev/null) || continue`,
|
|
6085
|
+
' case "$info" in *"S=Z"*) continue ;; esac',
|
|
6086
|
+
// The uid is the last line of `info`, so a match at its end cannot be the longer id 10000 for 1000.
|
|
6087
|
+
' case "$info" in *"U=$uid") left="$left $pid" ;; esac',
|
|
6088
|
+
" done",
|
|
6089
|
+
' [ -z "$left" ] && break',
|
|
6090
|
+
' for pid in $left; do kill -KILL "$pid" 2>/dev/null && n=$((n+1)); done',
|
|
6091
|
+
" pass=$((pass+1))",
|
|
6092
|
+
" sleep 0.2",
|
|
6093
|
+
"done",
|
|
6094
|
+
'[ -z "$left" ] || { echo "$left are still running" >&2; exit 1; }',
|
|
6095
|
+
'echo "stopped $n"'
|
|
6096
|
+
].join("\n");
|
|
6097
|
+
}
|
|
6098
|
+
var HELPER_FLAGS = [
|
|
6099
|
+
"--rm",
|
|
6100
|
+
"--network",
|
|
6101
|
+
"none",
|
|
6102
|
+
"--cap-drop",
|
|
6103
|
+
"ALL",
|
|
6104
|
+
"--cap-add",
|
|
6105
|
+
"CHOWN",
|
|
6106
|
+
"--cap-add",
|
|
6107
|
+
"DAC_OVERRIDE",
|
|
6108
|
+
"--cap-add",
|
|
6109
|
+
"DAC_READ_SEARCH",
|
|
6110
|
+
"--cap-add",
|
|
6111
|
+
"FOWNER",
|
|
6112
|
+
"--security-opt",
|
|
6113
|
+
"no-new-privileges",
|
|
6114
|
+
"--read-only",
|
|
6115
|
+
"--user",
|
|
6116
|
+
"0",
|
|
6117
|
+
"--pids-limit",
|
|
6118
|
+
"256"
|
|
6119
|
+
];
|
|
6120
|
+
function helperArgs(input) {
|
|
6121
|
+
return [
|
|
6122
|
+
...HELPER_FLAGS,
|
|
6123
|
+
"--label",
|
|
6124
|
+
`${RUNNER_LABEL}=${input.runnerId}`,
|
|
6125
|
+
"--mount",
|
|
6126
|
+
`type=volume,src=${input.from},dst=/from,readonly`,
|
|
6127
|
+
"--mount",
|
|
6128
|
+
`type=volume,src=${input.to},dst=/to`,
|
|
6129
|
+
"--entrypoint",
|
|
6130
|
+
"sh",
|
|
6131
|
+
input.image,
|
|
6132
|
+
"-c",
|
|
6133
|
+
input.script
|
|
6134
|
+
];
|
|
6135
|
+
}
|
|
6136
|
+
var SAVE_SCRIPT = `set -e; cp -a ${SAVED_FOLDERS.map((name) => `/from/${name}`).join(" ")} /to/; du -sk /to | cut -f1`;
|
|
6137
|
+
var RESTORE_SCRIPT = `set -e; cp -a ${SAVED_FOLDERS.map((name) => `/from/${name}`).join(" ")} /to/`;
|
|
6138
|
+
function failureText3(result) {
|
|
6139
|
+
const line2 = result.stderr.trim().split("\n").at(-1) ?? "";
|
|
6140
|
+
return `exit ${result.status}${line2 === "" ? "" : `: ${line2}`}`;
|
|
6141
|
+
}
|
|
6142
|
+
async function saveContainerState(input) {
|
|
6143
|
+
const { host } = input;
|
|
6144
|
+
const id = randomBytes(6).toString("hex");
|
|
6145
|
+
const volume = `outerlayer-saved-${id}`;
|
|
6146
|
+
const record = {
|
|
6147
|
+
id,
|
|
6148
|
+
kind: "volume",
|
|
6149
|
+
volume,
|
|
6150
|
+
savedAt: input.now.toISOString(),
|
|
6151
|
+
bytes: 0,
|
|
6152
|
+
baseKey: input.key.baseKey,
|
|
6153
|
+
key: input.key.key,
|
|
6154
|
+
fileHashes: input.key.fileHashes,
|
|
6155
|
+
...input.agentUid === void 0 ? {} : { agentUid: input.agentUid },
|
|
6156
|
+
complete: false
|
|
6157
|
+
};
|
|
6158
|
+
const discard = async (reason) => {
|
|
6159
|
+
const removed = await host.removeVolume(volume).catch((err) => ({ status: -1, stderr: describeCallFailure(err) }));
|
|
6160
|
+
if (removed.status !== 0) {
|
|
6161
|
+
input.log(`the volume ${volume} could not be removed (${failureText3({ status: removed.status, stderr: removed.stderr })}); its record stays so a later pass retries`);
|
|
6162
|
+
return { ok: false, reason };
|
|
6163
|
+
}
|
|
6164
|
+
deleteRecord(input.dir, id);
|
|
6165
|
+
return { ok: false, reason };
|
|
6166
|
+
};
|
|
6167
|
+
try {
|
|
6168
|
+
const noEnv = { literals: {}, passed: {} };
|
|
6169
|
+
const stopped = await host.exec({ container: input.container, user: input.agentUser, env: noEnv, argv: ["sh", "-c", stopProcessesScript()] });
|
|
6170
|
+
if (stopped.status !== 0) return { ok: false, reason: `the build's processes could not be stopped (${failureText3(stopped)})` };
|
|
6171
|
+
input.log(`${stopped.stdout.trim() || "stopped 0"} process${stopped.stdout.trim() === "stopped 1" ? "" : "es"} before saving the state`);
|
|
6172
|
+
const flushed = await host.exec({ container: input.container, user: input.agentUser, env: noEnv, argv: ["sync"] });
|
|
6173
|
+
if (flushed.status !== 0) return { ok: false, reason: `the build's disk could not be flushed (${failureText3(flushed)})` };
|
|
6174
|
+
writeRecord2(input.dir, record);
|
|
6175
|
+
const created = await host.createVolume(volume, { [SAVED_STATE_LABEL]: id, [RUNNER_LABEL]: input.runnerId });
|
|
6176
|
+
if (created.status !== 0) return await discard(`the volume for the saved state could not be made (${failureText3(created)})`);
|
|
6177
|
+
const copied = await host.run(helperArgs({ image: input.image, from: input.buildVolume, to: volume, script: SAVE_SCRIPT, runnerId: input.runnerId }), { logPath: input.logPath });
|
|
6178
|
+
if (copied.status !== 0) return await discard(`the copy into the saved state failed (${failureText3(copied)})`);
|
|
6179
|
+
const kilobytes = Number(copied.stdout.trim().split("\n").at(-1));
|
|
6180
|
+
const done = { ...record, bytes: Number.isFinite(kilobytes) ? kilobytes * 1024 : 0, complete: true };
|
|
6181
|
+
writeRecord2(input.dir, done);
|
|
6182
|
+
return { ok: true, record: done };
|
|
6183
|
+
} catch (err) {
|
|
6184
|
+
return await discard(`the state could not be saved: ${describeCallFailure(err)}`);
|
|
6185
|
+
}
|
|
6186
|
+
}
|
|
6187
|
+
async function restoreContainerState(input) {
|
|
6188
|
+
try {
|
|
6189
|
+
const copied = await input.host.run(helperArgs({ image: input.image, from: input.savedVolume, to: input.targetVolume, script: RESTORE_SCRIPT, runnerId: input.runnerId }), { logPath: input.logPath });
|
|
6190
|
+
if (copied.status !== 0) return { ok: false, reason: `the saved volume could not be copied (${failureText3(copied)})` };
|
|
6191
|
+
return { ok: true };
|
|
6192
|
+
} catch (err) {
|
|
6193
|
+
return { ok: false, reason: `the saved volume could not be copied: ${describeCallFailure(err)}` };
|
|
6194
|
+
}
|
|
6195
|
+
}
|
|
6196
|
+
|
|
6197
|
+
// src/runner/workspace/keep.ts
|
|
6198
|
+
function recordOf(input, kind, bytes, volume) {
|
|
6199
|
+
return {
|
|
6200
|
+
workItemId: input.workItemId,
|
|
6201
|
+
claimId: input.claimId,
|
|
6202
|
+
queue: input.queue,
|
|
6203
|
+
imageId: input.imageId,
|
|
6204
|
+
diskBytes: input.diskBytes,
|
|
6205
|
+
kind,
|
|
6206
|
+
...volume === void 0 ? {} : { volume },
|
|
6207
|
+
bytes,
|
|
6208
|
+
keptAt: input.now.toISOString()
|
|
6209
|
+
};
|
|
6210
|
+
}
|
|
6211
|
+
function finish(input, dir, staging, record) {
|
|
6212
|
+
writeFileSync(join(staging, RECORD_FILE), `${JSON.stringify(record, null, 2)}
|
|
6213
|
+
`, { mode: RUNNER_FILE_MODE });
|
|
6214
|
+
const older = swapInItemDisk(dir, staging);
|
|
6215
|
+
if (record.kind === "disk" && older?.record.kind === "volume") {
|
|
6216
|
+
input.log(`the work item's older disk was the Docker volume ${older.record.volume}, which this copy replaces; remove the volume with \`docker volume rm\``);
|
|
6217
|
+
}
|
|
6218
|
+
}
|
|
6219
|
+
async function keepMicroVmDisk(input) {
|
|
6220
|
+
let dir;
|
|
6221
|
+
try {
|
|
6222
|
+
dir = itemDiskDir(input.configPath, input.organizationId, input.workItemId);
|
|
6223
|
+
} catch (err) {
|
|
6224
|
+
return { ok: false, reason: describeCallFailure(err) };
|
|
6225
|
+
}
|
|
6226
|
+
let staging;
|
|
6227
|
+
const helperCopy = join(input.buildDir, HELPER_COPY_NAME);
|
|
6228
|
+
try {
|
|
6229
|
+
staging = stagingItemDiskDir(dir);
|
|
6230
|
+
const target2 = join(staging, DISK_FILE);
|
|
6231
|
+
if (input.helper !== void 0) {
|
|
6232
|
+
rmSync(helperCopy, { force: true });
|
|
6233
|
+
await input.helper.copy(input.buildId);
|
|
6234
|
+
renameSync(helperCopy, target2);
|
|
6235
|
+
} else {
|
|
6236
|
+
await (input.copyDisk ?? copyDiskFile)(input.buildDisk, target2);
|
|
6237
|
+
}
|
|
6238
|
+
chmodSync(target2, RUNNER_FILE_MODE);
|
|
6239
|
+
const record = recordOf(input, "disk", allocatedBytes(target2));
|
|
6240
|
+
finish(input, dir, staging, record);
|
|
6241
|
+
staging = void 0;
|
|
6242
|
+
return { ok: true, record };
|
|
6243
|
+
} catch (err) {
|
|
6244
|
+
return { ok: false, reason: `the build disk could not be copied: ${describeCallFailure(err)}` };
|
|
6245
|
+
} finally {
|
|
6246
|
+
if (staging !== void 0) rmSync(staging, { recursive: true, force: true });
|
|
6247
|
+
rmSync(helperCopy, { force: true });
|
|
6248
|
+
}
|
|
6249
|
+
}
|
|
6250
|
+
async function keepContainerDisk(input) {
|
|
6251
|
+
let dir;
|
|
6252
|
+
try {
|
|
6253
|
+
dir = itemDiskDir(input.configPath, input.organizationId, input.workItemId);
|
|
6254
|
+
} catch (err) {
|
|
6255
|
+
return { ok: false, reason: describeCallFailure(err) };
|
|
6256
|
+
}
|
|
6257
|
+
const { host } = input;
|
|
6258
|
+
const volume = `outerlayer-workspace-${randomBytes(6).toString("hex")}`;
|
|
6259
|
+
let created = false;
|
|
6260
|
+
let staging;
|
|
6261
|
+
const dropNew = async () => {
|
|
6262
|
+
if (!created) return;
|
|
6263
|
+
const removed = await host.removeVolume(volume).catch((err) => ({ status: -1, stderr: describeCallFailure(err) }));
|
|
6264
|
+
if (removed.status !== 0) input.log(`the volume ${volume} could not be removed (${failureText3({ status: removed.status, stderr: removed.stderr })})`);
|
|
6265
|
+
};
|
|
6266
|
+
try {
|
|
6267
|
+
const made = await host.createVolume(volume, { [WORKSPACE_LABEL]: input.workItemId, [RUNNER_LABEL]: input.runnerId });
|
|
6268
|
+
if (made.status !== 0) return { ok: false, reason: `the volume for the kept disk could not be made (${failureText3(made)})` };
|
|
6269
|
+
created = true;
|
|
6270
|
+
const copied = await host.run(helperArgs({ image: input.image, from: input.buildVolume, to: volume, script: SAVE_SCRIPT, runnerId: input.runnerId }), { logPath: input.logPath });
|
|
6271
|
+
if (copied.status !== 0) {
|
|
6272
|
+
await dropNew();
|
|
6273
|
+
return { ok: false, reason: `the copy into the kept disk failed (${failureText3(copied)})` };
|
|
6274
|
+
}
|
|
6275
|
+
const kilobytes = Number(copied.stdout.trim().split("\n").at(-1));
|
|
6276
|
+
const record = recordOf(input, "volume", Number.isFinite(kilobytes) ? kilobytes * 1024 : 0, volume);
|
|
6277
|
+
const older = readItemDisk(dir);
|
|
6278
|
+
if (older?.record.volume !== void 0) {
|
|
6279
|
+
const removed = await host.removeVolume(older.record.volume);
|
|
6280
|
+
if (removed.status !== 0 && !/no such volume/i.test(removed.stderr)) {
|
|
6281
|
+
await dropNew();
|
|
6282
|
+
return { ok: false, reason: `the work item's older disk could not be replaced: its volume ${older.record.volume} was not removed (${failureText3(removed)})` };
|
|
6283
|
+
}
|
|
6284
|
+
}
|
|
6285
|
+
staging = stagingItemDiskDir(dir);
|
|
6286
|
+
finish(input, dir, staging, record);
|
|
6287
|
+
staging = void 0;
|
|
6288
|
+
return { ok: true, record };
|
|
6289
|
+
} catch (err) {
|
|
6290
|
+
await dropNew();
|
|
6291
|
+
return { ok: false, reason: `the build's volume could not be copied: ${describeCallFailure(err)}` };
|
|
6292
|
+
} finally {
|
|
6293
|
+
if (staging !== void 0) rmSync(staging, { recursive: true, force: true });
|
|
6294
|
+
}
|
|
6295
|
+
}
|
|
6296
|
+
|
|
6297
|
+
// src/runner/workspace/finish.ts
|
|
6298
|
+
function noDiskReason(job, config) {
|
|
6299
|
+
if (job.workItemId === void 0) return "the job names no work item";
|
|
6300
|
+
if (config.managed === true && (job.managedVariables?.length ?? 0) > 0) return "the build held a factory build variable, and the runner cannot remove a value that a command stored in an encoded form";
|
|
6301
|
+
return void 0;
|
|
6302
|
+
}
|
|
6303
|
+
function target(input, imageId, diskBytes) {
|
|
6304
|
+
return {
|
|
6305
|
+
configPath: input.config.configPath,
|
|
6306
|
+
...input.job.organizationId === void 0 ? {} : { organizationId: input.job.organizationId },
|
|
6307
|
+
workItemId: input.job.workItemId,
|
|
6308
|
+
claimId: input.job.claimId,
|
|
6309
|
+
queue: input.job.queue,
|
|
6310
|
+
imageId,
|
|
6311
|
+
diskBytes,
|
|
6312
|
+
now: input.now(),
|
|
6313
|
+
log: (line2) => input.log.line(`${input.tag} ${line2}`)
|
|
6314
|
+
};
|
|
6315
|
+
}
|
|
6316
|
+
function microVmDiskKeeper(input) {
|
|
6317
|
+
const state = input.job.microvm;
|
|
6318
|
+
if (state === void 0) return void 0;
|
|
6319
|
+
const refused2 = noDiskReason(input.job, input.config);
|
|
6320
|
+
if (refused2 !== void 0) {
|
|
6321
|
+
if (input.job.workItemId !== void 0) input.log.line(`${input.tag} the build disk is not kept: ${refused2}`);
|
|
6322
|
+
return void 0;
|
|
6323
|
+
}
|
|
6324
|
+
if (state.imageId === void 0 || state.limits === void 0 || state.buildDisk === void 0) return void 0;
|
|
6325
|
+
const { imageId, buildDisk } = state;
|
|
6326
|
+
const diskBytes = state.limits.diskBytes;
|
|
6327
|
+
return async () => {
|
|
6328
|
+
let helper;
|
|
6329
|
+
if (state.jailed !== void 0) {
|
|
6330
|
+
const probe = await input.runtime.vm.helper.probe();
|
|
6331
|
+
if (!probe.ok) throw new Error(`the root helper does not answer (${probe.detail})`);
|
|
6332
|
+
helper = probe.client;
|
|
6333
|
+
}
|
|
6334
|
+
const copyDisk = input.runtime.vm.rootfs.copyDisk?.bind(input.runtime.vm.rootfs);
|
|
6335
|
+
const kept = await keepMicroVmDisk({ ...target(input, imageId, diskBytes), buildId: state.buildId, buildDisk, buildDir: state.buildDir, ...helper === void 0 ? {} : { helper }, ...copyDisk === void 0 ? {} : { copyDisk } });
|
|
6336
|
+
if (!kept.ok) throw new Error(kept.reason);
|
|
6337
|
+
input.log.line(`${input.tag} kept the build disk for the work item: ${formatBytes(kept.record.bytes)} allocated`);
|
|
6338
|
+
};
|
|
6339
|
+
}
|
|
6340
|
+
function containerDiskKeeper(input) {
|
|
6341
|
+
const state = input.job.container;
|
|
6342
|
+
if (state === void 0) return void 0;
|
|
6343
|
+
const refused2 = noDiskReason(input.job, input.config);
|
|
6344
|
+
if (refused2 !== void 0) {
|
|
6345
|
+
if (input.job.workItemId !== void 0) input.log.line(`${input.tag} the build disk is not kept: ${refused2}`);
|
|
6346
|
+
return void 0;
|
|
6347
|
+
}
|
|
6348
|
+
if (state.imageId === void 0) return void 0;
|
|
6349
|
+
const { imageId } = state;
|
|
6350
|
+
const diskBytes = parseSize(input.config.build?.disk ?? DEFAULT_BUILD_DISK) ?? 0;
|
|
6351
|
+
return async () => {
|
|
6352
|
+
const kept = await keepContainerDisk({ ...target(input, imageId, diskBytes), host: input.runtime.host, image: imageId, buildVolume: state.volume, runnerId: runnerLabelValue(input.config.configPath) });
|
|
6353
|
+
if (!kept.ok) throw new Error(kept.reason);
|
|
6354
|
+
input.log.line(`${input.tag} kept the build disk for the work item: ${formatBytes(kept.record.bytes)} allocated`);
|
|
6355
|
+
};
|
|
6356
|
+
}
|
|
5894
6357
|
var SESSION_TAR = "session.tar";
|
|
5895
6358
|
async function guestOf(job, runtime) {
|
|
5896
6359
|
if (job.microvm !== void 0) {
|
|
@@ -6242,7 +6705,7 @@ async function runJudge(input) {
|
|
|
6242
6705
|
log.line(`${tag} judge: ${plan.toJudge.length} of ${list.length} criteria to judge, ${list.length - plan.toJudge.length} settled without the judge`);
|
|
6243
6706
|
}
|
|
6244
6707
|
if (criteria !== void 0 && plan.toJudge.length === 0) {
|
|
6245
|
-
return await
|
|
6708
|
+
return await finish2(check, { criteria, items: plan.settled, citations, head, branch, finder, judgeReport: void 0 });
|
|
6246
6709
|
}
|
|
6247
6710
|
let diff = "";
|
|
6248
6711
|
const startCommit = (job.container ?? job.microvm)?.startCommit;
|
|
@@ -6317,19 +6780,19 @@ async function runJudge(input) {
|
|
|
6317
6780
|
];
|
|
6318
6781
|
if (answer?.ok === true) {
|
|
6319
6782
|
const results2 = new Map(answer.answer.items.map((entry) => [entry.id, entry]));
|
|
6320
|
-
return await
|
|
6783
|
+
return await finish2(check, { criteria, items: judged(results2), citations, head, branch, finder, judgeReport: void 0 });
|
|
6321
6784
|
}
|
|
6322
6785
|
if (reply.kind === "none") {
|
|
6323
|
-
return await
|
|
6786
|
+
return await finish2(check, { criteria, items: judged(/* @__PURE__ */ new Map()), citations, head, branch, finder, judgeReport: report, reason: reply.reason, limitKey: reply.limitKey === true });
|
|
6324
6787
|
}
|
|
6325
6788
|
if (answer !== void 0) {
|
|
6326
|
-
return await
|
|
6789
|
+
return await finish2(check, { criteria, items: judged(/* @__PURE__ */ new Map()), citations, head, branch, finder, judgeReport: report, reason: answer.reason });
|
|
6327
6790
|
}
|
|
6328
6791
|
const failsAll = reply.verdict === "fail" && reply.unmet.size === 0;
|
|
6329
6792
|
const results = new Map(plan.toJudge.map((criterion) => [criterion.id, { result: failsAll || reply.unmet.has(criterion.id) ? "fail" : "pass" }]));
|
|
6330
|
-
return await
|
|
6793
|
+
return await finish2(check, { criteria, items: judged(results), citations, head, branch, finder, judgeReport: report });
|
|
6331
6794
|
}
|
|
6332
|
-
async function
|
|
6795
|
+
async function finish2(check, at) {
|
|
6333
6796
|
const items = inCriteriaOrder(at.items, at.criteria);
|
|
6334
6797
|
const failing = itemsSentence(items, { one: "criterion", many: "criteria" });
|
|
6335
6798
|
const result = failing === void 0 ? "pass" : "fail";
|
|
@@ -6772,12 +7235,12 @@ async function renewLease(config, item, fetchImpl) {
|
|
|
6772
7235
|
}
|
|
6773
7236
|
var ALREADY_RELEASED = "already released";
|
|
6774
7237
|
async function releaseLease(config, item, outcome, detail, fetchImpl) {
|
|
6775
|
-
const send = async (environment2, sent2, log2, resume2) => postJson(
|
|
7238
|
+
const send = async (environment2, sent2, log2, resume2, disk2) => postJson(
|
|
6776
7239
|
config.url,
|
|
6777
7240
|
`/v1/work-items/${item}/claim/release`,
|
|
6778
7241
|
config.apiKey,
|
|
6779
7242
|
config.appId,
|
|
6780
|
-
{ host: config.host, outcome: sent2, stage: detail.stage, exitCode: detail.exitCode, reason: detail.reason, environment: environment2, resume: resume2, log: log2 },
|
|
7243
|
+
{ host: config.host, outcome: sent2, stage: detail.stage, exitCode: detail.exitCode, reason: detail.reason, environment: environment2, resume: resume2, disk: disk2, log: log2 },
|
|
6781
7244
|
fetchImpl,
|
|
6782
7245
|
void 0,
|
|
6783
7246
|
await signerFor(config.configPath)
|
|
@@ -6786,10 +7249,11 @@ async function releaseLease(config, item, outcome, detail, fetchImpl) {
|
|
|
6786
7249
|
let sent = outcome;
|
|
6787
7250
|
let log = detail.log;
|
|
6788
7251
|
let resume = detail.resume;
|
|
7252
|
+
let disk = detail.disk;
|
|
6789
7253
|
let data;
|
|
6790
7254
|
for (; ; ) {
|
|
6791
7255
|
try {
|
|
6792
|
-
({ data } = await send(environment, sent, log, resume));
|
|
7256
|
+
({ data } = await send(environment, sent, log, resume, disk));
|
|
6793
7257
|
break;
|
|
6794
7258
|
} catch (err) {
|
|
6795
7259
|
if (!(err instanceof WorkCommandError) || err.status !== 400 || err.code !== "invalid_request_body") throw err;
|
|
@@ -6798,6 +7262,8 @@ async function releaseLease(config, item, outcome, detail, fetchImpl) {
|
|
|
6798
7262
|
sent = "ok";
|
|
6799
7263
|
} else if (resume !== void 0 && /\bresume\b/.test(err.message)) {
|
|
6800
7264
|
resume = void 0;
|
|
7265
|
+
} else if (disk !== void 0 && /\bdisk\b/.test(err.message)) {
|
|
7266
|
+
disk = void 0;
|
|
6801
7267
|
} else if (log !== void 0 && /\blog\b/.test(err.message)) {
|
|
6802
7268
|
log = void 0;
|
|
6803
7269
|
} else if (environment?.routes !== void 0) {
|
|
@@ -7166,7 +7632,8 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
|
|
|
7166
7632
|
job.buildDiskPeakBytes = bytes;
|
|
7167
7633
|
writeJobFile(join(jobDirPath, "job.json"), job);
|
|
7168
7634
|
log.line(`${tag} build disk peak ${formatBytes(bytes)}`);
|
|
7169
|
-
}
|
|
7635
|
+
},
|
|
7636
|
+
microVmDiskKeeper({ job, config, runtime: vmBuild.runtime, now, log, tag, jobDirPath })
|
|
7170
7637
|
);
|
|
7171
7638
|
} catch (err) {
|
|
7172
7639
|
cleanedUp = false;
|
|
@@ -7179,7 +7646,7 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
|
|
|
7179
7646
|
if (build !== void 0) {
|
|
7180
7647
|
tunnelRecord = build.runtime.tunnels.get(build.state.buildId)?.record();
|
|
7181
7648
|
try {
|
|
7182
|
-
await cleanupContainer(build.runtime, build.state, jobDirPath);
|
|
7649
|
+
await cleanupContainer(build.runtime, build.state, jobDirPath, containerDiskKeeper({ job, config, runtime: build.runtime, now, log, tag, jobDirPath }), (text2) => log.error(`${tag} ${text2}`));
|
|
7183
7650
|
} catch (err) {
|
|
7184
7651
|
cleanedUp = false;
|
|
7185
7652
|
log.error(`${tag} cleanup failed: ${describeCallFailure(err)} \xB7 continuing`);
|
|
@@ -7323,7 +7790,7 @@ async function finishJob(job, jobDirPath, outcome, config, deps, ending) {
|
|
|
7323
7790
|
const sentAtMs = now().getTime();
|
|
7324
7791
|
const runnerLog = valuesNotHeld ? `The runner sends no log for this attempt: ${VALUES_NOT_HELD}.
|
|
7325
7792
|
` : releaseLogFor(jobDirPath, job, config);
|
|
7326
|
-
const detail = outcome === void 0 ? { log: runnerLog } : { stage: job.endStage, exitCode: job.endExitCode, reason: job.reason, environment: job.environment, resume: job.resume, log: runnerLog };
|
|
7793
|
+
const detail = outcome === void 0 ? { log: runnerLog } : { stage: job.endStage, exitCode: job.endExitCode, reason: job.reason, environment: job.environment, resume: job.resume, disk: job.disk, log: runnerLog };
|
|
7327
7794
|
const release = await retrySend(() => releaseLease(claimCalls(config, job), claimItem(config, job), outcome, detail, deps.fetchImpl), {
|
|
7328
7795
|
now: deps.now,
|
|
7329
7796
|
sleep: deps.sleep
|
|
@@ -7394,7 +7861,7 @@ async function retryFailedReleases(jobsDirPath, config, deps) {
|
|
|
7394
7861
|
continue;
|
|
7395
7862
|
}
|
|
7396
7863
|
const runnerLog = readScrubbedReleaseLog(dirPath) ?? releaseLogFor(dirPath, job, config);
|
|
7397
|
-
const detail = job.outcome === void 0 ? { log: runnerLog } : { stage: job.endStage, exitCode: job.endExitCode, reason: job.reason, environment: job.environment, resume: job.resume, log: runnerLog };
|
|
7864
|
+
const detail = job.outcome === void 0 ? { log: runnerLog } : { stage: job.endStage, exitCode: job.endExitCode, reason: job.reason, environment: job.environment, resume: job.resume, disk: job.disk, log: runnerLog };
|
|
7398
7865
|
const release = await retrySend(() => releaseLease(claimCalls(config, job), claimItem(config, job), job.outcome, detail, deps.fetchImpl), {
|
|
7399
7866
|
now: deps.now,
|
|
7400
7867
|
sleep: deps.sleep
|
|
@@ -7644,15 +8111,108 @@ async function housekeepingDockerIfReachable(deps) {
|
|
|
7644
8111
|
}
|
|
7645
8112
|
return createHousekeepingDocker(deps);
|
|
7646
8113
|
}
|
|
8114
|
+
var DAY_MS = 864e5;
|
|
8115
|
+
var STAGING_GRACE_MS = 36e5;
|
|
8116
|
+
var keptAtOf = (entry) => Date.parse(entry.kept.record.keptAt);
|
|
8117
|
+
var oldestFirst2 = (entries) => [...entries].sort((a, b) => keptAtOf(a) - keptAtOf(b));
|
|
8118
|
+
var bytesOf = (entries) => entries.reduce((sum, entry) => sum + entry.kept.record.bytes, 0);
|
|
8119
|
+
function allEntries(configPath) {
|
|
8120
|
+
return storeScopes(configPath).flatMap((scope) => listItemDisks(configPath, scope).map((kept) => ({ scope, kept })));
|
|
8121
|
+
}
|
|
8122
|
+
async function removeEntry(entry, removeVolume) {
|
|
8123
|
+
const { record, dir } = entry.kept;
|
|
8124
|
+
if (record.kind === "volume" && record.volume !== void 0) {
|
|
8125
|
+
if (removeVolume === void 0) throw new Error("Docker is not available");
|
|
8126
|
+
await removeVolume(record.volume);
|
|
8127
|
+
}
|
|
8128
|
+
rmSync(dir, { recursive: true, force: true });
|
|
8129
|
+
}
|
|
8130
|
+
function treeBytes(path) {
|
|
8131
|
+
try {
|
|
8132
|
+
const stats = lstatSync(path);
|
|
8133
|
+
if (!stats.isDirectory()) return stats.blocks * 512;
|
|
8134
|
+
return readdirSync(path).reduce((sum, name) => sum + treeBytes(join(path, name)), 0);
|
|
8135
|
+
} catch {
|
|
8136
|
+
return 0;
|
|
8137
|
+
}
|
|
8138
|
+
}
|
|
8139
|
+
async function removeItemDisks(input) {
|
|
8140
|
+
const { configPath, limits: limits2, nowMs } = input;
|
|
8141
|
+
let freed = 0;
|
|
8142
|
+
for (const scope of storeScopes(configPath)) {
|
|
8143
|
+
for (const leftover of listLeftovers(configPath, scope)) {
|
|
8144
|
+
const staging = leftover.path.split("/").at(-1).startsWith(".");
|
|
8145
|
+
const limit = staging ? STAGING_GRACE_MS : limits2.keepDays * DAY_MS;
|
|
8146
|
+
if (nowMs - leftover.mtimeMs < limit) continue;
|
|
8147
|
+
const size = treeBytes(leftover.path);
|
|
8148
|
+
try {
|
|
8149
|
+
rmSync(leftover.path, { recursive: true, force: true });
|
|
8150
|
+
freed += size;
|
|
8151
|
+
input.log(`housekeeping: removed ${leftover.path} (${formatBytes(size)}), a kept disk that was never finished or has no record`);
|
|
8152
|
+
} catch (err) {
|
|
8153
|
+
input.error(`housekeeping: could not remove ${leftover.path}: ${describeCallFailure(err)}`);
|
|
8154
|
+
}
|
|
8155
|
+
}
|
|
8156
|
+
}
|
|
8157
|
+
const gone = /* @__PURE__ */ new Set();
|
|
8158
|
+
const remove = async (entry, why) => {
|
|
8159
|
+
try {
|
|
8160
|
+
await removeEntry(entry, input.removeVolume);
|
|
8161
|
+
gone.add(entry);
|
|
8162
|
+
freed += entry.kept.record.bytes;
|
|
8163
|
+
input.log(`housekeeping: removed the kept disk of work item ${entry.kept.record.workItemId} (${formatBytes(entry.kept.record.bytes)}), ${why}`);
|
|
8164
|
+
} catch (err) {
|
|
8165
|
+
input.error(`housekeeping: could not remove the kept disk of work item ${entry.kept.record.workItemId}: ${describeCallFailure(err)}`);
|
|
8166
|
+
}
|
|
8167
|
+
};
|
|
8168
|
+
const entries = allEntries(configPath);
|
|
8169
|
+
for (const entry of entries) {
|
|
8170
|
+
const sinceMs = nowMs - keptAtOf(entry);
|
|
8171
|
+
if (sinceMs >= limits2.keepDays * DAY_MS) await remove(entry, `no job replaced it for ${formatDuration(sinceMs)}, past runner.housekeeping.workspaceKeepDays`);
|
|
8172
|
+
}
|
|
8173
|
+
for (const scope of new Set(entries.map((entry) => entry.scope))) {
|
|
8174
|
+
if (scope === void 0) continue;
|
|
8175
|
+
const mine = oldestFirst2(entries.filter((entry) => entry.scope === scope && !gone.has(entry)));
|
|
8176
|
+
let total2 = bytesOf(mine);
|
|
8177
|
+
for (const entry of mine.slice(0, -1)) {
|
|
8178
|
+
if (total2 <= limits2.orgMax) break;
|
|
8179
|
+
const before = gone.size;
|
|
8180
|
+
await remove(entry, `organization ${scope}'s kept disks pass runner.housekeeping.workspaceOrgMax`);
|
|
8181
|
+
if (gone.size > before) total2 -= entry.kept.record.bytes;
|
|
8182
|
+
}
|
|
8183
|
+
}
|
|
8184
|
+
let total = bytesOf(entries.filter((entry) => !gone.has(entry)));
|
|
8185
|
+
for (const entry of oldestFirst2(entries.filter((candidate) => !gone.has(candidate)))) {
|
|
8186
|
+
if (total <= limits2.max) break;
|
|
8187
|
+
const before = gone.size;
|
|
8188
|
+
await remove(entry, "the kept disks pass runner.housekeeping.workspaceMax");
|
|
8189
|
+
if (gone.size > before) total -= entry.kept.record.bytes;
|
|
8190
|
+
}
|
|
8191
|
+
return freed;
|
|
8192
|
+
}
|
|
8193
|
+
async function freeItemDisksUntil(input) {
|
|
8194
|
+
let freed = 0;
|
|
8195
|
+
for (const entry of oldestFirst2(allEntries(input.configPath))) {
|
|
8196
|
+
if (input.enough()) break;
|
|
8197
|
+
try {
|
|
8198
|
+
await removeEntry(entry, input.removeVolume);
|
|
8199
|
+
freed += entry.kept.record.bytes;
|
|
8200
|
+
input.log(`removed the kept disk of work item ${entry.kept.record.workItemId} from ${entry.kept.record.keptAt}`);
|
|
8201
|
+
} catch (err) {
|
|
8202
|
+
input.log(`could not remove the kept disk of work item ${entry.kept.record.workItemId}: ${describeCallFailure(err)}`);
|
|
8203
|
+
}
|
|
8204
|
+
}
|
|
8205
|
+
return freed;
|
|
8206
|
+
}
|
|
7647
8207
|
|
|
7648
8208
|
// src/runner/housekeeping/select.ts
|
|
7649
|
-
var
|
|
8209
|
+
var DAY_MS2 = 864e5;
|
|
7650
8210
|
function spoolMaxAgeMs() {
|
|
7651
8211
|
return 24 * 36e5;
|
|
7652
8212
|
}
|
|
7653
8213
|
function selectJobDirs(entries, nowMs, keepDays) {
|
|
7654
8214
|
return entries.filter(
|
|
7655
|
-
(entry) => (entry.state === "finished" || entry.state === "no_job_file") && nowMs - entry.mtimeMs > keepDays *
|
|
8215
|
+
(entry) => (entry.state === "finished" || entry.state === "no_job_file") && nowMs - entry.mtimeMs > keepDays * DAY_MS2
|
|
7656
8216
|
);
|
|
7657
8217
|
}
|
|
7658
8218
|
function liveBuildIds(jobs) {
|
|
@@ -7888,6 +8448,14 @@ async function runHousekeeping(options) {
|
|
|
7888
8448
|
freed += await removeSavedStates(options, nowMs, savedStatesDir(root));
|
|
7889
8449
|
freed += removeStaleBuilderCaches(options, nowMs);
|
|
7890
8450
|
freed += removeStaleSessions(options, nowMs);
|
|
8451
|
+
freed += await removeItemDisks({
|
|
8452
|
+
configPath: options.configPath,
|
|
8453
|
+
limits: { max: options.workspaceMax ?? Number.POSITIVE_INFINITY, orgMax: options.workspaceOrgMax ?? Number.POSITIVE_INFINITY, keepDays: options.workspaceKeepDays ?? DEFAULT_WORKSPACE_KEEP_DAYS },
|
|
8454
|
+
nowMs,
|
|
8455
|
+
removeVolume: options.docker === void 0 ? void 0 : (name) => options.docker.removeVolume(name),
|
|
8456
|
+
log: (line2) => options.log.line(line2),
|
|
8457
|
+
error: (line2) => options.log.error(line2)
|
|
8458
|
+
});
|
|
7891
8459
|
for (const scope of storeScopes(options.configPath)) {
|
|
7892
8460
|
const spoolPath = spoolDir(orgStoreIn(root, scope));
|
|
7893
8461
|
const spoolFiles = listDir(spoolPath).flatMap((name) => {
|
|
@@ -8100,7 +8668,7 @@ var BRIDGE_ADDRESS = "172.17.0.1";
|
|
|
8100
8668
|
var STEP_PROXY = `http://${BRIDGE_ADDRESS}:${TUNNEL_PORT}`;
|
|
8101
8669
|
var NO_PROXY = "localhost,127.0.0.1,::1";
|
|
8102
8670
|
var TUNNEL_SOCKET = "tunnel.sock";
|
|
8103
|
-
var
|
|
8671
|
+
var RECORD_FILE2 = "image-builder.json";
|
|
8104
8672
|
var BOOT_ATTEMPTS2 = 120;
|
|
8105
8673
|
var BOOT_POLL_MS2 = 500;
|
|
8106
8674
|
var ROOT_PATH2 = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
|
|
@@ -8116,8 +8684,8 @@ var GUEST_OUTPUT = "/out/rootfs.ext4";
|
|
|
8116
8684
|
var LEFTOVERS_SCRIPT = "umount /work /out 2>/dev/null; rm -rf /cache/work /cache/rootfs /cache/out; status=$?; sync; exit $status";
|
|
8117
8685
|
var DOCKER_WAIT_SECONDS2 = 90;
|
|
8118
8686
|
var BUILD_CACHE_KEEP = "2GB";
|
|
8119
|
-
function unpackCommand(
|
|
8120
|
-
return ["sh", "-c", 'tar -x --no-same-owner -C "$1"; s=$?; cat >/dev/null; exit $s', "unpack",
|
|
8687
|
+
function unpackCommand(target2) {
|
|
8688
|
+
return ["sh", "-c", 'tar -x --no-same-owner -C "$1"; s=$?; cat >/dev/null; exit $s', "unpack", target2];
|
|
8121
8689
|
}
|
|
8122
8690
|
function engineLogExcerpt(log) {
|
|
8123
8691
|
return `grep -m1 'panic:' ${log} | sed 's/^/${ENGINE_PANIC_PREFIX}/' || true; tail -n 20 ${log}`;
|
|
@@ -8272,7 +8840,7 @@ function readStored(prepared) {
|
|
|
8272
8840
|
}
|
|
8273
8841
|
}
|
|
8274
8842
|
function writeBuilderRecord(dir, record) {
|
|
8275
|
-
writeFileSync(join(dir,
|
|
8843
|
+
writeFileSync(join(dir, RECORD_FILE2), `${JSON.stringify(record)}
|
|
8276
8844
|
`, { mode: 384 });
|
|
8277
8845
|
}
|
|
8278
8846
|
function refusalReason(refusals, logPath) {
|
|
@@ -8336,11 +8904,18 @@ async function buildInBuilder(opts, deps, prepared) {
|
|
|
8336
8904
|
let tunnel;
|
|
8337
8905
|
let sanitized;
|
|
8338
8906
|
let timedOut = false;
|
|
8907
|
+
let ended = false;
|
|
8339
8908
|
const controller = new AbortController();
|
|
8340
8909
|
const timer = opts.deadlineMs === void 0 ? void 0 : setTimeout(() => {
|
|
8341
8910
|
timedOut = true;
|
|
8342
8911
|
controller.abort();
|
|
8343
8912
|
}, Math.max(0, opts.deadlineMs - Date.now()));
|
|
8913
|
+
const onEnded = () => {
|
|
8914
|
+
ended = true;
|
|
8915
|
+
controller.abort();
|
|
8916
|
+
};
|
|
8917
|
+
if (opts.signal?.aborted === true) onEnded();
|
|
8918
|
+
else opts.signal?.addEventListener("abort", onEnded, { once: true });
|
|
8344
8919
|
const tail = [];
|
|
8345
8920
|
let result;
|
|
8346
8921
|
let enginePanic;
|
|
@@ -8384,7 +8959,7 @@ async function buildInBuilder(opts, deps, prepared) {
|
|
|
8384
8959
|
const exec = (argv) => ({ argv, user: "root", cwd: "/", env: { PATH: ROOT_PATH2 } });
|
|
8385
8960
|
const check = (status, what) => {
|
|
8386
8961
|
if (hostFailure !== void 0) throw new StepFailed(`${what} stopped: ${hostFailure}`);
|
|
8387
|
-
if (controller.signal.aborted) throw new StepFailed(`${what} was stopped at the time limit`);
|
|
8962
|
+
if (controller.signal.aborted) throw new StepFailed(ended ? `${what} was stopped because its build ended` : `${what} was stopped at the time limit`);
|
|
8388
8963
|
if (status !== 0) throw new StepFailed(`${what} failed (exit ${status})`);
|
|
8389
8964
|
};
|
|
8390
8965
|
const cacheSpace = async () => {
|
|
@@ -8476,16 +9051,16 @@ async function buildInBuilder(opts, deps, prepared) {
|
|
|
8476
9051
|
})
|
|
8477
9052
|
);
|
|
8478
9053
|
inputs = builderInput({ checkoutDir: checkout.dir, toolsDir, toolFilesDir, recipeDir }, archive);
|
|
8479
|
-
for (const { target, stream } of inputs) {
|
|
9054
|
+
for (const { target: target2, stream } of inputs) {
|
|
8480
9055
|
let status;
|
|
8481
9056
|
try {
|
|
8482
|
-
status = (await ports.exec(state.vsockPath, exec(unpackCommand(
|
|
9057
|
+
status = (await ports.exec(state.vsockPath, exec(unpackCommand(target2)), { stdin: stream, signal: controller.signal })).status;
|
|
8483
9058
|
} catch (err) {
|
|
8484
9059
|
if (hostFailure !== void 0 || controller.signal.aborted) throw err;
|
|
8485
|
-
throw new StepFailed(`unpacking ${
|
|
9060
|
+
throw new StepFailed(`unpacking ${target2} in the builder failed: ${err instanceof Error ? err.message : String(err)}${await spaceNote()}`);
|
|
8486
9061
|
}
|
|
8487
|
-
if (status !== 0 && hostFailure === void 0 && !controller.signal.aborted) throw new StepFailed(`unpacking ${
|
|
8488
|
-
check(status, `unpacking ${
|
|
9062
|
+
if (status !== 0 && hostFailure === void 0 && !controller.signal.aborted) throw new StepFailed(`unpacking ${target2} in the builder failed (exit ${status})${await spaceNote()}`);
|
|
9063
|
+
check(status, `unpacking ${target2} in the builder`);
|
|
8489
9064
|
}
|
|
8490
9065
|
const script = builderGuestScript({ recipe: recipeParts, recipeTag, buildTag });
|
|
8491
9066
|
const ran = await ports.execStream(state.vsockPath, exec(["/bin/sh", "-c", script]), { signal: controller.signal, onStdout: onOutput, onStderr: onOutput });
|
|
@@ -8545,6 +9120,7 @@ async function buildInBuilder(opts, deps, prepared) {
|
|
|
8545
9120
|
failure3 = await explain(err);
|
|
8546
9121
|
} finally {
|
|
8547
9122
|
if (timer !== void 0) clearTimeout(timer);
|
|
9123
|
+
opts.signal?.removeEventListener("abort", onEnded);
|
|
8548
9124
|
for (const { stream } of inputs) stream.destroy();
|
|
8549
9125
|
const stopped = await stopBuilder();
|
|
8550
9126
|
await tunnel?.close().catch(() => void 0);
|
|
@@ -8581,6 +9157,7 @@ async function buildInBuilder(opts, deps, prepared) {
|
|
|
8581
9157
|
async function explain(err) {
|
|
8582
9158
|
if (err instanceof RecipeError) return err;
|
|
8583
9159
|
if (hostFailure !== void 0) return new RecipeError("image_builder_failed", `the image build stopped: ${hostFailure}`, logPath);
|
|
9160
|
+
if (ended) return new RecipeError("image_builder_failed", `the build ended, so its image build was stopped. The build log is at ${logPath}`, logPath);
|
|
8584
9161
|
if (timedOut) {
|
|
8585
9162
|
const limit = opts.timeLimitMinutes === void 0 ? "runner.timeLimitMinutes" : `runner.timeLimitMinutes (${opts.timeLimitMinutes} minutes)`;
|
|
8586
9163
|
return new RecipeError("image_builder_failed", `the image build ran past ${limit} and the builder microVM was stopped. The build log is at ${logPath}`, logPath);
|
|
@@ -8640,7 +9217,7 @@ async function sweepImageBuilders(configPath, ports, onError) {
|
|
|
8640
9217
|
const dir = buildDir(configPath, id);
|
|
8641
9218
|
let record;
|
|
8642
9219
|
try {
|
|
8643
|
-
record = JSON.parse(readFileSync(join(dir,
|
|
9220
|
+
record = JSON.parse(readFileSync(join(dir, RECORD_FILE2), "utf8"));
|
|
8644
9221
|
} catch {
|
|
8645
9222
|
continue;
|
|
8646
9223
|
}
|
|
@@ -8680,127 +9257,6 @@ async function sweepImageBuilders(configPath, ports, onError) {
|
|
|
8680
9257
|
}
|
|
8681
9258
|
return swept;
|
|
8682
9259
|
}
|
|
8683
|
-
var SAVED_FOLDERS = ["home", "work"];
|
|
8684
|
-
function stopProcessesScript() {
|
|
8685
|
-
return [
|
|
8686
|
-
"me=$$; uid=$(id -u); n=0; pass=0",
|
|
8687
|
-
"while [ $pass -lt 25 ]; do",
|
|
8688
|
-
' left=""',
|
|
8689
|
-
" for p in /proc/[0-9]*; do",
|
|
8690
|
-
" pid=${p##*/}",
|
|
8691
|
-
' [ "$pid" = "$me" ] && continue',
|
|
8692
|
-
` info=$(sed -n -e 's/^State:[[:space:]]*\\(.\\).*/S=\\1/p' -e 's/^Uid:[[:space:]]*\\([0-9]*\\).*/U=\\1/p' "$p/status" 2>/dev/null) || continue`,
|
|
8693
|
-
' case "$info" in *"S=Z"*) continue ;; esac',
|
|
8694
|
-
// The uid is the last line of `info`, so a match at its end cannot be the longer id 10000 for 1000.
|
|
8695
|
-
' case "$info" in *"U=$uid") left="$left $pid" ;; esac',
|
|
8696
|
-
" done",
|
|
8697
|
-
' [ -z "$left" ] && break',
|
|
8698
|
-
' for pid in $left; do kill -KILL "$pid" 2>/dev/null && n=$((n+1)); done',
|
|
8699
|
-
" pass=$((pass+1))",
|
|
8700
|
-
" sleep 0.2",
|
|
8701
|
-
"done",
|
|
8702
|
-
'[ -z "$left" ] || { echo "$left are still running" >&2; exit 1; }',
|
|
8703
|
-
'echo "stopped $n"'
|
|
8704
|
-
].join("\n");
|
|
8705
|
-
}
|
|
8706
|
-
var HELPER_FLAGS = [
|
|
8707
|
-
"--rm",
|
|
8708
|
-
"--network",
|
|
8709
|
-
"none",
|
|
8710
|
-
"--cap-drop",
|
|
8711
|
-
"ALL",
|
|
8712
|
-
"--cap-add",
|
|
8713
|
-
"CHOWN",
|
|
8714
|
-
"--cap-add",
|
|
8715
|
-
"DAC_OVERRIDE",
|
|
8716
|
-
"--cap-add",
|
|
8717
|
-
"DAC_READ_SEARCH",
|
|
8718
|
-
"--cap-add",
|
|
8719
|
-
"FOWNER",
|
|
8720
|
-
"--security-opt",
|
|
8721
|
-
"no-new-privileges",
|
|
8722
|
-
"--read-only",
|
|
8723
|
-
"--user",
|
|
8724
|
-
"0",
|
|
8725
|
-
"--pids-limit",
|
|
8726
|
-
"256"
|
|
8727
|
-
];
|
|
8728
|
-
function helperArgs(input) {
|
|
8729
|
-
return [
|
|
8730
|
-
...HELPER_FLAGS,
|
|
8731
|
-
"--label",
|
|
8732
|
-
`${RUNNER_LABEL}=${input.runnerId}`,
|
|
8733
|
-
"--mount",
|
|
8734
|
-
`type=volume,src=${input.from},dst=/from,readonly`,
|
|
8735
|
-
"--mount",
|
|
8736
|
-
`type=volume,src=${input.to},dst=/to`,
|
|
8737
|
-
"--entrypoint",
|
|
8738
|
-
"sh",
|
|
8739
|
-
input.image,
|
|
8740
|
-
"-c",
|
|
8741
|
-
input.script
|
|
8742
|
-
];
|
|
8743
|
-
}
|
|
8744
|
-
var SAVE_SCRIPT = `set -e; cp -a ${SAVED_FOLDERS.map((name) => `/from/${name}`).join(" ")} /to/; du -sk /to | cut -f1`;
|
|
8745
|
-
var RESTORE_SCRIPT = `set -e; cp -a ${SAVED_FOLDERS.map((name) => `/from/${name}`).join(" ")} /to/`;
|
|
8746
|
-
function failureText3(result) {
|
|
8747
|
-
const line2 = result.stderr.trim().split("\n").at(-1) ?? "";
|
|
8748
|
-
return `exit ${result.status}${line2 === "" ? "" : `: ${line2}`}`;
|
|
8749
|
-
}
|
|
8750
|
-
async function saveContainerState(input) {
|
|
8751
|
-
const { host } = input;
|
|
8752
|
-
const id = randomBytes(6).toString("hex");
|
|
8753
|
-
const volume = `outerlayer-saved-${id}`;
|
|
8754
|
-
const record = {
|
|
8755
|
-
id,
|
|
8756
|
-
kind: "volume",
|
|
8757
|
-
volume,
|
|
8758
|
-
savedAt: input.now.toISOString(),
|
|
8759
|
-
bytes: 0,
|
|
8760
|
-
baseKey: input.key.baseKey,
|
|
8761
|
-
key: input.key.key,
|
|
8762
|
-
fileHashes: input.key.fileHashes,
|
|
8763
|
-
...input.agentUid === void 0 ? {} : { agentUid: input.agentUid },
|
|
8764
|
-
complete: false
|
|
8765
|
-
};
|
|
8766
|
-
const discard = async (reason) => {
|
|
8767
|
-
const removed = await host.removeVolume(volume).catch((err) => ({ status: -1, stderr: describeCallFailure(err) }));
|
|
8768
|
-
if (removed.status !== 0) {
|
|
8769
|
-
input.log(`the volume ${volume} could not be removed (${failureText3({ status: removed.status, stderr: removed.stderr })}); its record stays so a later pass retries`);
|
|
8770
|
-
return { ok: false, reason };
|
|
8771
|
-
}
|
|
8772
|
-
deleteRecord(input.dir, id);
|
|
8773
|
-
return { ok: false, reason };
|
|
8774
|
-
};
|
|
8775
|
-
try {
|
|
8776
|
-
const noEnv = { literals: {}, passed: {} };
|
|
8777
|
-
const stopped = await host.exec({ container: input.container, user: input.agentUser, env: noEnv, argv: ["sh", "-c", stopProcessesScript()] });
|
|
8778
|
-
if (stopped.status !== 0) return { ok: false, reason: `the build's processes could not be stopped (${failureText3(stopped)})` };
|
|
8779
|
-
input.log(`${stopped.stdout.trim() || "stopped 0"} process${stopped.stdout.trim() === "stopped 1" ? "" : "es"} before saving the state`);
|
|
8780
|
-
const flushed = await host.exec({ container: input.container, user: input.agentUser, env: noEnv, argv: ["sync"] });
|
|
8781
|
-
if (flushed.status !== 0) return { ok: false, reason: `the build's disk could not be flushed (${failureText3(flushed)})` };
|
|
8782
|
-
writeRecord2(input.dir, record);
|
|
8783
|
-
const created = await host.createVolume(volume, { [SAVED_STATE_LABEL]: id, [RUNNER_LABEL]: input.runnerId });
|
|
8784
|
-
if (created.status !== 0) return await discard(`the volume for the saved state could not be made (${failureText3(created)})`);
|
|
8785
|
-
const copied = await host.run(helperArgs({ image: input.image, from: input.buildVolume, to: volume, script: SAVE_SCRIPT, runnerId: input.runnerId }), { logPath: input.logPath });
|
|
8786
|
-
if (copied.status !== 0) return await discard(`the copy into the saved state failed (${failureText3(copied)})`);
|
|
8787
|
-
const kilobytes = Number(copied.stdout.trim().split("\n").at(-1));
|
|
8788
|
-
const done = { ...record, bytes: Number.isFinite(kilobytes) ? kilobytes * 1024 : 0, complete: true };
|
|
8789
|
-
writeRecord2(input.dir, done);
|
|
8790
|
-
return { ok: true, record: done };
|
|
8791
|
-
} catch (err) {
|
|
8792
|
-
return await discard(`the state could not be saved: ${describeCallFailure(err)}`);
|
|
8793
|
-
}
|
|
8794
|
-
}
|
|
8795
|
-
async function restoreContainerState(input) {
|
|
8796
|
-
try {
|
|
8797
|
-
const copied = await input.host.run(helperArgs({ image: input.image, from: input.savedVolume, to: input.targetVolume, script: RESTORE_SCRIPT, runnerId: input.runnerId }), { logPath: input.logPath });
|
|
8798
|
-
if (copied.status !== 0) return { ok: false, reason: `the saved volume could not be copied (${failureText3(copied)})` };
|
|
8799
|
-
return { ok: true };
|
|
8800
|
-
} catch (err) {
|
|
8801
|
-
return { ok: false, reason: `the saved volume could not be copied: ${describeCallFailure(err)}` };
|
|
8802
|
-
}
|
|
8803
|
-
}
|
|
8804
9260
|
var noop = () => void 0;
|
|
8805
9261
|
var FRAME_HEADER_BYTES = 9;
|
|
8806
9262
|
var GOAWAY_FRAME = 7;
|
|
@@ -8913,8 +9369,8 @@ function serveSession(transport, services, opts = {}) {
|
|
|
8913
9369
|
});
|
|
8914
9370
|
session.on("stream", (stream, headers) => {
|
|
8915
9371
|
stream.on("error", noop);
|
|
8916
|
-
const
|
|
8917
|
-
if (
|
|
9372
|
+
const target2 = headers[":method"] === "POST" ? targetOfPath(headers[":path"], opts.builtIns) : void 0;
|
|
9373
|
+
if (target2 === void 0 || open >= maxStreams) {
|
|
8918
9374
|
stream.close(http2.constants.NGHTTP2_REFUSED_STREAM);
|
|
8919
9375
|
return;
|
|
8920
9376
|
}
|
|
@@ -8923,7 +9379,7 @@ function serveSession(transport, services, opts = {}) {
|
|
|
8923
9379
|
open--;
|
|
8924
9380
|
});
|
|
8925
9381
|
writeStringsAsBuffers(stream);
|
|
8926
|
-
if (!services.accept(
|
|
9382
|
+
if (!services.accept(target2, stream)) {
|
|
8927
9383
|
stream.close(http2.constants.NGHTTP2_REFUSED_STREAM);
|
|
8928
9384
|
return;
|
|
8929
9385
|
}
|
|
@@ -9373,7 +9829,7 @@ async function drain(req) {
|
|
|
9373
9829
|
function readPrefix(req, gzip) {
|
|
9374
9830
|
return new Promise((resolve2, reject) => {
|
|
9375
9831
|
const held3 = [];
|
|
9376
|
-
const
|
|
9832
|
+
const finish2 = (section2) => {
|
|
9377
9833
|
req.off("data", onData);
|
|
9378
9834
|
req.off("end", onEnd);
|
|
9379
9835
|
req.off("error", reject);
|
|
@@ -9383,9 +9839,9 @@ function readPrefix(req, gzip) {
|
|
|
9383
9839
|
const onData = (chunk) => {
|
|
9384
9840
|
held3.push(chunk);
|
|
9385
9841
|
const section2 = readCommandSection(Buffer.concat(held3), gzip);
|
|
9386
|
-
if (section2.kind !== "need-more")
|
|
9842
|
+
if (section2.kind !== "need-more") finish2(section2);
|
|
9387
9843
|
};
|
|
9388
|
-
const onEnd = () =>
|
|
9844
|
+
const onEnd = () => finish2({ kind: "need-more" });
|
|
9389
9845
|
req.on("data", onData);
|
|
9390
9846
|
req.once("end", onEnd);
|
|
9391
9847
|
req.once("error", reject);
|
|
@@ -9467,7 +9923,7 @@ function createGitRemote(options) {
|
|
|
9467
9923
|
return void 0;
|
|
9468
9924
|
}
|
|
9469
9925
|
}
|
|
9470
|
-
async function push(req, res, route,
|
|
9926
|
+
async function push(req, res, route, target2) {
|
|
9471
9927
|
const encoding = req.headers["content-encoding"];
|
|
9472
9928
|
const gzip = encoding === "gzip";
|
|
9473
9929
|
const { held: held3, section: section2 } = await readPrefix(req, gzip);
|
|
@@ -9492,8 +9948,8 @@ function createGitRemote(options) {
|
|
|
9492
9948
|
let bodyPath;
|
|
9493
9949
|
try {
|
|
9494
9950
|
let fastForward;
|
|
9495
|
-
if (needsFastForwardCheck(commands,
|
|
9496
|
-
const read = await tokenOrRefuse(res, "read",
|
|
9951
|
+
if (needsFastForwardCheck(commands, target2.branch)) {
|
|
9952
|
+
const read = await tokenOrRefuse(res, "read", target2.repository);
|
|
9497
9953
|
if (read === void 0) return void await drain(req);
|
|
9498
9954
|
mkdirSync(options.spoolDir, { recursive: true, mode: 448 });
|
|
9499
9955
|
bodyPath = join(options.spoolDir, randomBytes(8).toString("hex"));
|
|
@@ -9514,21 +9970,21 @@ function createGitRemote(options) {
|
|
|
9514
9970
|
if (size > cap) return void await refuseInBand(`the push is larger than the ${cap} bytes the runner holds to check it`);
|
|
9515
9971
|
try {
|
|
9516
9972
|
fastForward = await isFastForward({
|
|
9517
|
-
mirrorDir:
|
|
9973
|
+
mirrorDir: target2.mirrorDir,
|
|
9518
9974
|
remoteUrl: `${gitUrl}/${route.owner}/${route.name}.git`,
|
|
9519
9975
|
token: read,
|
|
9520
|
-
branch:
|
|
9976
|
+
branch: target2.branch,
|
|
9521
9977
|
bodyPath,
|
|
9522
9978
|
gzip
|
|
9523
9979
|
});
|
|
9524
9980
|
} catch (err) {
|
|
9525
9981
|
log(`fast-forward check could not run: ${err instanceof Error ? err.message : String(err)}`);
|
|
9526
|
-
return void await refuseInBand(`the runner could not check whether this push fast-forwards ${
|
|
9982
|
+
return void await refuseInBand(`the runner could not check whether this push fast-forwards ${target2.branch}`);
|
|
9527
9983
|
}
|
|
9528
9984
|
}
|
|
9529
|
-
const verdict = judgePush({ commands, branch:
|
|
9985
|
+
const verdict = judgePush({ commands, branch: target2.branch, fastForward });
|
|
9530
9986
|
if (!verdict.allowed) return void await refuseInBand(verdict.message);
|
|
9531
|
-
const token = await tokenOrRefuse(res, "push",
|
|
9987
|
+
const token = await tokenOrRefuse(res, "push", target2.repository);
|
|
9532
9988
|
if (token === void 0) return void await drain(req);
|
|
9533
9989
|
options.tokens.markUsed("push");
|
|
9534
9990
|
const headers = upstreamHeaders(req.headers, basicAuthorization(token));
|
|
@@ -9565,15 +10021,15 @@ function createGitRemote(options) {
|
|
|
9565
10021
|
req.resume();
|
|
9566
10022
|
return plain2(res, 403, "this remote is read-only: a check cannot push\n");
|
|
9567
10023
|
}
|
|
9568
|
-
const
|
|
10024
|
+
const target2 = claimed.find((entry) => isOwnRepository(entry.repository, route.owner, route.name));
|
|
9569
10025
|
const pushing = route.kind === "receive-pack" || route.kind === "info-refs" && route.service === "git-receive-pack";
|
|
9570
|
-
if (
|
|
10026
|
+
if (target2 === void 0 && pushing) {
|
|
9571
10027
|
log(`push refused: ${route.owner}/${route.name} is not a repository of this build's claim`);
|
|
9572
10028
|
req.resume();
|
|
9573
10029
|
return plain2(res, 403, `the runner refused this push: ${route.owner}/${route.name} is not a repository of this build's claim
|
|
9574
10030
|
`);
|
|
9575
10031
|
}
|
|
9576
|
-
if (
|
|
10032
|
+
if (target2 !== void 0 && route.kind === "receive-pack") return push(req, res, route, target2);
|
|
9577
10033
|
let kind = route.kind === "info-refs" && route.service === "git-receive-pack" ? "push" : "read";
|
|
9578
10034
|
let body;
|
|
9579
10035
|
if (route.kind === "lfs-batch") {
|
|
@@ -9583,8 +10039,8 @@ function createGitRemote(options) {
|
|
|
9583
10039
|
if (options.readOnly === true && kind === "push") return plain2(res, 403, "this remote is read-only: a check cannot upload\n");
|
|
9584
10040
|
}
|
|
9585
10041
|
let authorization;
|
|
9586
|
-
if (
|
|
9587
|
-
const token = await tokenOrRefuse(res, kind,
|
|
10042
|
+
if (target2 !== void 0) {
|
|
10043
|
+
const token = await tokenOrRefuse(res, kind, target2.repository);
|
|
9588
10044
|
if (token === void 0) return void await drain(req);
|
|
9589
10045
|
authorization = basicAuthorization(token);
|
|
9590
10046
|
if (kind === "read" || route.kind === "lfs-batch") options.tokens.markUsed(kind);
|
|
@@ -9909,6 +10365,7 @@ async function waitForRelay(runtime, state) {
|
|
|
9909
10365
|
}
|
|
9910
10366
|
return false;
|
|
9911
10367
|
}
|
|
10368
|
+
var ABORT_POLL_MS = 1e3;
|
|
9912
10369
|
async function obtainImage(input) {
|
|
9913
10370
|
const { config, runtime, tokens, repository, tag, log } = input;
|
|
9914
10371
|
for (; ; ) {
|
|
@@ -9926,10 +10383,19 @@ async function obtainImage(input) {
|
|
|
9926
10383
|
try {
|
|
9927
10384
|
const common = { repository, configPath: config.configPath, ...input.organizationId === void 0 ? {} : { organizationId: input.organizationId }, readToken, pinned: input.pinned, log: (line2) => log.line(`${tag} ${line2}`) };
|
|
9928
10385
|
if (input.inBuilder !== void 0) {
|
|
9929
|
-
|
|
10386
|
+
const ended = new AbortController();
|
|
10387
|
+
const watch = setInterval(() => {
|
|
10388
|
+
if (input.aborted()) ended.abort();
|
|
10389
|
+
}, ABORT_POLL_MS);
|
|
10390
|
+
try {
|
|
10391
|
+
return { ok: true, built: await runtime.buildRootDisk({ ...input.inBuilder, ...common, guestHelper: input.guestHelper, deadlineMs: input.deadlineMs, signal: ended.signal }) };
|
|
10392
|
+
} finally {
|
|
10393
|
+
clearInterval(watch);
|
|
10394
|
+
}
|
|
9930
10395
|
}
|
|
9931
10396
|
return { ok: true, built: await runtime.buildImage({ ...common, buildMemory: config.build?.memory ?? "8g", guestHelper: input.guestHelper }) };
|
|
9932
10397
|
} catch (err) {
|
|
10398
|
+
if (input.aborted()) return { ok: false, reason: "ended before provision finished", aborted: true };
|
|
9933
10399
|
if (err instanceof RecipeError && err.code === "build_in_progress" && (input.now?.() ?? /* @__PURE__ */ new Date()).getTime() < input.deadlineMs) {
|
|
9934
10400
|
log.line(`${tag} waiting for another build of ${repository}'s image`);
|
|
9935
10401
|
await runtime.sleep(BUSY_IMAGE_WAIT_MS);
|
|
@@ -9957,11 +10423,11 @@ async function controlPlaneReadToken(tokens, controlPlane) {
|
|
|
9957
10423
|
}
|
|
9958
10424
|
async function provisionContainer(input) {
|
|
9959
10425
|
return provisionWithFreshFallback({
|
|
9960
|
-
attempt: (allowRestore) => provisionContainerOnce(input, allowRestore),
|
|
10426
|
+
attempt: (allowRestore, itemDiskFailed) => provisionContainerOnce(input, allowRestore, itemDiskFailed),
|
|
9961
10427
|
log: (line2) => input.log.line(`#${input.item.number} ${line2}`)
|
|
9962
10428
|
});
|
|
9963
10429
|
}
|
|
9964
|
-
async function provisionContainerOnce(input, allowRestore) {
|
|
10430
|
+
async function provisionContainerOnce(input, allowRestore, itemDiskFailed) {
|
|
9965
10431
|
const { config, runtime, item, itemKey, jobDir, log, tokens } = input;
|
|
9966
10432
|
const { host } = runtime;
|
|
9967
10433
|
const tag = itemTag({ item: item.number, organizationId: input.organizationId, claimId: input.claimId });
|
|
@@ -10021,7 +10487,11 @@ async function provisionContainerOnce(input, allowRestore) {
|
|
|
10021
10487
|
const built = obtained.built;
|
|
10022
10488
|
const { report } = built;
|
|
10023
10489
|
const tagged = taggedLog(log, tag);
|
|
10024
|
-
const
|
|
10490
|
+
const diskBytes = parseSize(config.build?.disk ?? DEFAULT_BUILD_DISK) ?? 0;
|
|
10491
|
+
const itemDisk = input.workItemId === void 0 ? { state: void 0 } : itemDiskFailed !== void 0 ? { state: { restored: false, reason: itemDiskFailed } } : itemDiskDecision({ queue: input.queue ?? "implement", builtin: true, backend: "volume", configPath: config.configPath, organizationId: input.organizationId, workItemId: input.workItemId, imageId: report.imageId, diskBytes });
|
|
10492
|
+
const keptDisk = itemDisk.kept;
|
|
10493
|
+
if (itemDisk.state?.restored === false) tagged(`this agent job starts without a kept disk: ${DISK_REASON_TEXT[itemDisk.state.reason]}`);
|
|
10494
|
+
const plan = keptDisk !== void 0 ? keptDiskPlan() : await planSavedState({
|
|
10025
10495
|
config,
|
|
10026
10496
|
repositories,
|
|
10027
10497
|
base: savedStateBase(report),
|
|
@@ -10029,7 +10499,7 @@ async function provisionContainerOnce(input, allowRestore) {
|
|
|
10029
10499
|
tokens,
|
|
10030
10500
|
now: clockOf(input.now)(),
|
|
10031
10501
|
allowRestore,
|
|
10032
|
-
diskBytes
|
|
10502
|
+
diskBytes,
|
|
10033
10503
|
log: tagged
|
|
10034
10504
|
});
|
|
10035
10505
|
const savedStatesPath = savedStatesDir(runnerDir(config.configPath));
|
|
@@ -10100,6 +10570,10 @@ async function provisionContainerOnce(input, allowRestore) {
|
|
|
10100
10570
|
onError: (line2) => log.error(`${tag} ${line2}`)
|
|
10101
10571
|
});
|
|
10102
10572
|
};
|
|
10573
|
+
const giveUpItemDisk = async (reason, why) => {
|
|
10574
|
+
await bail(reason);
|
|
10575
|
+
return discardUnusableItemDisk({ kept: keptDisk, reason, why, removeVolume: (volume2) => host.removeVolume(volume2), onError: (line2) => log.error(`${tag} ${line2}`) });
|
|
10576
|
+
};
|
|
10103
10577
|
if (input.aborted()) return bail("", true);
|
|
10104
10578
|
mkdirSync(buildDir2, { recursive: true });
|
|
10105
10579
|
const ghDir = ghConfigDir(buildDir2);
|
|
@@ -10151,7 +10625,12 @@ async function provisionContainerOnce(input, allowRestore) {
|
|
|
10151
10625
|
};
|
|
10152
10626
|
const prepared = await host.run(prepareRunArgs(runInput), { logPath });
|
|
10153
10627
|
if (prepared.status !== 0) return dockerFailed("preparing the build's volume", prepared);
|
|
10154
|
-
if (
|
|
10628
|
+
if (keptDisk !== void 0) {
|
|
10629
|
+
const restoreStartedAt = Date.now();
|
|
10630
|
+
const restored = await restoreContainerState({ host, image: report.imageId, savedVolume: keptDisk.record.volume, targetVolume: name, runnerId, logPath });
|
|
10631
|
+
if (!restored.ok) return giveUpItemDisk(restored.reason, "disk_not_restored");
|
|
10632
|
+
tagged(`restored the disk that claim ${shortClaim(keptDisk.record.claimId)} kept: ${formatBytes(keptDisk.record.bytes)} allocated, copied in ${formatDuration(Date.now() - restoreStartedAt)}`);
|
|
10633
|
+
} else if (plan.restore !== void 0) {
|
|
10155
10634
|
const restored = await restoreContainerState({ host, image: report.imageId, savedVolume: plan.restore.record.volume, targetVolume: name, runnerId, logPath });
|
|
10156
10635
|
if (!restored.ok) return giveUpState(restored.reason);
|
|
10157
10636
|
}
|
|
@@ -10247,14 +10726,14 @@ async function provisionContainerOnce(input, allowRestore) {
|
|
|
10247
10726
|
...input.requireBuildSkill === true ? { requireBuildSkill: true } : {},
|
|
10248
10727
|
// A build on the universal image, or on an image built from it, chooses and installs its runtimes.
|
|
10249
10728
|
...runtimeStepInput(report, services),
|
|
10250
|
-
setup: setupInputFor({ setupMinutes: config.build?.setupMinutes, plan, saveState })
|
|
10729
|
+
setup: setupInputFor({ setupMinutes: config.build?.setupMinutes, plan, saveState, fromItemDisk: keptDisk !== void 0 })
|
|
10251
10730
|
});
|
|
10252
|
-
if (!steps.ok) return settleFailedSteps(steps, { giveUp: giveUpState, bail });
|
|
10731
|
+
if (!steps.ok) return settleFailedSteps(steps, { giveUp: (reason, fromItemDisk) => fromItemDisk ? giveUpItemDisk(reason, "checkout_not_switched") : giveUpState(reason), bail });
|
|
10253
10732
|
state.startCommit = steps.startCommit;
|
|
10254
10733
|
keepRuntimeStep(state, steps);
|
|
10255
10734
|
keepMissingSetupScripts(state, steps);
|
|
10256
10735
|
if (steps.controlPlane !== void 0) environment.controlPlane = steps.controlPlane;
|
|
10257
|
-
return { ok: true, workdir: CHECKOUT_DIR, state, environment };
|
|
10736
|
+
return { ok: true, workdir: CHECKOUT_DIR, state, environment, ...itemDisk.state === void 0 ? {} : { disk: itemDisk.state } };
|
|
10258
10737
|
}
|
|
10259
10738
|
function endedAtLimit(result) {
|
|
10260
10739
|
return result.status === 124 && /no answer within \d+s/.test(result.stderr);
|
|
@@ -10559,7 +11038,7 @@ async function copyHookErrors2(runtime, state, jobDir) {
|
|
|
10559
11038
|
} catch {
|
|
10560
11039
|
}
|
|
10561
11040
|
}
|
|
10562
|
-
async function cleanupContainer(runtime, state, jobDir) {
|
|
11041
|
+
async function cleanupContainer(runtime, state, jobDir, keepDisk, warn) {
|
|
10563
11042
|
const failures = [];
|
|
10564
11043
|
if (jobDir !== void 0) await copyHookErrors2(runtime, state, jobDir);
|
|
10565
11044
|
await leaveBuild(runtime, state);
|
|
@@ -10572,6 +11051,13 @@ async function cleanupContainer(runtime, state, jobDir) {
|
|
|
10572
11051
|
}
|
|
10573
11052
|
const helperLeft = await removeNetworkHelper(runtime, state);
|
|
10574
11053
|
if (helperLeft !== void 0) failures.push(helperLeft);
|
|
11054
|
+
if (keepDisk !== void 0 && removedContainer.status === 0) {
|
|
11055
|
+
try {
|
|
11056
|
+
await keepDisk();
|
|
11057
|
+
} catch (err) {
|
|
11058
|
+
warn?.(`the build's disk was not kept: ${describeCallFailure(err)}`);
|
|
11059
|
+
}
|
|
11060
|
+
}
|
|
10575
11061
|
let volumeGone = false;
|
|
10576
11062
|
for (let attempt = 0; attempt < VOLUME_REMOVE_ATTEMPTS && !volumeGone; attempt++) {
|
|
10577
11063
|
const removed = await runtime.host.removeVolume(state.volume);
|
|
@@ -11282,4 +11768,4 @@ async function runHostChecks(input) {
|
|
|
11282
11768
|
}
|
|
11283
11769
|
}
|
|
11284
11770
|
|
|
11285
|
-
export { ADOPTED_FETCH_RETRY_WINDOW_MS, ALREADY_RELEASED, AttemptLogBook, EXIT_CODE_FILE, GUEST_USAGE_INTERVAL_MS, HELPER_ENV, KIND_LABEL, LEASE_SECONDS, MAX_CHECK_ITEMS_BYTES, MICROVM_COMMAND_DIR, MIN_ENGINE_MAJOR, PLACEHOLDER_MARKER, RENEW_INTERVAL_SECONDS, RunnerInitError, agentCredentialCheck, appendCommandLog, attemptNote, checksIn, claimPermissionProblem, commandItems, commandLogOffset, containerCommandExec, createContainerRuntime, createHousekeepingDocker, createLeaseChannel, currentSkillCommand, decideHostBuildSkill, deliverCommitHooks, deliverContainerHooks, deliverExecMaven, deliverJobFiles, describeHookEnd, describeMachineDocker, detectMachine, ensureFirecrackerAndJailer, ensureNetworkReady, ensureTunnel, execArgv, execCommandLine, fetchManagedBuildSettings, fetchManagedClaudeKey, filesAreCopied, finishJob, firstLine3 as firstLine, foldSample, formerSkillProblem, formerSkillQueues, gitRemoteFor, helperFirecrackerNote, helperSocketPath, holdManagedBuildSettings, holdManagedClaudeKey, hookLimitsFor, hostCommandEnvironment, hostEnvironment, housekeepingDockerIfReachable, inTeardown, isContainerTracked, isGroupAlive, isIdle, isJudgeCheck, isMicroVmTracked, isPlaceholderCommand, isReadable, isTimedOut, isTracked, isUnfinished, itemScope, itemTag, jobEnv, judgeProbe, keepGhConfigCurrent, leaseExpiresAtMs, leaseTimeLeftMs, lifecycleFailureReason, lifecycleSteps, listAdoptableJobs, listTrackedJobs, listUnreadableJobs, listenOnBroker, makeRecorder, managedBuildSettingsFor, measureDisk, microVmArchSupported, microVmAssetsPinned, microVmCommandLine, microVmOomKills, missingPermissionFix, missingPermissionOf, needsAgentCredential, needsBuildSkill, needsRenew, outcomeFromExitCode, parseCpuList, permissionModeProblem, permissionModeProblems, placeholderProblem, placeholderQueues, prepareBranch, prepareResume, prepareRunnerInit, probeCommand, probeHelper, probeMicroVmCommand, provisionContainer, provisionEnvironment, provisionMicroVm, provisionProcess, reachDockerStep, readConfigObject, readCpuUsec, readDefinitions, readProvisionOut, readRecords, recoverLostJobs, releaseLease, removeOldestUntil, renewLease, resolveHostBuild, restartSender, restoreSessionIntoContainer, restoreSessionIntoMicroVm, retryFailedReleases, runCommand, runHook, runHostChecks, runHousekeeping, runRunnerInit, runWithSpawn, sampleGuest, savedStatesDir, scrubReason, serveLease, setStage, setUpRunnerCgroup, shellQuote, startHostServices, startMicroVmCommand, startSender, startServicesFor, stopOrphanedMicroVms, stoppedHelperReason, stripTerminalControls, supportsContainerBuilds, supportsMicroVmBuilds, sweepImageBuilders, testProofIn, timeoutAfter, unfinishedJobs, usableCpus, vmAlive, withTunnelLog, workdirProblem, writeGuestGhConfig, writeRunnerInit };
|
|
11771
|
+
export { ADOPTED_FETCH_RETRY_WINDOW_MS, ALREADY_RELEASED, AttemptLogBook, EXIT_CODE_FILE, GUEST_USAGE_INTERVAL_MS, HELPER_ENV, KIND_LABEL, LEASE_SECONDS, MAX_CHECK_ITEMS_BYTES, MICROVM_COMMAND_DIR, MIN_ENGINE_MAJOR, PLACEHOLDER_MARKER, RENEW_INTERVAL_SECONDS, RunnerInitError, agentCredentialCheck, appendCommandLog, attemptNote, checksIn, claimPermissionProblem, commandItems, commandLogOffset, containerCommandExec, createContainerRuntime, createHousekeepingDocker, createLeaseChannel, currentSkillCommand, decideHostBuildSkill, deliverCommitHooks, deliverContainerHooks, deliverExecMaven, deliverJobFiles, describeHookEnd, describeMachineDocker, detectMachine, ensureFirecrackerAndJailer, ensureNetworkReady, ensureTunnel, execArgv, execCommandLine, fetchManagedBuildSettings, fetchManagedClaudeKey, filesAreCopied, finishJob, firstLine3 as firstLine, foldSample, formerSkillProblem, formerSkillQueues, freeItemDisksUntil, gitRemoteFor, helperFirecrackerNote, helperSocketPath, holdManagedBuildSettings, holdManagedClaudeKey, hookLimitsFor, hostCommandEnvironment, hostEnvironment, housekeepingDockerIfReachable, inTeardown, isContainerTracked, isGroupAlive, isIdle, isJudgeCheck, isMicroVmTracked, isPlaceholderCommand, isReadable, isTimedOut, isTracked, isUnfinished, itemScope, itemTag, jobEnv, judgeProbe, keepGhConfigCurrent, leaseExpiresAtMs, leaseTimeLeftMs, lifecycleFailureReason, lifecycleSteps, listAdoptableJobs, listTrackedJobs, listUnreadableJobs, listenOnBroker, makeRecorder, managedBuildSettingsFor, measureDisk, microVmArchSupported, microVmAssetsPinned, microVmCommandLine, microVmOomKills, missingPermissionFix, missingPermissionOf, needsAgentCredential, needsBuildSkill, needsRenew, outcomeFromExitCode, parseCpuList, permissionModeProblem, permissionModeProblems, placeholderProblem, placeholderQueues, prepareBranch, prepareResume, prepareRunnerInit, probeCommand, probeHelper, probeMicroVmCommand, provisionContainer, provisionEnvironment, provisionMicroVm, provisionProcess, reachDockerStep, readConfigObject, readCpuUsec, readDefinitions, readProvisionOut, readRecords, recoverLostJobs, releaseLease, removeOldestUntil, renewLease, resolveHostBuild, restartSender, restoreSessionIntoContainer, restoreSessionIntoMicroVm, retryFailedReleases, runCommand, runHook, runHostChecks, runHousekeeping, runRunnerInit, runWithSpawn, sampleGuest, savedStatesDir, scrubReason, serveLease, setStage, setUpRunnerCgroup, shellQuote, startHostServices, startMicroVmCommand, startSender, startServicesFor, stopOrphanedMicroVms, stoppedHelperReason, stripTerminalControls, supportsContainerBuilds, supportsMicroVmBuilds, sweepImageBuilders, testProofIn, timeoutAfter, unfinishedJobs, usableCpus, vmAlive, withTunnelLog, workdirProblem, writeGuestGhConfig, writeRunnerInit };
|