Skip to content

move the reservation up to when updating envd#2180

Closed
matthewlouisbrockman wants to merge 1 commit intomainfrom
move-reserved-disk-to-envd-update
Closed

move the reservation up to when updating envd#2180
matthewlouisbrockman wants to merge 1 commit intomainfrom
move-reserved-disk-to-envd-update

Conversation

@matthewlouisbrockman
Copy link
Copy Markdown
Contributor

@matthewlouisbrockman matthewlouisbrockman commented Mar 19, 2026

Moves guest-side reserved disk setup earlier for cached template builds. No change to fresh builds.

relates to: #2082 (comment)


Note

Medium Risk
Moves reserved disk space setup to run immediately after envd updates on resumed/cached builds, affecting guest filesystem behavior before subsequent actions. Risk is moderate because it changes build-time disk reservation timing and relies on feature-flag configuration during layer execution.

Overview
Moves guest-side reserved disk block configuration from the final post-processing step to immediately after envd is updated when resuming from a cached template, ensuring older cached templates get the reservation applied before later build actions run.

Written by Cursor Bugbot for commit 21b22ec. This will update automatically on new commits. Configure here.

@@ -219,16 +219,6 @@ func (ppb *PostProcessingBuilder) postProcessingFn(userLogger logger.Logger) lay
return
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regression: fresh builds no longer get guest-side disk reservation.

The old code called SetReservedBlocksInGuest unconditionally (modulo the feature flag) in postProcessingFn, covering both cached and fresh builds. The new code moves this call into layer_executor.go inside if cmd.UpdateEnvd, but in finalize/builder.go line 196 UpdateEnvd is set to sourceLayer.Cached. For a fresh build, sourceLayer.Cached == false so UpdateEnvd == false and SetReservedBlocksInGuest is never called. The guest filesystem ends up without the tune2fs -r reserved-blocks setting on non-cached builds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure this is accurate but moved this back to draft to check

// Apply guest-side reserved blocks on the resumed-template path so older
// cached templates get the reservation before subsequent build actions run.
if reservedDiskSpaceMB := int64(lb.featureFlags.IntFlag(ctx, featureflags.BuildReservedDiskSpaceMB)); reservedDiskSpaceMB > 0 {
err = sandboxtools.SetReservedBlocksInGuest(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant calls on multi-step cached builds.

steps/builder.go also sets UpdateEnvd: sourceLayer.Cached, so for a build with N cached steps, SetReservedBlocksInGuest (a round-trip tune2fs command inside the guest) is called N times - once per cached step layer - and again when the finalize layer is cached. Since tune2fs -r is idempotent the result is correct, but every extra call is unnecessary VM overhead. Consider tracking whether the reservation has already been applied (e.g. via a flag on LayerExecutor) and skipping subsequent calls.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 21b22ec8a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +120 to +122
// Apply guest-side reserved blocks on the resumed-template path so older
// cached templates get the reservation before subsequent build actions run.
if reservedDiskSpaceMB := int64(lb.featureFlags.IntFlag(ctx, featureflags.BuildReservedDiskSpaceMB)); reservedDiskSpaceMB > 0 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't make reserved-block repair depend on UpdateEnvd

This turns the guest-side reservation into a one-time side effect of UpdateEnvd, but UpdateEnvd is only set from sourceLayer.Cached in the step/finalize builders. After the first uncached layer, later phases no longer reapply the setting, and postProcessingFn now goes straight from configuration/start commands to SyncChangesToDisk (packages/orchestrator/internal/template/build/phases/finalize/builder.go:217-233). In a build that runs any later root command which touches the ext4 superblock (for example tune2fs -r 0 /dev/vda in a RUN or start command), the exported template will keep the wrong reserved-space value; before this change, finalize restored the configured reservation immediately before snapshotting.

Useful? React with 👍 / 👎.

@matthewlouisbrockman matthewlouisbrockman marked this pull request as draft March 19, 2026 22:38
@ValentaTomas ValentaTomas removed their assignment Mar 21, 2026
@ValentaTomas ValentaTomas removed their request for review March 21, 2026 06:39
@arkamar
Copy link
Copy Markdown
Contributor

arkamar commented Mar 23, 2026

This PR is obsoleted by #2199.

@arkamar arkamar closed this Mar 23, 2026
@ValentaTomas ValentaTomas deleted the move-reserved-disk-to-envd-update branch April 9, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants