Skip to content

fix(blaze): bind instance storage root - #2471

Open
WeissonHan wants to merge 2 commits into
alibaba:mainfrom
WeissonHan:fix/blaze/storage-root-ownership-draft-v1
Open

fix(blaze): bind instance storage root#2471
WeissonHan wants to merge 2 commits into
alibaba:mainfrom
WeissonHan:fix/blaze/storage-root-ownership-draft-v1

Conversation

@WeissonHan

@WeissonHan WeissonHan commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Why

The file storage provider must keep mutable sandbox storage bound to the
directory Blaze validated and opened at startup. Re-resolving
storage.instances_dir, creating a missing directory under its final name
before retaining it, or releasing the sandbox operation lock while blocking
storage acquisition was still running could redirect work or make cleanup act
on a replacement directory.

What changed

  • Plan and validate storage.instances_dir before creating daemon-owned
    paths. Reject unsupported path components, overlap with daemon state, and
    symbolic-link or bind-mount aliases with storage.images_dir.
  • Retain the deepest existing path component and verify every existing path
    component against its opened descriptor.
  • Require publication parents and the final instances root to be owned by root
    or the daemon's effective user and to reject group or other write access. A
    shared writable existing ancestor is accepted only when it is sticky and its
    next existing component has a trusted owner.
  • Create missing path components and sandbox slots under random private staging
    names. Retain their descriptors and filesystem identities, publish them with
    an atomic no-replace rename, synchronize the parent, and verify the published
    names before use.
  • Initialize sandbox artifacts through the retained slot descriptor. If a slot
    name changes identity, acquisition fails without adopting or deleting the
    replacement.
  • Keep storage acquisition under the sandbox operation lock after request
    cancellation. Destroy waits until acquisition finishes or establishes that
    cleanup by sandbox identifier is unsafe.
  • Perform acquire, reconstruct, synchronization, and release relative to the
    retained instances root. Revalidate ordinary backend-visible paths before
    returning them.
  • Make recursive release fail closed on symbolic links, multiply linked files,
    unexpected entry types, mount changes, and object replacement.
  • Add focused coverage for path publication, permissions, aliases,
    replacement, cancellation, provider failure, rollback, release, and relative
    path resolution.
  • Update the English and Chinese README and existing user guide with the
    compatibility boundary and operator recovery steps.

Base-image reads through storage.images_dir remain path-based. Backends
still receive ordinary host paths. Replacement after provider handoff but
before a backend opens the path remains tracked by #2495 and is not claimed by
this change.

Related issue

Closes #2484

Refs #2254

Follow-up backend path handoff: #2495

User / Agent impact

The storage configuration fields, HTTP APIs, successful sandbox lifecycle, and
on-disk slot format are unchanged. Existing safe layouts require no migration,
and first-start creation remains supported when the parent path satisfies the
ownership and permission checks.

Blaze now rejects unsafe path aliases, shared writable publication parents, a
root owned by another daemon, and names already occupied at atomic
publication. If the configured instances path is renamed or replaced while
Blaze is running, new allocation and reconstruction fail instead of using the
replacement. Work that already retained the original root continues against
that root.

Canceling a create request no longer permits destroy to overtake unfinished
storage acquisition. If Blaze cannot prove that a published slot name still
identifies its directory, automatic cleanup by sandbox identifier is disabled
for the current daemon process and the sandbox requires inspection.

Privileged processes and processes running with the daemon's effective user
remain within the host administration boundary. Cleanup suppression after a
detected replacement is not persisted across daemon restart, so stop Blaze and
inspect or restore the storage path before restarting after an administrative
path change.

A process exit after private staging creation but before publication or cleanup
can leave an empty .blaze-dir-<uuid>.tmp directory. Blaze does not adopt or
delete such restart residue based only on its name.

Risk and compatibility

  • Public CLI, API, configuration, or documented behavior changed
  • Privileged or security-sensitive behavior changed
  • Cross-component contract changed
  • Migration or rollback guidance is needed

The visible change is explicit rejection and recovery handling for unsafe
filesystem conditions. Normal configuration, APIs, successful operation, and
stored sandbox data remain compatible.

