Skip to content

Commit 42f2102

Browse files
authored
docs: align project docs and console-web pre-commit (#100)
Clarify CI vs make pre-commit, service ports, and roadmap status. Standardize scripts and READMEs to English. Translate console module comments to English (no behavior change). Fix console-web lint (eslint .) and Prettier targets via npm scripts and Makefile. Made-with: Cursor
1 parent 032bb4d commit 42f2102

42 files changed

Lines changed: 597 additions & 586 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/AGENTS.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ Applies to `.github/` and repository pull-request operations.
1919

2020
## CI Alignment
2121

22-
When changing CI-sensitive behavior, keep local validation aligned with `.github/workflows/ci.yml`.
22+
When changing CI-sensitive behavior, keep local validation aligned with [`Makefile`](Makefile) at the repo root.
2323

24-
Current `test-and-lint` gate includes:
24+
**Local bar before push (authoritative for contributors):** `make pre-commit` — runs Rust `fmt-check`, `clippy`, `test`, plus `console-web` lint and Prettier check (see `Makefile`).
2525

26+
**CI workflow** [`.github/workflows/ci.yml`](workflows/ci.yml) `test-and-lint` job currently runs:
27+
28+
- `cargo nextest run --all --no-tests pass` and `cargo test --all --doc`
2629
- `cargo fmt --all --check`
2730
- `cargo clippy --all-features -- -D warnings`
28-
- `cargo test --all`
29-
- `cd console-web && npm run lint`
30-
- `cd console-web && npx prettier --check "**/*.{ts,tsx,js,jsx,json,css,md}"`
31+
32+
It does **not** run `console-web` checks; still run **`make pre-commit` locally** before opening a PR so frontend changes are validated.

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ updates:
2424
interval: "daily"
2525
- package-ecosystem: "cargo"
2626
schedule:
27-
interval: "daily" # 这里添加了 schedule
27+
interval: "daily"
2828
directory: "/"
2929
groups:
3030
deps:

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Documentation
11+
12+
- Aligned [`CLAUDE.md`](CLAUDE.md) and [`ROADMAP.md`](ROADMAP.md) with current code: Tenant status conditions and StatefulSet updates on the successful reconcile path are documented as implemented; remaining work (status on early errors, integration tests, rollout extras) is listed explicitly.
13+
- Clarified the documentation map: [`CONTRIBUTING.md`](CONTRIBUTING.md) (quality gates and CI alignment), [`docs/DEVELOPMENT.md`](docs/DEVELOPMENT.md) (environment setup), [`docs/DEVELOPMENT-NOTES.md`](docs/DEVELOPMENT-NOTES.md) (historical notes, not normative).
14+
- Updated [`examples/README.md`](examples/README.md): Tenant Services document S3 **9000** and RustFS Console **9001**; distinguished the Operator HTTP Console (default **9090**, `cargo run -- console`) from the Tenant `{tenant}-console` Service.
15+
- Standardized [`README.md`](README.md), [`scripts/README.md`](scripts/README.md), and shell scripts under `scripts/` to English for consistency with architecture and development docs.
16+
- Translated Rust doc and line comments in [`src/console/`](src/console/) to English (no behavior change).
17+
18+
### Fixed
19+
20+
- **`console-web` / `make pre-commit`**: `npm run lint` now runs `eslint .` (bare `eslint` only printed CLI help). Added `format` / `format:check` scripts; [`Makefile`](Makefile) `console-fmt` and `console-fmt-check` call them so Prettier resolves from `node_modules` after `npm install` in `console-web/`.
21+
1022
### Added
1123

1224
#### **StatefulSet Reconciliation Improvements** (2025-12-03, Issue #43)

CLAUDE.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
77
This is a Kubernetes operator for RustFS, written in Rust using the `kube-rs` library. The operator manages a custom resource `Tenant` (CRD) that provisions and manages RustFS storage clusters in Kubernetes.
88

99
**Current Status**: v0.1.0 (pre-release) - Early development, not yet production-ready
10-
**Test Coverage**: 25 tests, all passing ✅
10+
**Test Coverage**: 47 library unit tests, all passing ✅ (run `cargo test --all` for current count)
1111

1212
## Build and Development Commands
1313

@@ -31,8 +31,11 @@ cargo run -- crd
3131
# Generate CRD YAML to file
3232
cargo run -- crd -f tenant-crd.yaml
3333

34-
# Run the controller (requires Kubernetes cluster access)
34+
# Run the Kubernetes controller (requires cluster access)
3535
cargo run -- server
36+
37+
# Run the operator HTTP console API (default port 9090; used by console-web)
38+
cargo run -- console
3639
```
3740

3841
### Docker
@@ -41,7 +44,7 @@ cargo run -- server
4144
docker build -t operator .
4245
```
4346

44-
Note: The Dockerfile uses a multi-stage build with Rust 1.91-alpine.
47+
Note: The Dockerfile uses a multi-stage build (`rust:bookworm`, cargo-chef); the final image defaults to `debian:bookworm-slim`.
4548

4649
### Scripts (deploy / cleanup / check)
4750
Shell scripts are under `scripts/` and grouped by purpose. Run from project root (scripts will `cd` to project root automatically):
@@ -85,7 +88,7 @@ See `docs/architecture-decisions.md` for detailed ADRs.
8588
### Reconciliation Loop
8689

8790
The operator follows the standard Kubernetes controller pattern:
88-
- **Entry Point**: `src/main.rs` - CLI with two subcommands: `crd` and `server`
91+
- **Entry Point**: `src/main.rs` - CLI subcommands: `crd`, `server` (controller), `console` (management API)
8992
- **Controller**: `src/lib.rs:run()` - Sets up the controller that watches `Tenant` resources and owned resources (ConfigMaps, Secrets, ServiceAccounts, Pods, StatefulSets)
9093
- **Reconciliation Logic**: `src/reconcile.rs:reconcile_rustfs()` - Main reconciliation function that creates/updates Kubernetes resources for a Tenant
9194
- **Error Handling**: `src/reconcile.rs:error_policy()` - Intelligent retry intervals based on error type:
@@ -170,8 +173,9 @@ The `Tenant` type in `src/types/v1alpha1/tenant.rs` has factory methods for crea
170173
### Status Management
171174

172175
- **Status Types**: `src/types/v1alpha1/status/` - Status structures including state, pool status, and certificate status
173-
- The status is updated via the Kubernetes status subresource
174-
- **TODO at `reconcile.rs:92`**: Implement comprehensive status condition updates on errors (Ready, Progressing, Degraded)
176+
- The status is updated via the Kubernetes status subresource (`Context::update_status`, with a single retry on conflict)
177+
- **Implemented (successful reconcile path)**: Aggregates per-pool StatefulSet status, sets `Ready` / `Progressing` / `Degraded` conditions, overall `current_state`, and pool entries—see `reconcile_rustfs()` in `src/reconcile.rs`
178+
- **Remaining (Issue #42 follow-up)**: When reconcile returns early with `Err` (e.g. credential/KMS validation, immutable field violations), status is not always updated to reflect that failure; consider setting conditions or state before returning
175179

176180
### Utilities
177181

@@ -188,29 +192,29 @@ The `Tenant` type in `src/types/v1alpha1/tenant.rs` has factory methods for crea
188192

189193
## Code Structure Notes
190194

191-
- Uses `kube-rs` with specific git revisions for `k8s-openapi` and `kube` crates
195+
- Uses `kube` and `k8s-openapi` from crates.io (see `Cargo.toml` for versions)
192196
- Kubernetes version target: v1.30
193197
- Error handling uses the `snafu` crate for structured error types
194198
- All files include Apache 2.0 license headers
195199
- Uses `strum::Display` for enum-to-string conversions (`ImagePullPolicy`, `PodManagementPolicy`, `PoolState`, `State`)
196200

197201
## Important Dependencies
198202

199-
- **kube** and **k8s-openapi**: Pinned to specific git revisions (not crates.io versions)
200-
- TODO: Evaluate migration to crates.io versions
203+
- **kube** / **k8s-openapi**: Versions pinned in `Cargo.toml` (crates.io)
201204
- Uses Rust edition 2024
202-
- Build script (`build.rs`) generates build metadata using the `built` crate
205+
- Build script (`build.rs`) generates build metadata using the `shadow-rs` crate
203206

204207
## Known Issues and TODOs
205208

206209
### High Priority
207210
- [x] ~~**Secret-based credential management**~~**COMPLETED** (2025-11-15, Issue #41)
208-
- [ ] **Status condition management** (`src/reconcile.rs:92`, Issue #42)
209-
- [ ] **StatefulSet reconciliation** (`reconcile.rs`) - Creation works, updates need refinement (Issue #43)
210-
- [ ] **Integration tests** - Only unit tests currently exist
211+
- [x] ~~**Tenant status conditions on successful reconcile**~~`Ready` / `Progressing` / `Degraded`, pool-level status (see `reconcile.rs`)
212+
- [ ] **Status on reconciliation failures** — Early error returns may not patch Tenant status (Issue #42 follow-up)
213+
- [ ] **StatefulSet advanced rollout** — Safe updates and validation exist; rollback, richer strategies, and Issue #43 polish remain
214+
- [ ] **Integration tests** — Only unit tests in-repo today
211215

212216
### Medium Priority
213-
- [ ] Status subresource update retry logic improvements
217+
- [ ] Status subresource update retry beyond single conflict retry (`context.rs`)
214218
- [ ] TLS certificate rotation automation
215219
- [ ] Configuration validation enhancements (storage class existence, node selector validity)
216220

@@ -220,7 +224,7 @@ The `Tenant` type in `src/types/v1alpha1/tenant.rs` has factory methods for crea
220224
- **ROADMAP.md** - Development roadmap organized by focus areas (Core Stability, Advanced Features, Enterprise Features, Production Ready)
221225
- **docs/architecture-decisions.md** - ADRs documenting key architectural decisions
222226
- **docs/multi-pool-use-cases.md** - Comprehensive guide for multi-pool scenarios
223-
- **docs/DEVELOPMENT-NOTES.md** - Development workflow and contribution guidelines
227+
- **docs/DEVELOPMENT-NOTES.md** - Historical analysis and design notes (not the primary dev guide; see `docs/DEVELOPMENT.md` and `CONTRIBUTING.md`)
224228

225229
## Examples
226230

@@ -251,10 +255,8 @@ See `examples/README.md` for comprehensive usage guide.
251255
## Development Priorities (from ROADMAP.md)
252256

253257
### Core Stability (Highest Priority)
254-
- Secret-based credential management
255-
- Status condition management (Ready, Progressing, Degraded)
256-
- StatefulSet update and rollout management
257-
- Improved error handling and observability
258+
- Status on failed reconcile paths and stronger status retry
259+
- StatefulSet rollout polish (rollback, strategies) and observability (metrics)
258260
- Integration test suite
259261

260262
### Advanced Features

CONTRIBUTING.md

Lines changed: 37 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# RustFS Development Guide
22

3+
## Documentation map
4+
5+
- **This file (`CONTRIBUTING.md`)** — Authoritative for **code quality**, commit workflow, formatting, and alignment with `make pre-commit` and CI. When instructions conflict, prefer this file plus [`Makefile`](Makefile) and [`.github/workflows/ci.yml`](.github/workflows/ci.yml).
6+
7+
- **[`docs/DEVELOPMENT.md`](docs/DEVELOPMENT.md)** — Local environment setup (Kubernetes, kind, optional tools), IDE hints, and longer workflows. It **does not** redefine the quality gates above; run `make pre-commit` as the single local bar before pushing.
8+
9+
- **[`docs/DEVELOPMENT-NOTES.md`](docs/DEVELOPMENT-NOTES.md)** — Historical design notes and analysis sessions (not a normative spec). For current behavior, use the source tree, [`CHANGELOG.md`](CHANGELOG.md), and [`CLAUDE.md`](CLAUDE.md).
10+
311
## 📋 Code Quality Requirements
412

513
### 🔧 Code Formatting Rules
@@ -8,9 +16,9 @@
816

917
#### Pre-commit Requirements
1018

11-
Before every commit, you **MUST**:
19+
Before every commit, you **MUST** pass the same checks as `make pre-commit` (see below). In practice, the steps are:
1220

13-
1. **Format your code**:
21+
1. **Format your code** (or rely on `make fmt-check` to fail if not formatted):
1422

1523
```bash
1624
cargo fmt --all
@@ -25,63 +33,56 @@ Before every commit, you **MUST**:
2533
3. **Pass clippy checks**:
2634

2735
```bash
28-
cargo clippy --all-targets --all-features -- -D warnings
36+
cargo clippy --all-features -- -D warnings
37+
```
38+
39+
4. **Run tests**:
40+
41+
```bash
42+
cargo test --all
2943
```
3044

31-
4. **Ensure compilation**:
45+
5. **Console (frontend)** — from repo root:
3246

3347
```bash
34-
cargo check --all-targets
48+
cd console-web && npm run lint
49+
cd console-web && npx prettier --check "**/*.{ts,tsx,js,jsx,json,css,md}"
3550
```
3651

3752
#### Quick Commands
3853

39-
We provide convenient Makefile targets for common tasks:
54+
Targets are defined in [`Makefile`](Makefile). Use these from the **repository root**:
4055

4156
```bash
42-
# Format all code
57+
# Format all Rust code
4358
make fmt
4459

45-
# Check if code is properly formatted
60+
# Check Rust formatting (no writes)
4661
make fmt-check
4762

48-
# Run clippy checks
63+
# Clippy (Rust)
4964
make clippy
5065

51-
# Run compilation check
52-
make check
53-
54-
# Run tests
66+
# Rust tests
5567
make test
5668

57-
# Run all pre-commit checks (format + clippy + check + test)
58-
make pre-commit
69+
# Frontend: ESLint + Prettier check (requires npm install in console-web/)
70+
make console-lint
71+
make console-fmt-check
5972

60-
# Setup git hooks (one-time setup)
61-
make setup-hooks
73+
# Full gate before push (Rust + console-web): same as project / AGENTS.md rules
74+
make pre-commit
6275
```
6376

64-
### 🔒 Automated Pre-commit Hooks
65-
66-
This project includes a pre-commit hook that automatically runs before each commit to ensure:
67-
68-
- ✅ Code is properly formatted (`cargo fmt --all --check`)
69-
- ✅ No clippy warnings (`cargo clippy --all-targets --all-features -- -D warnings`)
70-
- ✅ Code compiles successfully (`cargo check --all-targets`)
71-
72-
#### Setting Up Pre-commit Hooks
73-
74-
Run this command once after cloning the repository:
77+
Optional quick compile (not a separate `make` target):
7578

7679
```bash
77-
make setup-hooks
80+
cargo check --all-targets
7881
```
7982

80-
Or manually:
83+
### 🔒 Git hooks (optional)
8184

82-
```bash
83-
chmod +x .git/hooks/pre-commit
84-
```
85+
The repository does **not** ship a `make setup-hooks` target. To run checks automatically on `git commit`, add your own `.git/hooks/pre-commit` that invokes `make pre-commit` (or the individual commands above).
8586

8687
### 📝 Formatting Configuration
8788

@@ -95,11 +96,7 @@ single_line_let_else_max_width = 100
9596

9697
### 🚫 Commit Prevention
9798

98-
If your code doesn't meet the formatting requirements, the pre-commit hook will:
99-
100-
1. **Block the commit** and show clear error messages
101-
2. **Provide exact commands** to fix the issues
102-
3. **Guide you through** the resolution process
99+
If your code doesn't meet the formatting requirements, CI or local checks will fail with clear messages.
103100

104101
Example output when formatting fails:
105102

@@ -148,22 +145,12 @@ Configure your IDE to:
148145
### ❗ Important Notes
149146

150147
- **Never bypass formatting checks** - they are there for a reason
151-
- **All CI/CD pipelines** will also enforce these same checks
152-
- **Pull requests** will be automatically rejected if formatting checks fail
148+
- **CI and `make pre-commit`** should stay aligned; see [`Makefile`](Makefile) and [`.github/workflows/ci.yml`](.github/workflows/ci.yml)
149+
- **Pull requests** may be rejected if checks fail
153150
- **Consistent formatting** improves code readability and reduces merge conflicts
154151

155152
### 🆘 Troubleshooting
156153

157-
#### Pre-commit hook not running?
158-
159-
```bash
160-
# Check if hook is executable
161-
ls -la .git/hooks/pre-commit
162-
163-
# Make it executable if needed
164-
chmod +x .git/hooks/pre-commit
165-
```
166-
167154
#### Formatting issues?
168155

169156
```bash

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ test:
5656
console-lint:
5757
cd console-web && npm run lint
5858

59-
# 前端 Prettier 自动格式化
59+
# 前端 Prettier 自动格式化(需先在 console-web 下 npm install)
6060
console-fmt:
61-
cd console-web && npx prettier --write "**/*.{ts,tsx,js,jsx,json,css,md}"
61+
cd console-web && npm run format
6262

6363
# 前端 Prettier 格式检查(仅检查不修改)
6464
console-fmt-check:
65-
cd console-web && npx prettier --check "**/*.{ts,tsx,js,jsx,json,css,md}"
65+
cd console-web && npm run format:check
6666

6767
# 构建
6868
build:

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# RustFS Kubernetes Operator
22

3-
RustFS k8s operator(开发中,尚未可用于生产)。
3+
RustFS Kubernetes operator (under development; not production-ready).
44

5-
## 项目结构概览
5+
## Repository layout
66

7-
- **scripts/**部署/清理/检查脚本(见 [scripts/README.md](scripts/README.md)
8-
- `scripts/deploy/`一键部署(Kind + Operator + Tenant
9-
- `scripts/cleanup/`资源清理
10-
- `scripts/check/`集群与 Tenant 状态检查
11-
- **deploy/**K8s/Helm 部署清单与 Kind 配置
12-
- `deploy/rustfs-operator/` — Helm Chart
13-
- `deploy/k8s-dev/`开发用 K8s YAML
14-
- `deploy/kind/` — Kind 集群配置(如 4 节点)
15-
- **examples/** — Tenant CR 示例
16-
- **docs/**架构与开发文档
7+
- **scripts/**Deploy, cleanup, and check scripts (see [scripts/README.md](scripts/README.md))
8+
- `scripts/deploy/`One-shot deploy (Kind + Operator + Tenant)
9+
- `scripts/cleanup/`Resource cleanup
10+
- `scripts/check/`Cluster and Tenant status checks
11+
- **deploy/**Kubernetes / Helm manifests and Kind configs
12+
- `deploy/rustfs-operator/` — Helm chart
13+
- `deploy/k8s-dev/`Development Kubernetes YAML
14+
- `deploy/kind/` — Kind cluster configs (e.g. 4-node)
15+
- **examples/**Sample Tenant CRs
16+
- **docs/**Architecture and development documentation

0 commit comments

Comments
 (0)