mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-08 06:13:14 +00:00
refactor: extract startup ready lifecycle boundary (#3635)
This commit is contained in:
@@ -5,15 +5,15 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block
|
||||
## Current Context
|
||||
|
||||
- Issue: [`rustfs/backlog#660`](https://github.com/rustfs/backlog/issues/660)
|
||||
- Branch: `overtrue/arch-startup-shutdown-lifecycle-boundary`
|
||||
- Baseline: `origin/main`
|
||||
(`eec1792c7bd1bf650dbb3c46d7873db6fed6150f`).
|
||||
- Branch: `overtrue/arch-startup-ready-lifecycle-boundary`
|
||||
- Baseline: `origin/main` (`e9037f9eb09fcbb31d980efac8b8e6b8f12bcaef`).
|
||||
- PR type for this branch: `pure-move`
|
||||
- Runtime behavior changes: none.
|
||||
- Rust code changes: move startup shutdown sequencing from `startup_services`
|
||||
into a dedicated shutdown lifecycle boundary.
|
||||
- Rust code changes: move ready publication, scanner startup, shutdown-signal
|
||||
wait, and stopped-state final logging from `startup_services` into a
|
||||
dedicated startup lifecycle boundary.
|
||||
- CI/script changes: none.
|
||||
- Docs changes: record the R-023 startup shutdown lifecycle boundary slice.
|
||||
- Docs changes: record the R-024 startup lifecycle boundary slice.
|
||||
|
||||
## Phase 0 Tasks
|
||||
|
||||
@@ -2063,6 +2063,20 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block
|
||||
check, migration/layer guards, formatting, diff hygiene, Rust risk scan,
|
||||
branch freshness check, pre-commit quality gate, and three-expert review.
|
||||
|
||||
- [x] `R-024` Extract startup ready lifecycle boundary.
|
||||
- Do: add `startup_lifecycle` and move ready publication, global init time,
|
||||
scanner startup, shutdown-signal wait, shutdown delegation, and final
|
||||
stopped-state logging out of `startup_services`.
|
||||
- Acceptance: lifecycle order stays server-ready log, IAM readiness
|
||||
publication, global init time, optional scanner startup, shutdown wait,
|
||||
shutdown sequence delegation, and final stopped log.
|
||||
- Must preserve: inline/deferred IAM readiness behavior, scanner start timing,
|
||||
global init-time timing, shutdown signal wait semantics, shutdown ordering,
|
||||
service state reporting, and fatal boundary on readiness publication.
|
||||
- Verification: focused lifecycle/service/shutdown tests, RustFS lib check,
|
||||
migration/layer guards, formatting, diff hygiene, Rust risk scan, branch
|
||||
freshness check, pre-commit quality gate, and three-expert review.
|
||||
|
||||
## Next PRs
|
||||
|
||||
1. `pure-move`: continue larger lifecycle hook slices for optional runtime
|
||||
@@ -2074,9 +2088,9 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block
|
||||
|
||||
| Expert | Status | Notes |
|
||||
|---|---|---|
|
||||
| Quality/architecture | passed | R-023 keeps startup orchestration in `startup_services` and moves shutdown sequencing into `startup_shutdown`. |
|
||||
| Migration preservation | passed | Runtime token cancellation, background shutdown, optional runtime planning, notifier/audit/profiling shutdown, HTTP shutdown, optional runtime waits, and service state transitions remain ordered. |
|
||||
| Testing/verification | passed | Focused shutdown, optional runtime, and startup service tests plus final checks are tracked below before push. |
|
||||
| Quality/architecture | passed | R-024 keeps runtime service initialization in `startup_services` and moves ready/scanner/shutdown-wait orchestration into `startup_lifecycle`. |
|
||||
| Migration preservation | passed | Ready publication, global init time, scanner startup, shutdown wait/delegation, and final stopped logging remain ordered. |
|
||||
| Testing/verification | passed | Focused lifecycle, shutdown, and startup service tests plus final checks are tracked below before push. |
|
||||
|
||||
## Verification Notes
|
||||
|
||||
@@ -2145,6 +2159,19 @@ Passed before push:
|
||||
- `make pre-commit`: passed.
|
||||
- Three-expert review: passed.
|
||||
|
||||
- Issue #660 R-024 current slice:
|
||||
- `cargo test -p rustfs --lib startup_lifecycle -- --nocapture`: passed.
|
||||
- `cargo test -p rustfs --lib startup_services -- --nocapture`: passed.
|
||||
- `cargo test -p rustfs --lib startup_shutdown -- --nocapture`: passed.
|
||||
- `cargo check -p rustfs --lib`: passed.
|
||||
- `./scripts/check_architecture_migration_rules.sh`: passed.
|
||||
- `./scripts/check_layer_dependencies.sh`: passed.
|
||||
- `cargo fmt --all --check`: passed.
|
||||
- `git diff --check`: passed.
|
||||
- Rust risk scan on changed Rust files: passed.
|
||||
- `make pre-commit`: passed.
|
||||
- Three-expert review: passed.
|
||||
|
||||
- Issue #660 R-020 current slice:
|
||||
- `cargo test -p rustfs --lib startup_profiling -- --nocapture`: passed.
|
||||
- `cargo check -p rustfs --lib`: passed.
|
||||
|
||||
@@ -39,6 +39,14 @@ must not reorder runtime-token cancellation, background service shutdown,
|
||||
optional runtime shutdown planning, notifier/audit/profiling shutdown, HTTP
|
||||
shutdown, optional runtime waits, or final service-state publication.
|
||||
|
||||
## Startup Lifecycle Boundary
|
||||
|
||||
`startup_lifecycle` owns the ready-to-shutdown orchestration after runtime
|
||||
services initialize. Service modules may return initialized handles into this
|
||||
boundary, but they must not reorder ready publication, global init-time
|
||||
publication, scanner startup, shutdown-signal wait, shutdown delegation, or the
|
||||
final stopped-state log.
|
||||
|
||||
## Optional Runtime Boundary
|
||||
|
||||
`startup_optional_runtimes` owns startup and shutdown handoff for optional
|
||||
|
||||
@@ -45,9 +45,9 @@ new startup semantics.
|
||||
| `RUN-019` | `rustfs/src/startup_services.rs` | Add bucket notification config and initialize notification system. | Adds bucket notification configuration and publishes the global notification system. | Notification config add is non-fatal in this path; global notification init is fatal on error. | None |
|
||||
| `RUN-020` | `rustfs/src/startup_services.rs` | Create AHM cancellation token and initialize heal manager when scanner or heal is enabled. | Creates AHM cancellation token and starts heal manager for heal/scanner workflows. | Heal manager init is fatal when enabled. | None |
|
||||
| `RUN-021` | `rustfs/src/startup_services.rs` | Print server info, init update check, allocator reclaim, metrics, memory observability, and auto-tuner. | Starts informational/update/memory/metrics background tasks when enabled. | Non-fatal in this path. | None |
|
||||
| `RUN-022` | `rustfs/src/startup_services.rs` and `rustfs/src/startup_iam.rs` | Log successful startup and publish full readiness for inline IAM. | Logs version/address, checks runtime readiness, marks `FullReady`, and sets service state to `Ready` when IAM was ready inline. | Fatal if runtime readiness is not reached within the startup wait. | Marks `FullReady` only for inline IAM here |
|
||||
| `RUN-023` | `rustfs/src/startup_services.rs` | Publish global init time and start data scanner when enabled. | Sets global init time and starts scanner after the successful-startup log. | Scanner start is non-fatal in this path. | Full readiness may already be published or may await deferred IAM recovery |
|
||||
| `RUN-024` | `rustfs/src/startup_services.rs` | Wait for shutdown signal. | Blocks the main task until a shutdown signal is received. | Non-fatal. | Runtime remains in its current readiness state |
|
||||
| `RUN-022` | `rustfs/src/startup_lifecycle.rs` and `rustfs/src/startup_iam.rs` | Log successful startup and publish full readiness for inline IAM. | Logs version/address, checks runtime readiness, marks `FullReady`, and sets service state to `Ready` when IAM was ready inline. | Fatal if runtime readiness is not reached within the startup wait. | Marks `FullReady` only for inline IAM here |
|
||||
| `RUN-023` | `rustfs/src/startup_lifecycle.rs` | Publish global init time and start data scanner when enabled. | Sets global init time and starts scanner after the successful-startup log. | Scanner start is non-fatal in this path. | Full readiness may already be published or may await deferred IAM recovery |
|
||||
| `RUN-024` | `rustfs/src/startup_lifecycle.rs` | Wait for shutdown signal. | Blocks the main task until a shutdown signal is received. | Non-fatal. | Runtime remains in its current readiness state |
|
||||
|
||||
## Deferred IAM Readiness
|
||||
|
||||
|
||||
Reference in New Issue
Block a user