Commit structure

  1. 6b4a8a50030a302bd163bff6a841e4a9d586f88b — bind the validated
    instances root to a retained descriptor owner and move provider lifecycle
    operations beneath it.
  2. 03616fc0a18d06ec5d170df344e2dc2465e1ec10 — add private no-replace
    publication, identity and durability checks, cancellation-safe acquisition,
    and fail-closed cleanup.

The previous validation-only correction commit was folded into the commit that
introduced each affected invariant. The final source tree is unchanged from
the reviewed current-main candidate.

Validation

Revision identity:

  • base: ba20d94d19a73e5b781cab0c687d4034ad0d0dae, tree
    b69ad4b5dd999e7244b1cea058e62232e7d1407a;
  • first commit: 6b4a8a50030a302bd163bff6a841e4a9d586f88b, tree
    31fbf0d9889980e56372cbdd5f20719706d59e3a;
  • exact head: 03616fc0a18d06ec5d170df344e2dc2465e1ec10, tree
    32d16adabaea187c620040136551a12dcb153978;
  • GitHub merge ref: bf65d19d89a1d6216117d6ce5e1f09eae0c9a15c, tree
    32d16adabaea187c620040136551a12dcb153978, with ordered parents
    ba20d94d19a73e5b781cab0c687d4034ad0d0dae and
    03616fc0a18d06ec5d170df344e2dc2465e1ec10.

Each public object was independently reconstructed from GitHub's public commit,
tree, blob, and source-archive interfaces, then validated on native Linux
x86_64 with Rust and Cargo 1.88.0, locked offline dependencies, a fresh Cargo
home, and an empty target directory for every stage.

For the first commit:

  • formatting, default and all-feature metadata, all-target builds, strict
    Clippy, serial tests, and strict rustdoc passed;
  • default tests passed: blaze-core 53 and blazed 280;
  • all-feature tests passed: blaze-core 53 and blazed 301;
  • 49 focused storage-root and daemon-planning tests passed;
  • bilingual documentation naming, parity, and link checks passed.

For the exact head and GitHub merge ref, each in a separate fresh environment:

  • the same default and all-feature matrix passed;
  • default tests passed: blaze-core 53 and blazed 288;
  • all-feature tests passed: blaze-core 53 and blazed 314;
  • 61 focused publication, cancellation, storage-root, and daemon-planning tests
    passed;
  • bilingual documentation naming, parity, and link checks passed.

The source tree remained unchanged in all three runs. Final source-archive
SHA-256 values were:

  • first commit:
    5288dacf0ffa9624550219d3dd9e3eb8ba012c8827cd80c0d44ecf846b46a906;
  • exact head:
    465573b56da73762bbe8c8793bc7e50ce02acabfa26c47917c6285505c664c3b;
  • GitHub merge ref:
    15288ea8eff25330fd6c0975fce2323f1df56ecd82c1cf1c7a095f7f7caef4fd.

Hosted checks for the rewritten exact head passed:

GitHub's public commit status surface does not currently expose an independent
CLA result for this rewritten head, so no CLA result is claimed here. The
exact-head Codex review
reviewed 03616fc0a1 and reported no major issues.

Documentation and rollback

The English and Chinese README and existing user guide describe accepted and
rejected layouts, pathname replacement, request cancellation, the
administration boundary, restart limitations, and operator recovery.

To roll back, stop every daemon using the instances root before restoring the
previous binary. No data migration is required, but the earlier path-based
failure behavior returns after rollback.

All review threads are resolved. No unresolved inline finding remains for the
rewritten exact head.

