feat: add three-state volume initialization (None → Initializing → Ready)#127
Merged
Conversation
Add three-state initialization detection (None, Initializing, Ready) for LUKS2 volumes. get_init_state() reads the subsystem field from the raw LUKS2 header. is_initialized() is refactored to use get_init_state() internally, preserving backward compatibility.
format() now calls mark_volume_as_initializing() after writing the LUKS2 header, ensuring the volume starts in Initializing state. This prevents the ambiguous no-marker state if init is interrupted after format but before the final ready marker.
Extend VolumeStatusKind with Initializing variant for partially initialized volumes. determine_status() now uses get_init_state() to distinguish None, Initializing, and Ready states. The show command displays Initializing volumes with a warning indicator. Also handle Initializing state in the init command to allow re-initialization of interrupted volumes.
Add tests for the full None -> Initializing -> Ready lifecycle: - Raw device returns None - After format returns Initializing - After mark returns Ready - is_initialized backward compat: true only for Ready
|
@imlk0 ,您好,您的请求已接收,请耐心等待结果。 |
|
@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
Move set_label for the initializing marker into format()'s spawn_blocking block, making header creation and marker write a single atomic operation. Remove the now-unused mark_volume_as_initializing() function.
|
@imlk0 ,您好,您的请求已接收,请耐心等待结果。 |
|
@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
…field, and parallel lifecycle test - format() now sets subsystem='cryptpilot-initializing' directly in CryptParamsLuks2 during format(), eliminating the post-format set_label call. Always pass params_ref (not just for integrity) so subsystem is written regardless of integrity type. - blkid.rs: add 'subsystem' field to BlkidProbeResult::KnownSignature to expose the LUKS2 SUBSYSTEM field from blkid -p output. - Add test_full_init_lifecycle_with_blkid_probe: runs blkid -p in a parallel monitor while performing format + mkfs + mark, verifying all three states are observable via blkid. - before_sysroot.rs: update KnownSignature pattern to include new field.
…ries - Add serial_test dev-dependency to prevent parallel test interference - Rewrite test_full_init_lifecycle_with_blkid_probe: uses get_init_state() for reliable state verification at each step, with wait_for_blkid_subsystem() retry loop (up to 3s/5s) to detect blkid SUBSYSTEM changes - Add sync() calls after format and mark to flush kernel page cache
|
@imlk0 ,您好,您的请求已接收,请耐心等待结果。 |
|
@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
Add the blkid subsystem field to the KnownSignature pattern match and include it in the persistent-mode data-protection error message for better diagnostics.
… test The spawned _monitor task recorded SUBSYSTEM transitions into observed_subsystems but never asserted on them. All verification is already done by wait_for_blkid_subsystem() which uses the same blkid polling logic with proper wait/retry semantics. Also removes the unused 300ms startup delay and Arc/Mutex imports.
When delta_location is DiskPersist and the volume is recreated (format + mkfs), call mark_volume_as_initialized() so that is_initialized() returns true on the next boot and the delta volume is reused instead of being wiped again. Before this fix, DiskPersist volumes were reformatted on every boot because format() writes 'cryptpilot-initializing' and nothing ever transitioned the marker to 'cryptpilot'.
|
@imlk0 ,您好,您的请求已接收,请耐心等待结果。 |
|
@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
format() always writes subsystem='cryptpilot-initializing'. After the full init sequence (format + mkfs), always call mark_volume_as_initialized() to transition to 'cryptpilot' (Ready), regardless of delta_location or provider type. This ensures every format() call is followed by a complete lifecycle, keeping the volume state consistent.
|
@imlk0 ,您好,您的请求已接收,请耐心等待结果。 |
|
@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
- Remove needless borrows in wait_for_blkid_subsystem calls - Replace Command::output() with run_with_status_checker() to satisfy disallowed_methods lint
|
@imlk0 ,您好,您的请求已接收,请耐心等待结果。 |
|
@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a three-state initialization marker system for LUKS2 volumes so external scripts and
cryptpilot-cryptcan detect partially initialized volumes (interrupted during format) vs uninitialized vs fully ready.Problem
When
cryptpilot-crypt initformats a LUKS2 volume, it writes the LUKS2 header first, then creates an optional filesystem, and finally sets thesubsystem = "cryptpilot"marker. If the process is interrupted (e.g., timeout, pod restart), the device has a valid LUKS2 header but no subsystem marker. External scripts cannot distinguish between:Solution
Three-state system using the existing LUKS2
subsystemfield:NoneInitializingcryptpilot-initializingReadycryptpilotChanges
cryptpilot-core
VolumeInitStateenum: None, Initializing, Readyget_init_state(): public API returning the enummark_volume_as_initializing(): private, called byformat()format(): now writesinitializingmarker right after creating the LUKS2 headeris_initialized(): unchanged — returnstrueonly forReady(backward compatible)cryptpilot-crypt
show:VolumeStatusKindgainsInitializingvariant, displayed with yellow warninginit: auto-retries onInitializingstate without requiring--force-reinitTest Results
cargo fmt --checkpassesCommits
🤖 Generated with Claude Code