This file configures AI assistants to work effectively with the TopoLVM codebase.
When you use AI assistance on this project, the AI reads this file to understand:
- Where to find documentation
- Which files are auto-generated (do not edit)
- Common development workflows
- Testing requirements and conventions
Before making changes, always reference the canonical documentation:
- Architecture & Design: docs/design.md - Component diagram, motivation, how provisioning works
- Getting Started: README.md and docs/getting-started.md
- Components:
- docs/topolvm-controller.md - CSI controller service
- docs/topolvm-node.md - CSI node service
- docs/topolvm-scheduler.md - Scheduler extender
- docs/lvmd.md - LVM daemon
- API Reference:
- docs/logical-volume-crd.md - LogicalVolume CRD spec
- docs/lvmd-protocol.md - gRPC protocol (auto-generated)
- Advanced Topics:
- docs/snapshot-and-restore.md - Snapshot/clone support
- docs/advanced-setup.md - Advanced configurations
- docs/limitations.md - Known limitations
- docs/faq.md - Frequently asked questions
- Language: Go 1.24.0
- Framework: Kubernetes controller-runtime
- Type: CSI (Container Storage Interface) plugin for Kubernetes using LVM
- License: LICENSE
# Setup development environment (run once)
make setup
# Run tests and linting before committing
make test
# Fix linting issues automatically
make lint-fix
# Generate code after modifying API types or protobuf
make generate
# Verify no uncommitted generated files (CI check)
make check-uncommitted
# Build binaries
make build
# Build Docker images
make imageSee test/e2e/README.md for detailed E2E testing instructions.
These files are generated by make generate - NEVER edit manually:
api/v1/zz_generated.deepcopy.go(generated from API types)api/legacy/v1/*(generated from api/v1)pkg/lvmd/proto/lvmd.pb.go(generated from .proto)pkg/lvmd/proto/lvmd_grpc.pb.go(generated from .proto)docs/lvmd-protocol.md(generated from .proto)config/**/*.yaml(generated controller gen)charts/topolvm/templates/crds/*.yaml(generated from API types)charts/topolvm/README.md(generated bymake generate-helm-docs)
Always run make generate after modifying:
- API types in
api/v1/*_types.go - Protobuf definitions in
pkg/lvmd/proto/lvmd.proto - Helm chart values or templates
# 1. Edit source files (API types or protobuf)
vim api/v1/logicalvolume_types.go
# 2. Generate derived code
make generate
# 3. Verify changes
git diff
# 4. Commit both source and generated files
git add api/v1/logicalvolume_types.go api/v1/zz_generated.deepcopy.go config/crd/
git commit -s -m "Add new field to LogicalVolume CRD"- Don't guess file locations: Use Grep/Glob tools to find files rather than assuming paths
- Read design.md first: Before implementing features, understand the architecture in docs/design.md
- Check existing tests: Look at
*_test.gofiles for patterns before writing new tests - Follow gRPC patterns: When modifying lvmd protocol, study existing RPC patterns in pkg/lvmd/proto/lvmd.proto
- Kubernetes controller patterns: This project uses controller-runtime - study existing controllers in internal/
- Add tests for new features (use Ginkgo/Gomega framework)
- Ensure tests pass with
-raceflag (checked by CI) - Update e2e tests for user-facing changes
- Test both thin and thick provisioning modes when relevant
- Sign all commits: Use
git commit -s(DCO requirement) - PR checklist:
- Run
make testlocally - Run
make generateif you modified API types or protobuf - Run
make check-uncommittedto verify generated files are committed - Ensure all commits are signed
- Run
topolvm/
├── api/v1/ # Kubernetes API types (source of truth for CRDs)
├── cmd/ # Main binaries (hypertopolvm, lvmd)
├── internal/ # Internal packages (controllers, drivers)
├── pkg/lvmd/proto/ # gRPC protocol definitions
├── charts/topolvm/ # Helm chart
├── docs/ # Documentation (READ THESE FIRST)
├── test/e2e/ # End-to-end test suite
└── Makefile # Build automation
When implementing features, avoid:
- Command injection (sanitize inputs to LVM commands)
- Path traversal (validate volume names, device paths)
- Privilege escalation (lvmd runs privileged - be extra careful)
- Resource exhaustion (validate size limits, quota enforcement)
Before diving into TopoLVM-specific operations, refer to the mechanism and spec of the Kubernetes CSI driver.
For implementation tasks, study these workflows in docs/design.md:
- Dynamic Provisioning (11 steps): PVC → LogicalVolume CRD → LVM volume creation
- Volume Expansion (9 steps): PVC resize → LV resize → filesystem resize
- Snapshot Creation: Only works with thin provisioning (see docs/snapshot-and-restore.md)
- Search existing code:
grep -r "pattern" .or use Grep tool - Check docs/faq.md for common issues
- Look at test files for usage examples:
find . -name "*_test.go" -exec grep -l "pattern" {} \; - Review recent PRs for similar changes:
gh pr list --state merged --limit 20
See CONTRIBUTING.md for full contribution guidelines.
Key points:
- All commits must be signed with DCO (
git commit -s) - Follow Go code style (gofmt -s)
- Pass all linters (golangci-lint, go vet)
- Add tests for new functionality