@github-actions github-actions Bot added component:blaze src/blaze scope:documentation ./docs/|./*.md|./NOTICE labels Aug 13, 2026
@WeissonHan
WeissonHan force-pushed the fix/blaze/storage-root-ownership-draft-v1 branch from b94e624 to e8bdf50 Compare August 13, 2026 04:05
@WeissonHan WeissonHan changed the title fix(blaze): bind storage roots fix(blaze): bind instance storage root Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review This rewritten one-commit PR binds only the mutable instance storage root, keeps image reads and recovery out of scope, and has passed the exact-tree Linux default, all-feature, strict Clippy, rustdoc, and focused ownership/cleanup matrix.

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

Copy link
Copy Markdown

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: e8bdf5091e

ℹ️ 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 thread src/blaze/crates/blazed/src/file_provider.rs Outdated
Comment thread src/blaze/crates/blazed/src/file_provider.rs Outdated
@WeissonHan
WeissonHan force-pushed the fix/blaze/storage-root-ownership-draft-v1 branch from e8bdf50 to 030c3f1 Compare August 13, 2026 05:41

Copy link
Copy Markdown
Collaborator Author

@codex review The two findings on reconstruction error classification and diff-artifact initialization are fixed in 030c3f1d5bff; the rewritten exact head passed fresh Linux default and all-feature build, strict Clippy, workspace tests, rustdoc, and focused regressions.

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

Copy link
Copy Markdown

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: 030c3f1d5b

ℹ️ 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 thread src/blaze/crates/blazed/src/file_provider.rs
@WeissonHan
WeissonHan force-pushed the fix/blaze/storage-root-ownership-draft-v1 branch from 030c3f1 to d9030c9 Compare August 13, 2026 05:53

Copy link
Copy Markdown
Collaborator Author

@codex review The remaining wrong-type reconstruction finding is fixed in d9030c99470e by no-follow metadata classification before open and retained-inode verification; the exact head passed the focused socket regression and Linux all-feature build, strict Clippy, and workspace tests.

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

Copy link
Copy Markdown

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: d9030c9947

ℹ️ 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 thread src/blaze/crates/blazed/src/file_provider.rs Outdated
@WeissonHan
WeissonHan force-pushed the fix/blaze/storage-root-ownership-draft-v1 branch from d9030c9 to 9fb3d91 Compare August 13, 2026 06:42
@WeissonHan
WeissonHan marked this pull request as ready for review August 13, 2026 06:49
@WeissonHan
WeissonHan requested a review from casparant as a code owner August 13, 2026 06:49

@qoderai qoderai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • 实例存储根从规划到准备阶段的身份校验存在空隙,若后续指向不同目录可能绕过生命周期边界约束。
  • 生命周期状态根按单一 state_dir 解析,未全面覆盖多挂载场景下的实例根与状态根交叉风险。
  • 阻塞 acquire 事务“可能残留所有权”路径与 warm 验证的剩余清理契约不完全对齐,易触发不必要隔离/删除。

🤖 Generated by QoderView workflow run

Comment thread src/blaze/crates/blazed/src/daemon.rs
Comment thread src/blaze/crates/blazed/src/sandbox/template.rs
Comment thread src/blaze/crates/blaze-core/src/storage.rs

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

Copy link
Copy Markdown

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: 9fb3d91ee2

ℹ️ 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 thread src/blaze/crates/blazed/src/file_provider.rs
@WeissonHan
WeissonHan force-pushed the fix/blaze/storage-root-ownership-draft-v1 branch 2 times, most recently from 96f4e65 to b96a1fe Compare August 13, 2026 07:38

Copy link
Copy Markdown
Collaborator Author

@codex review Verify that the file provider retains exclusive instance-root ownership, keeps mutable operations descriptor-relative, and never returns backend-visible storage paths through a replaced root.

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

Copy link
Copy Markdown

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: b96a1fec93

ℹ️ 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 thread src/blaze/crates/blazed/src/file_provider.rs
@WeissonHan

Copy link
Copy Markdown
Collaborator Author

@codex review

@WeissonHan
WeissonHan force-pushed the fix/blaze/storage-root-ownership-draft-v1 branch from b96a1fe to 1611637 Compare August 13, 2026 08:59

Copy link
Copy Markdown
Collaborator Author

@codex review Bind the mutable instance-storage root to one retained directory object while safely handling opaque Linux mount roots.

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

Copy link
Copy Markdown

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: 16116370d9

ℹ️ 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 thread src/blaze/crates/blazed/src/daemon.rs Outdated
@WeissonHan
WeissonHan force-pushed the fix/blaze/storage-root-ownership-draft-v1 branch from 1611637 to 7946157 Compare August 13, 2026 09:32

Copy link
Copy Markdown
Collaborator Author

@codex review Reject resolved storage-root aliases, including dangling symbolic links and bind mounts, before provider-owned paths are created.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 7946157107

ℹ️ 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".

@WeissonHan
WeissonHan force-pushed the fix/blaze/storage-root-ownership-draft-v1 branch from 7946157 to fbee4a9 Compare August 13, 2026 09:43

Copy link
Copy Markdown
Collaborator Author

@codex review Verify that resolved storage-root aliases fail before materialization and that simulated restart tests use the provider's bounded lock-reopen path.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: fbee4a9366

ℹ️ 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".

@WeissonHan

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: fbee4a9366

ℹ️ 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".

@WeissonHan
WeissonHan marked this pull request as draft August 14, 2026 08:14
@WeissonHan
WeissonHan force-pushed the fix/blaze/storage-root-ownership-draft-v1 branch from fbee4a9 to b69328d Compare August 14, 2026 08:15
@WeissonHan
WeissonHan marked this pull request as ready for review August 14, 2026 08:18

Copy link
Copy Markdown
Collaborator Author

@codex review Verify the new bilingual storage compatibility guidance against the unchanged ownership implementation at b69328d.

@WeissonHan

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: b69328d68f

ℹ️ 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 thread src/blaze/crates/blazed/src/file_provider.rs Outdated
@WeissonHan
WeissonHan marked this pull request as draft August 14, 2026 08:41
@WeissonHan
WeissonHan force-pushed the fix/blaze/storage-root-ownership-draft-v1 branch from d8e3df8 to fc28fb8 Compare August 14, 2026 12:38

Copy link
Copy Markdown
Collaborator Author

@codex review Verify that the exact head atomically publishes retained storage directories and keeps cancelled acquisition under lock without changing safe-layout behavior.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: fc28fb8b6d

ℹ️ 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".

@WeissonHan
WeissonHan marked this pull request as ready for review August 15, 2026 09:33

Copy link
Copy Markdown
Collaborator Author

@codex review Please review the exact head's atomic publication of retained storage directories, cancellation supervision, and compatibility with the current main branch.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: fc28fb8b6d

ℹ️ 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".

Retain an exclusive descriptor owner for storage.instances_dir from startup
planning through the file-provider lifetime. Descriptor-relative operations
prevent path replacement from redirecting mutable slot work without removing
the public StorageSlot paths used by backends.

Keep storage.images_dir reads path-based. Leave slot inventory, startup
recovery, and warm storage to follow-up work.

Fixes: 8cf1df2 ("feat(blaze): implement FileStorageProvider with unit tests")
Signed-off-by: Weisson <Weisson@linux.alibaba.com>
Publish missing storage components and sandbox slots through private,
descriptor-retained staging directories and no-replace renames. Reject
path chains whose permissions allow untrusted replacement while keeping
first-start creation.

Keep storage acquisition under detached per-sandbox supervision so request
cancellation cannot let destroy overtake filesystem work. Carry cleanup
disposition explicitly and suppress stable-name cleanup when identity cannot
be proven.

A process crash before staging publication can leave an empty hidden
directory. Root and same-effective-user path mutation remains an
administrative trust boundary.

Signed-off-by: Weisson <Weisson@linux.alibaba.com>
@WeissonHan
WeissonHan force-pushed the fix/blaze/storage-root-ownership-draft-v1 branch from fc28fb8 to 03616fc Compare August 15, 2026 16:43

Copy link
Copy Markdown
Collaborator Author

@codex review Please review exact head 03616fc0a18d06ec5d170df344e2dc2465e1ec10, both rewritten commits, and the cumulative diff from ba20d94d19a73e5b781cab0c687d4034ad0d0dae, with particular attention to retained instances-root ownership, no-replace publication, cancellation-safe acquisition, replacement-safe cleanup, and any P1/P2 issue.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 03616fc0a1

ℹ️ 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".

Copy link
Copy Markdown
Collaborator Author

@casparant All 11 review threads are now resolved. The rewritten exact head 03616fc0a18d06ec5d170df344e2dc2465e1ec10 and its current-main merge candidate passed the complete native Linux validation matrix and hosted checks, and the exact-head Codex review reported no major issues. This pull request is ready for maintainer review.

@WeissonHan

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 03616fc0a1

ℹ️ 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:blaze src/blaze scope:documentation ./docs/|./*.md|./NOTICE

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[blaze] bind file-provider instances to an owned root

1 participant