feat(server): add safe service runtime pruning #7811
Closedpaulcatamio(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/7811/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/cloud/bootService.ts lines 444 to 455Resolvedby paulcatamio(GitHub profile, opens in a new tab)@@ -403,3 +405,20 @@403405 }404406 }405407408+export class BootServicePruneStateError extends Schema.TaggedErrorClass<BootServicePruneStateError>()(409+ "BootServicePruneStateError",410+ {},411+) {412+ override get message(): string {413+ return "The T3 Code service state is missing or invalid. Run `npx t3@latest service update` before pruning runtimes.";414+ }415+}416+417+export class BootServicePruneError extends Schema.TaggedErrorClass<BootServicePruneError>()(418+ "BootServicePruneError",419+ { cause: Schema.Defect() },420+) {421+ override get message(): string {422+ return "Could not prune T3 Code service runtimes.";423+ }424+}
- @@ -222,0 +265,21 @@265+ const realVersionDir = yield* input.fs.realPath(paths.versionDir).pipe(Effect.option);266+ if (267+ Option.isNone(realVersionDir) ||268+ realVersionDir.value !== input.path.join(realVersionsDir, version)269+ ) {270+ return false;271+ }272+273+ const [entryExists, sentinel] = yield* Effect.all([274+ input.fs.exists(paths.entryPath),275+ input.fs.readFileString(paths.sentinelPath).pipe(Effect.option),276+ ]);277+ return entryExists && Option.isSome(sentinel) && sentinel.value.trim() === version;278+ }),279+ );280+ versions.sort((left, right) => {281+ const precedence = compareExactServiceVersions(left, right);282+ return precedence === 0 ? left.localeCompare(right) : precedence;283+ });284+285+ if (!input.dryRun) {
- @@ -766,0 +829,21 @@829+ return yield* new BootServicePruneStateError({ statePath });830+ }831+ if (state.update?.status === "pending") {832+ return yield* new BootServiceUpdatePendingError();833+ }834+ return yield* prunePinnedRuntimes({835+ baseDir: input.baseDir,836+ state,837+ dryRun: options.dryRun,838+ fs,839+ path,840+ }).pipe(841+ Effect.mapError(842+ (cause) =>843+ new BootServicePruneError({844+ stage: "pruning runtimes",845+ path: path.dirname(runtimePaths.versionDir),846+ cause,847+ }),848+ ),849+ );
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
61ef50f7-6295-44a2-84b8-717b47b1de7bYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share