Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
551 commits
Select commit Hold shift + click to select a range
0a3151d
Merge remote-tracking branch 'origin/main' into astef-prototype
asergunov Nov 29, 2025
72321e9
Add copyright notice to multiple files
asergunov Nov 29, 2025
b387766
Skip failing tests: quorum calculation and selector validations
asergunov Nov 29, 2025
d05e07a
go lint fixes
asergunov Nov 29, 2025
3d00374
some spelling fixes
asergunov Nov 29, 2025
f5ea336
add module label to CDRs
asergunov Nov 29, 2025
5cd8e23
go-lint fixes
asergunov Nov 29, 2025
1820f31
Update .gitignore to include test data directory and modify parser_te…
asergunov Nov 29, 2025
1d021b2
go lint fixes
asergunov Nov 29, 2025
df7b5fa
Update Go modules and add linter scripts
asergunov Nov 29, 2025
7ebec93
linter autofixes
asergunov Nov 29, 2025
ace6444
Refactor node ID naming for consistency and clarity
asergunov Nov 29, 2025
6d5bd4c
fix-fix
asergunov Nov 29, 2025
f6bc4a3
lint autoformat
asergunov Nov 29, 2025
e777d4a
linter formatting
asergunov Nov 29, 2025
5fabd1c
go linter fixed. all green
asergunov Nov 29, 2025
d5aa678
initial commit
asergunov Dec 1, 2025
e3209d5
add ginkgo tool to all mod, execute permissions for hack/generate-cod…
asergunov Dec 1, 2025
23d7142
Merge branch 'astef-prototype' into rvr-status-config-address-controller
asergunov Dec 1, 2025
3c93ed5
cleanup
asergunov Dec 1, 2025
c0efb01
Enhance RVR status config controller with improved logging and reconc…
asergunov Dec 1, 2025
0b3cec8
Implement validation rule for ReplicatedVolumeReplica ownerReferences…
asergunov Dec 1, 2025
f89c9b3
Enhance ReplicatedVolumeReplica address configuration logic and condi…
asergunov Dec 1, 2025
7cdf859
Refactor port parsing and enhance logging in RVR status config contro…
asergunov Dec 1, 2025
1194d63
Refactor condition handling in RVR reconciler for improved clarity
asergunov Dec 1, 2025
625ee4d
Refactor RVR reconciler for improved address configuration logic
asergunov Dec 1, 2025
1df2ddb
spec
astef Dec 1, 2025
c79b25f
Merge commit 'e3209d591f631e80124f5e8406b11e34263119bc' into astef-pr…
astef Dec 1, 2025
84679ce
spec changes
astef Dec 1, 2025
91331f8
fix build
asergunov Dec 1, 2025
9bc93a1
fixate progress
astef Dec 1, 2025
ed29b92
Enhance RVR status configuration with new error handling and validation
asergunov Dec 1, 2025
6f96f8f
Refactor RVR reconciler tests for improved clarity and functionality
asergunov Dec 1, 2025
2f6a46c
Refactor RVR reconciler to improve port reuse logic and enhance test …
asergunov Dec 1, 2025
59c7db3
Refactor RVR status config address controller and add unit tests
asergunov Dec 2, 2025
5661ef9
Update unit tests for RVR status config address handlers
asergunov Dec 2, 2025
a77f36e
Update unit tests for RVR status config address handlers
asergunov Dec 2, 2025
67e1267
Merge remote-tracking branch 'origin/astef-prototype' into rvr-status…
asergunov Dec 2, 2025
9d28210
Remove PR_DESCRIPTION.md file detailing the RVR status config address…
asergunov Dec 2, 2025
33861a1
shared secret updates
astef Dec 2, 2025
84d064d
fixate progress
astef Dec 2, 2025
3990898
temp
astef Dec 2, 2025
75d9548
go get -t -u ./... && go mod tidy
astef Dec 2, 2025
a7b1aa9
rename rv.status.config -> rv.status.drbd.config
astef Dec 2, 2025
6fa8595
"drbd-" controllers
astef Dec 2, 2025
2ad2ab0
Merge remote-tracking branch 'origin/astef-prototype' into rvr-status…
asergunov Dec 3, 2025
cc9e30b
Refactor error handling and update test assertions for RVR status con…
asergunov Dec 3, 2025
0be518f
Update fake client in RVR reconciler tests to support additional stat…
asergunov Dec 3, 2025
f577f56
Delete api/v1alpha3/replicated_volume_replica.go.orig
asergunov Dec 3, 2025
f0d5bef
Add TODOs for security context checks in YAML templates
asergunov Dec 3, 2025
ab57593
Refine TODO comments for security context and RBAC checks
asergunov Dec 3, 2025
508ac21
Update linting comments in YAML templates for security context and RB…
asergunov Dec 3, 2025
d8024e7
Update linting comments in YAML templates to use dmtlint-disable
asergunov Dec 3, 2025
531bb8e
Enhance linting configuration in YAML templates
asergunov Dec 3, 2025
12f8efd
Merge pull request #359 from deckhouse/dmt-lint-disable-checks
asergunov Dec 3, 2025
263c5d2
Merge remote-tracking branch 'origin/astef-prototype' into rvr-status…
asergunov Dec 3, 2025
d3e0202
Add license header to rvr_status_config_address_suite_test.go
asergunov Dec 3, 2025
00d9cf6
Refactor DRBD configuration handling in agent and controller
asergunov Dec 3, 2025
2f36126
Rename cluster package to config
asergunov Dec 3, 2025
1a00d05
fixate progress
astef Dec 3, 2025
e75b66c
fixate progress
astef Dec 3, 2025
437b052
Add RVR Status Config Peers Controller (#340)
asergunov Dec 3, 2025
b89a702
crd updates
astef Dec 4, 2025
8a0c405
regenrate crd
astef Dec 4, 2025
dc9ae8a
rename to device minor
astef Dec 4, 2025
337e81b
Merge remote-tracking branch 'origin/astef-prototype' into rvr-status…
asergunov Dec 4, 2025
4cf3dcd
rvr-gc-controller
astef Dec 4, 2025
c1427b5
drbd-config updates
astef Dec 4, 2025
cbb3e82
[controller] Implement rv-status-config-device-minor-controller (#346)
IvanOgurchenok Dec 4, 2025
8f03126
Add port validation method to DRBDConfig and refactor RVR status hand…
asergunov Dec 5, 2025
4a13402
Enhance RVR status handling by initializing Conditions and simplifyin…
asergunov Dec 5, 2025
0e1154b
Refactor RVR reconciler tests for clarity and consistency
asergunov Dec 5, 2025
39b0d8d
go lint
asergunov Dec 5, 2025
31cf9b2
Merge pull request #357 from deckhouse/rvr-status-config-address-cont…
astef Dec 5, 2025
3879983
[controller] Implement rvr-diskful-count-controller (#342)
krpsh123 Dec 5, 2025
a0e1236
ReplicatedVolume Status Config Quorum Controller (#356)
asergunov Dec 5, 2025
9d49c0d
[controller] Implement rvr-status-config-node-id-controller (#341)
IvanOgurchenok Dec 6, 2025
102dd4d
fixate progress
astef Dec 7, 2025
7445c29
unify approach to configs, controller entrypoint
astef Dec 7, 2025
e484852
[controller] Implement rvr-volume-controller (#354)
krpsh123 Dec 9, 2025
e502f1a
Add RVR Owner Reference Controller Implementation
MrTomSawyer Dec 9, 2025
72f9da6
Remove RVR Owner Reference Controller and associated tests
MrTomSawyer Dec 9, 2025
dc83c2c
mark llv finalizer as "TODO"
krpsh123 Dec 9, 2025
dbf594d
add all controllers to wave2
krpsh123 Dec 9, 2025
98f3286
[controller] Astef prototype rv status config shared secret controlle…
IvanOgurchenok Dec 9, 2025
a7818fa
[controller] Implement rvr-tie-breaker-count (#358)
MrTomSawyer Dec 9, 2025
c2f1609
add dummy shared secret algorithm for testing purposes
astef Dec 9, 2025
f6f0fbd
fixed tests: now they will use indexes of Algs, for check logic, so r…
IvanOgurchenok Dec 10, 2025
3c419db
[controller] Implement rvr-quorum-and-publish-constrained-release-con…
MrTomSawyer Dec 11, 2025
240335c
rv deletion updates
astef Dec 11, 2025
841f539
cleanup specs
astef Dec 11, 2025
b467976
move resize to w2
astef Dec 11, 2025
6a1224b
[contoller] Implement rvr-access-count-controller (#374)
IvanOgurchenok Dec 11, 2025
c92e20f
cancel controller
astef Dec 11, 2025
c17d015
spec cleanup
astef Dec 11, 2025
40c127c
[controller] implement rvr-owner-reference-controller (#377)
MrTomSawyer Dec 11, 2025
5f9043e
[controller] Implement rv-publish-controller (#364)
MrTomSawyer Dec 12, 2025
ef42e85
some alpha version of condition specs
IvanOgurchenok Dec 9, 2025
8d0d66e
updated
IvanOgurchenok Dec 11, 2025
264e74a
Update spec_v1alpha3_rv_rvr_spec.md
IvanOgurchenok Dec 11, 2025
de3d369
expand some conditions
IvanOgurchenok Dec 11, 2025
ad32829
Update spec_v1alpha3_rv_rvr_spec.md
IvanOgurchenok Dec 11, 2025
143dc04
updated,renamed
IvanOgurchenok Dec 12, 2025
7d819b8
changes
IvanOgurchenok Dec 12, 2025
69beb04
updated
IvanOgurchenok Dec 12, 2025
a88bbaa
updates with last changes and discussions
IvanOgurchenok Dec 15, 2025
a1c158d
fix
IvanOgurchenok Dec 15, 2025
bd787a7
removed useless info
IvanOgurchenok Dec 15, 2025
aeb21ed
Merge pull request #397 from deckhouse/astef-prototype-v1alpha3-add-r…
astef Dec 16, 2025
10e818b
[controller] Improve rvr-volume-controller to add condition BackingVo…
krpsh123 Dec 16, 2025
2de264d
[controller] Implement drbd-config (#366)
astef Dec 16, 2025
8d04c2d
[contoller] Implement add rvr-status-conditions controller (#396)
IvanOgurchenok Dec 16, 2025
32e675d
Implement rv-finalizer-controller (#389)
astef Dec 16, 2025
3e554f0
Initialized -> DataInitialized
astef Dec 17, 2025
3046aa9
Implement rvr-finalizer-release-contoller (#391)
astef Dec 17, 2025
459f0ff
Implement rv-delete-propagation-controller (#390)
astef Dec 17, 2025
d036952
fix build (#412)
astef Dec 18, 2025
da9fb9b
[controller] rv finalizer - fix and tests (#409)
astef Dec 18, 2025
eaec4a2
[controller] [csi] [agent] Updated code to use v1alpha3 (#411)
astef Dec 18, 2025
22086ed
[agent] Implement status conditions from agent's perspective (#413)
astef Dec 22, 2025
95b9d80
[controller] Improve rv-publish-controller to add condition Published…
astef Dec 22, 2025
5b337f3
[controller] Implement rvr-scheduling-controller (#399)
MrTomSawyer Dec 22, 2025
fa6297d
[controller] [agent] implement external finalizers check (#406)
MrTomSawyer Dec 22, 2025
8bc6d6b
[controller] [agent] implement controller finalizer checks for Replic…
MrTomSawyer Dec 22, 2025
6b1e7cd
[controller] Remove the DiskfulReplicaCountReached condition (#408)
krpsh123 Dec 22, 2025
a0f817e
[controller] Implement rv-status-conditions controller for RVR condit…
IvanOgurchenok Dec 22, 2025
a07731c
Merge branch 'main' into astef-prototype
astef Dec 22, 2025
dbe9523
bash hack/go-mod-tidy
astef Dec 22, 2025
e96e32f
delete deprecated resources from v1alpha1
astef Dec 22, 2025
ab26ff4
fix crd
astef Dec 22, 2025
9143151
fix linter (SharedSecretAlg enum issue)
astef Dec 22, 2025
c791c54
fix crd linter
astef Dec 22, 2025
58925e7
Update IOReady condition description in spec
AleksZimin Dec 22, 2025
020f81b
migrate to automatic crd generation in v1alpha1
astef Dec 22, 2025
5e6ae85
move v1alpha3 to v1alpha1; migrate to controller-gen from deepcopy-ge…
astef Dec 22, 2025
ecaf798
rename v1alpha1->v1alpha3
astef Dec 22, 2025
3695c0b
downgrade to go 1.24.11
astef Dec 22, 2025
878f725
delete temp files
astef Dec 22, 2025
97c219f
refactor
astef Dec 22, 2025
a8575f0
[controller] fix rvr-scheduling-controller and other problems (#425)
AleksZimin Dec 23, 2025
9d04202
invoke additional scanner refresh for resource, when rvr updated in u…
astef Dec 23, 2025
0004b1a
[agent] fix for avoid uninitialyzed 1st diskfull peers. we should che…
IvanOgurchenok Dec 24, 2025
cc120b7
[controller] rv_status_config_quorum set now minimal qmr to 1. (#441)
IvanOgurchenok Dec 24, 2025
cb57978
rename rvr owner reference controller
astef Dec 24, 2025
4029d9c
reuse utils
astef Dec 24, 2025
217c714
reuse utils
astef Dec 24, 2025
8e8c79a
docs
astef Dec 24, 2025
21fab66
gofmt
astef Dec 24, 2025
660f8ef
fix package names
astef Dec 25, 2025
d294c9e
fix linter
astef Dec 25, 2025
3a59eb3
[controller][drdb-config] Use rv.Intialized instead of rvr.Status.DRB…
IvanOgurchenok Dec 25, 2025
7033e9d
[controller] rvr-scheduling-controller: best-effort Diskful schedulin…
AleksZimin Dec 25, 2025
536b31b
todo_prototype.sh
astef Dec 25, 2025
161321d
go mod tidy
astef Dec 25, 2025
0b30472
[controller] Fix rvr-tie-breaker-count-controller (#430)
astef Dec 26, 2025
bed7d46
[internal] megatest - stress testing tool for ReplicatedVolumes (#401)
krpsh123 Dec 26, 2025
72b1b9f
[controller] Use numeric RVR names (#473)
astef Dec 29, 2025
1023adb
[controller] use in-memory cache to synchronize device minors (#471)
astef Dec 29, 2025
9a154e7
[controller] Change to llv.spec.actualLVNameOnTheNode == rvrName (#477)
krpsh123 Dec 29, 2025
f72cf09
[agent] Add sync percent (#476)
IvanOgurchenok Dec 29, 2025
554e7f0
fix panic
astef Dec 29, 2025
3101474
fix panic - refactor into late-stage ResourceScanner global variable…
astef Dec 29, 2025
773c68b
[controller] Add labels to RV and RVR resources (#475)
IvanOgurchenok Dec 29, 2025
4083139
change cooldown parameters; do minor optimizations
astef Dec 29, 2025
15cc07e
[agent] Fix drbd_primary (#479)
astef Dec 29, 2025
a51d5e6
Merge pull request #482 from deckhouse/astef-optimize-scanner
dmgtn Dec 29, 2025
a3d2475
[controller] prefix LLV/LV names with rvr- and align RV/RVR name leng…
dmgtn Dec 30, 2025
d04db0d
[agent] Scanner should not drop batch items, when patch fails (#485)
astef Dec 30, 2025
6e92ffe
Refactor ReplicatedVolume and ReplicatedVolumeReplica to use 'attachT…
Dec 27, 2025
b944221
api: add ReplicatedVolumeAttachment CRD + pin controller-gen v0.20.0
Dec 27, 2025
d7448ba
Introduce rv-attach-controller to manage desiredAttachTo and handle a…
Dec 28, 2025
09f7f25
Enhance rv-attach-controller with index registration and optimized vo…
Dec 28, 2025
cc1f967
Enhance rv-attach-controller by adding predicates for ReplicatedVolum…
Dec 28, 2025
cd678bd
Refactor ReplicatedVolumeAttachment phases to use constants for statu…
Dec 28, 2025
543fad9
Refactor ReplicatedVolumeAttachment conditions to enhance clarity and…
Dec 28, 2025
bb88ead
Enhance rv-attach-controller by configuring the maximum concurrent re…
Dec 28, 2025
0201feb
Refactor comments in rv_attach_controller reconciler for clarity and …
Dec 28, 2025
720b817
chore: generate CRDs without pinning controller-gen in api/go.mod
Dec 29, 2025
e83557e
Move the IndexFieldRVAByReplicatedVolumeName constant from api/v1alph…
Dec 29, 2025
17c59ab
Prevent rv-attach-controller from requesting Primary on new Replicate…
Dec 29, 2025
76f3d78
Merge pull request #469 from deckhouse/astef-prototype-attach-controller
dmgtn Dec 30, 2025
d45ed5d
use rvr.name as a filename
astef Dec 30, 2025
768a37f
Merge pull request #494 from deckhouse/astef-drbd-config-filenames
dmgtn Dec 31, 2025
89021c1
Implement indexing for ReplicatedVolumeReplica by replicatedVolumeName
Dec 31, 2025
2f9f672
[controller] Introduce rv-controller: RV metadata + deviceMinor alloc…
Jan 1, 2026
e6d77ce
refactor(api): rename status.conditions constants and add Cursor nami…
Jan 2, 2026
1e8dfa1
[dev] Add Cursor Go coding/testing rules
Jan 2, 2026
0e31413
[api] Reorganize v1alpha1 types and conditions
Jan 2, 2026
67e1072
[tooling] Add direnv caches and migrate Cursor rules to .mdc
Jan 2, 2026
87fff30
[controller] Type-safe device minor allocation
Jan 2, 2026
9069534
[api] Add objutilv1 helpers and migrate usages from v1alpha1
Jan 2, 2026
a985a6e
[controller] Introduce reconciliation flow and refactor RV controller
Jan 3, 2026
f74112d
[internal] Encapsulate flow.Outcome and extend objutilv1 helpers
Jan 4, 2026
1335e25
[dev] Clarify controller.go wiring rules and commit sign-off policy
Jan 4, 2026
afb3842
[controller] Refine ReplicatedVolume update predicate
Jan 4, 2026
73373c3
[reconciliation/flow] Track changes and optimistic-lock requirement i…
Jan 4, 2026
0c382f1
[rules] Require commit messages to be output in a code block
Jan 4, 2026
2137cbd
[dev] Document controller reconcile helper contracts; add flow.Outcom…
Jan 4, 2026
598ec32
[docs] Expand controller ReconcileHelper guidelines
Jan 5, 2026
223b150
[rules] Refine controller reconciliation guide
Jan 5, 2026
fe0a70c
[dev] Refine controller reconciliation rules for error context
Jan 5, 2026
712aa45
[flow] Add phase context helpers and Outcome.OnErrorf
Jan 5, 2026
e61f9fa
[docs] Clarify flow.Outcome usage in reconcile helpers
Jan 5, 2026
ae6be19
[rules] Add controller terminology and flow usage rules
Jan 5, 2026
c4f2967
[rules] Refine controller rule docs structure and terminology
Jan 6, 2026
de8dfb0
[flow] Validate phase kv pairs and stabilize error context
Jan 6, 2026
68f535e
[flow] Log phase errors once; remove ContinueErr
Jan 6, 2026
da43af7
[rules] Normalize controller docs terminology and formatting
Jan 6, 2026
54a6d16
[controller] Refactor RV reconciler patching and error propagation
Jan 7, 2026
5fc978d
[controller] Inline storageClass label sync for RV and drop API helpers
Jan 7, 2026
e7fa7f8
[controller] Refactor RV device-minor allocation and idpool API
Jan 8, 2026
4ba7daa
[controller] Rename IsUpToDate helpers to IsInSync
Jan 8, 2026
e60a40b
[controller] RV reconciler: treat NotFound as deleted and normalize n…
Jan 8, 2026
05946b9
[cursor] Extend controller rules globs to rv_attach_controller
Jan 9, 2026
6dd195d
refactor: move isSyncingState to API layer, use parsed DRBD status (#…
IvanOgurchenok Jan 12, 2026
40b9cb5
[agent] Optimize predicates in drbd-config (#487)
astef Jan 12, 2026
0a4bfa4
[megatest] Adapt tests for ReplicatedVolumeAttachment (#496)
krpsh123 Jan 12, 2026
f40c804
[cursor] Add RFC-style writing rules for .mdc documents
Jan 12, 2026
7fede95
[rules] Split predicate rules into predicate.go and add GetReconcileH…
Jan 12, 2026
7cebad9
[rules] Normalize .mdc frontmatter and centralize RFC-style conventions
Jan 12, 2026
92ca3d2
[rules] Align controller rule docs with RFC keyword formatting
Jan 12, 2026
5660f63
[rules] Define API short kind names for controller helper/predicate n…
Jan 12, 2026
7e9ca2c
[rules] Document `reconciler.go` layout and helper ordering conventions
Jan 12, 2026
66ef1e3
[rules] Add controller reconciliation rules for optional scalars and …
Jan 12, 2026
5882b5c
[rules] Document optional scalar fields as `*T` across API and reconc…
Jan 12, 2026
3c7cb0c
[rules] Add split-client determinism guidance to reconciliation docs
Jan 12, 2026
8a77d79
[flow] Introduce typed flow scopes for reconcile/ensure/steps
Jan 16, 2026
7c9f8db
Merge branch 'astef-prototype' into astef-prototype-rv-controller
Jan 16, 2026
2f2262e
[controller] Preserve deviceMinor on pool errors
Jan 16, 2026
d999da2
[rules] Refactor flow API: split Outcome into ReconcileOutcome and En…
Jan 16, 2026
77d3b5e
[cursor-rules] Improve controller reconcile helper documentation
Jan 16, 2026
e76bc15
[ci] Add all image modules to go.work and fix internal dependency
Jan 16, 2026
a774ae1
Merge pull request #495 from deckhouse/astef-prototype-rv-controller
dmgtn Jan 16, 2026
9ee679a
Fix problems in flow (#507)
astef Jan 16, 2026
163706f
Run "go work sync" (#508)
astef Jan 16, 2026
a227681
go mod tidy (#509)
astef Jan 16, 2026
1923e0d
[api,controller] Add eligible nodes tracking and configuration rollout
Jan 17, 2026
e98fe47
[rules] Add controller rules reference to repo-wide.mdc
Jan 17, 2026
feba810
[rules] Add API development section to repo-wide rules
Jan 17, 2026
7608ebe
[controller] Implement rsc_controller reconciliation logic
Jan 18, 2026
cac6a9c
[controller] Use rsc.status.configuration instead of rsc.spec in node…
Jan 18, 2026
d4931d5
API contracts for drbdr (#504)
astef Jan 18, 2026
9c981d1
[api] Rename RSC conditions and strategies for clarity
Jan 18, 2026
9182936
Merge branch 'astef-prototype' into astef-prototype-new-controller
Jan 18, 2026
34586dc
[controller] Refactor flow API and rename RSC/RV conditions
Jan 18, 2026
7325e0b
[controller] Protect agent label on nodes with DRBDResources
Jan 18, 2026
d333c61
Merge pull request #510 from deckhouse/astef-prototype-new-controller
AleksZimin Jan 19, 2026
164bbd1
[rules] Add kubebuilder markers rule for gofmt smart quotes issue (#511)
IvanOgurchenok Jan 19, 2026
36f49a0
rewrite valdation rule to avoid gofmt bug (#512)
astef Jan 19, 2026
d4f606e
[agent] Add dmsetup utility to agent image (#513)
krpsh123 Jan 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 17 additions & 0 deletions .cursor/rules/api-codegen.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
description: API codegen rules for kubebuilder/controller-gen and generated files hygiene. Apply when adding/modifying API types or kubebuilder markers under api/v*/, and when deciding whether regeneration is required. Apply when editing relevant files, and when reasoning/planning/answering questions where this rule could influence code decisions (even if matching files are not currently open).
globs: api/v*/**/*.go
alwaysApply: false
---

- Kubebuilder markers & API changes (MUST):
- If I add a new API object/type or modify an existing one in `api/` (especially changes to `// +kubebuilder:*` markers, validation markers, printcolumns, subresources, etc.), I MUST run code generation and include the regenerated outputs in the same change.
- In this repo, run generation from the repository root:
- `bash hack/generate_code.sh`
- If I am intentionally doing an **API-only refactor stage** where changes outside `api/` are temporarily forbidden/undesired (e.g. the rest of the repo is not yet refactored and will not compile), then:
- It is acceptable to **defer CRD regeneration** (outputs under `crds/`) until the stage when cross-repo refactor is allowed.
- I MUST still keep `api/v1alpha1` internally consistent and compilable; prefer running **object/deepcopy generation only** when possible, instead of editing generated files by hand.

- Generated files (MUST NOT edit by hand):
- Do NOT edit `zz_generated*` files (e.g. `api/v1alpha1/zz_generated.deepcopy.go`) manually.
- If a generated file needs to change, update the source types/markers and re-run generation instead.
56 changes: 56 additions & 0 deletions .cursor/rules/api-conditions.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
description: API condition Type/Reason constants naming, ordering, comments, and stability rules. Apply when editing api/v*/**/*_conditions.go, and when deciding how to name/add conditions for API objects. Apply when editing relevant files, and when reasoning/planning/answering questions where this rule could influence code decisions (even if matching files are not currently open).
globs: api/v*/**/*_conditions.go
alwaysApply: false
---

- Condition constants naming:
- Every API object `Status` MUST expose `.status.conditions` (`[]metav1.Condition`) (see `types_rules.mdc`).
- Any API object that has at least one standardized/used condition MUST have its own condition type/reason constants scoped by object name.
- If the API type exposes `.status.conditions` but there are **no** standardized/used conditions yet:
- The `Conditions` field MUST remain in the API (it is part of the contract).
- The `<objprefix>_conditions.go` file MAY be absent.
- Do NOT create placeholder/empty condition constants “just in case”.
- Current API types that expose `.status.conditions` in this repo:
- `ReplicatedVolume`
- `ReplicatedVolumeReplica`
- `ReplicatedVolumeAttachment`
- `ReplicatedStorageClass`
- `ReplicatedStoragePool`

- Condition Type constants MUST be named:
- `<ObjName>Cond<CondTypeName>Type`
- `CondTypeName` MUST match the string value of `.Type`.
- Examples:
- `ReplicatedVolumeCondIOReadyType = "IOReady"`
- `ReplicatedVolumeReplicaCondDataInitializedType = "DataInitialized"`
- `ReplicatedVolumeAttachmentCondReplicaIOReadyType = "ReplicaIOReady"`

- Condition Reason constants MUST be named:
- `<ObjName>Cond<CondTypeName>Reason<ReasonName>`
- `CondTypeName` MUST match the string value of the condition type (the `.Type` string).
- `ReasonName` MUST match the string value of `.Reason`.
- Examples:
- `ReplicatedVolumeReplicaCondScheduledReasonReplicaScheduled = "ReplicaScheduled"`
- `ReplicatedVolumeCondQuorumReasonQuorumLost = "QuorumLost"`
- `ReplicatedVolumeAttachmentCondAttachedReasonSettingPrimary = "SettingPrimary"`

- Conditions grouping (MUST):
- Keep each condition type and **all of its reasons in a single `const (...)` block**.
- Conditions MUST be ordered alphabetically by condition type name within the file/package.
- Reasons within a condition MUST be ordered alphabetically by reason constant name.

- Conditions comments (MUST):
- Avoid controller-specific comments like “managed by X” in API packages.
- Add short English docs: what the condition represents and what the reasons mean.

- Value stability (MUST):
- Do NOT change string values of `.Type` and `.Reason` constants.
- Only rename Go identifiers when reorganizing/clarifying.

- Scoping & duplication (MUST):
- Do NOT use generic `ConditionType*` / `Reason*` constants.
- If the same reason string is used by multiple conditions, create separate constants per condition type, even if the string is identical.
- Example: `"NodeNotReady"`:
- `ReplicatedVolumeReplicaCondOnlineReasonNodeNotReady = "NodeNotReady"`
- `ReplicatedVolumeReplicaCondIOReadyReasonNodeNotReady = "NodeNotReady"`
21 changes: 21 additions & 0 deletions .cursor/rules/api-file-structure.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
description: API package conventions: object prefixes and per-object/common file naming rules under api/. Apply when creating/renaming/editing Go files under api/v*/, and when deciding where API code should live. Apply when editing relevant files, and when reasoning/planning/answering questions where this rule could influence code decisions (even if matching files are not currently open).
globs: api/v*/**/*.go
alwaysApply: false
---

- Object prefixes (MUST):
- Use short prefixes: `rv`, `rvr`, `rva`, `rsc`, `rsp`.

- File naming per object (MUST):
- `<objprefix>_types.go`: API types (kubebuilder tags), object/spec/status structs, adapters for interfaces (e.g. GetConditions/SetConditions) and tightly coupled constants/types and pure set/get/has helpers (no I/O, no external context).
- `<objprefix>_conditions.go`: condition Type/Reason constants for the object.
- MAY be absent if the API object exposes `.status.conditions` but there are no standardized/used conditions yet (do not create empty placeholder constants).
- `<objprefix>_custom_logic_that_should_not_be_here.go`: non-trivial/domain logic helpers (everything that does not fit `*_types.go`).

- Common file naming (MUST):
- `common_types.go`: shared types/enums/constants for the API package.
- `common_helpers.go`: shared pure helpers used across API types.
- `labels.go`: well-known label keys (constants).
- `finalizers.go`: module finalizer constants.
- `register.go`: scheme registration.
108 changes: 108 additions & 0 deletions .cursor/rules/api-kubebuilder-markers.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
description: Kubebuilder marker hygiene rules for CEL expressions, gofmt smart quote avoidance, and typographic character detection. Apply when writing or editing kubebuilder markers (especially XValidation with CEL), when reviewing API types under api/v*/, and when debugging unexpected character transformations in comments. Apply when editing relevant files, and when reasoning/planning/answering questions where this rule could influence code decisions (even if matching files are not currently open).
globs: api/v*/**/*.go
alwaysApply: true
---

Normative keywords used in this document are defined in `rfc-like-mdc.mdc`.

# Kubebuilder markers and gofmt smart quote issue

## Background

Since Go 1.19, `gofmt` reformats doc comments (comments immediately preceding `type`, `func`, `var`, `const` declarations) for improved documentation rendering. One side effect is that `gofmt` converts two consecutive single quotes (`''`) into a typographic RIGHT DOUBLE QUOTATION MARK (`"`, U+201D) in doc comments.

This behavior breaks kubebuilder `XValidation` markers that contain CEL expressions, because CEL uses single quotes for string literals (`'hello'`), and an empty string in CEL is `''`.

**References:**
- Stack Overflow: https://stackoverflow.com/questions/79734115/why-does-gofmt-replace-two-single-quotes-with-a-single-double-quote-in-my-go-com
- Go 1.19 release notes (comment formatting): https://go.dev/doc/go1.19#go-doc

## Empty string comparison in CEL (MUST)

When writing CEL expressions in `// +kubebuilder:validation:XValidation` markers, you MUST NOT use `''` (two single quotes) for empty string comparison.

**Bad (will be corrupted by gofmt):**
```go
// +kubebuilder:validation:XValidation:rule="self.field != ''",message="field must not be empty"
```

**After gofmt, this becomes (broken):**
```go
// +kubebuilder:validation:XValidation:rule="self.field != "",message="field must not be empty"
```

### Solution 1: Use `size()` function (RECOMMENDED)

Use the CEL `size()` function instead of comparing to an empty string:

| Instead of | Use |
|------------|-----|
| `field != ''` | `size(field) > 0` |
| `field == ''` | `size(field) == 0` |

**Good:**
```go
// +kubebuilder:validation:XValidation:rule="size(self.field) > 0",message="field must not be empty"
```

### Solution 2: Tab indentation (alternative)

Adding a tab character before the `+` in the marker causes `gofmt` to treat the line as a preformatted code block, which disables smart quote conversion:

```go
// +kubebuilder:validation:XValidation:rule="self.field != ''",message="field must not be empty"
```

Note: The tab character is between `//` and `+`. This approach is less preferred because it is subtle and easy to lose during edits.

## Detecting typographic characters (MUST)

When reviewing or debugging kubebuilder markers, you MUST check for typographic/Unicode characters that should not be present in code:

| Bad character | Unicode | Hex bytes (UTF-8) | Should be |
|---------------|---------|-------------------|-----------|
| `"` (left double) | U+201C | `e2 80 9c` | `"` (0x22) |
| `"` (right double) | U+201D | `e2 80 9d` | `"` (0x22) |
| `'` (left single) | U+2018 | `e2 80 98` | `'` (0x27) |
| `'` (right single) | U+2019 | `e2 80 99` | `'` (0x27) |
| `–` (en dash) | U+2013 | `e2 80 93` | `-` (0x2d) |
| `—` (em dash) | U+2014 | `e2 80 94` | `--` or `-` |

### How to detect

Use `xxd` or `hexdump` to inspect suspicious lines:

```bash
sed -n '<line>p' <file> | xxd | grep -E "e2 80"
```

If you see `e2 80 9c`, `e2 80 9d`, `e2 80 98`, or `e2 80 99` in the output, the file contains typographic quotes that will cause problems.

### How to fix

Replace typographic characters with their ASCII equivalents. For CEL empty string comparisons, use `size()` as described above.

## Sources of typographic characters

Typographic quotes are often introduced when:

1. **Copying from documents** (Word, Google Docs, PDF, Notion)
2. **Copying from web pages** with "smart quotes" enabled
3. **macOS keyboard** with "Use smart quotes and dashes" enabled
4. **AI assistants** (ChatGPT, Claude, etc.) that sometimes generate typographic quotes
5. **Running gofmt** on code that contains `''` in doc comments

## Validation timing

CEL expression syntax is NOT validated by:
- Go compiler (`go build`)
- `gofmt` / `gopls`
- `controller-gen`
- `golangci-lint`

CEL syntax errors are only detected at runtime when:
1. The CRD is applied to a Kubernetes cluster
2. A resource is created/updated and Kubernetes validates it against the CEL rule

Therefore, you SHOULD manually verify CEL expressions before committing.
42 changes: 42 additions & 0 deletions .cursor/rules/api-labels-and-finalizers.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
description: API naming rules for label keys (labels.go) and finalizer constants (finalizers.go): naming, value formats, and stability. Apply when editing api/v*/**/labels.go or api/v*/**/finalizers.go, and when deciding label/finalizer names/values. Apply when editing relevant files, and when reasoning/planning/answering questions where this rule could influence code decisions (even if matching files are not currently open).
globs: api/v*/**/finalizers.go,api/v*/**/labels.go
alwaysApply: false
---

## Label keys (`labels.go`)

- **Constant naming (MUST)**:
- Label key constants MUST end with `LabelKey`.
- Good: `ReplicatedVolumeLabelKey`, `NodeNameLabelKey`
- Bad: `LabelReplicatedVolume`, `NodeLabel`, `LabelNodeName`

- **Prefix constant (MUST)**:
- The label prefix constant MUST be private and named `labelPrefix` (unless there is a proven need to export it).
- The prefix value MUST be the module-scoped prefix:
- `sds-replicated-volume.deckhouse.io/`

- **Value format (MUST)**:
- Label key values MUST be built as `labelPrefix + "<suffix>"`.
- The `<suffix>` part MUST be lowercase-kebab-case, without repeating the module name.
- Good: `labelPrefix + "replicated-volume"`
- Bad: `labelPrefix + "sds-replicated-volume-replicated-volume"`

- **Layout (MUST)**:
- Keep all exported `...LabelKey` constants in a single `const (...)` block.
- Avoid commented-out placeholder constants; prefer adding constants only when actually needed.

## Finalizers (`finalizers.go`)

- **Constant naming (MUST)**:
- Finalizer constants MUST end with `Finalizer`.
- Good: `ControllerFinalizer`, `AgentFinalizer`
- Bad: `FinalizerController`, `ControllerFinalizerName`

- **Value format (MUST)**:
- Finalizer values MUST be module-scoped and stable:
- `sds-replicated-volume.deckhouse.io/<component>`
- `<component>` MUST be lowercase and short (e.g. `controller`, `agent`).

- **Stability (MUST)**:
- Do NOT change existing finalizer string values (this would break cleanup semantics).
Loading