Commit ba2ce80
committed
Fix false positive "shrinking persistent volumes" error
The operator was incorrectly reporting PVC shrinking errors when the
capacity values were equal but represented in different formats.
Adopted CloudNativePG's pattern for PVC comparison:
- Use switch statement on Cmp() result for clarity
- Handle equal, shrink, and expand cases explicitly
- Improve error messages to show actual capacities
- Add debug logging for capacity comparisons
The Cmp() method already handles decimal comparison internally,
correctly comparing "10Gi" with "10737418240" (bytes).
Changes:
- internal/scaling/scaling.go: Switch statement comparison pattern
- internal/scaling/scaling_test.go: Updated test assertions
- controllers/reconcile_persistence_test.go: Updated test assertions
All tests passing (9/9 specs).
Fixes: #20231 parent e20d5f4 commit ba2ce80
File tree
3 files changed
+21
-7
lines changed- controllers
- internal/scaling
3 files changed
+21
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
54 | 68 | | |
55 | 69 | | |
56 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
0 commit comments