feat: cnpg support - #208
Conversation
WalkthroughCloudNativePG Cluster and Backup health customizations were added. Lua health-status normalization was centralized. Test discovery was updated, and fixture-based tests cover health, readiness, failure, suspension, and backup lifecycle states. ChangesCloudNativePG health
Sequence Diagram(s)sequenceDiagram
participant HealthTest
participant ExecuteHealthLua
participant ClusterHealthLua
participant BackupHealthLua
HealthTest->>ExecuteHealthLua: evaluate CloudNativePG fixture
ExecuteHealthLua->>ClusterHealthLua: evaluate Cluster health
ClusterHealthLua-->>ExecuteHealthLua: return cluster health result
ExecuteHealthLua->>BackupHealthLua: evaluate Backup health
BackupHealthLua-->>ExecuteHealthLua: return backup health result
ExecuteHealthLua-->>HealthTest: return normalized status
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/resource_customizations/postgresql.cnpg.io/Cluster/health.lua`:
- Around line 112-114: Update the failed-backup condition in the health
evaluation to remove the conditionIsStale(lastBackup) exclusion, so any
LastBackupSucceeded=False condition still triggers the warning unless the
existing BackupStarted, Degraded, or Suspended exceptions apply. Add a fixture
covering a current Ready=True condition alongside a stale failed-backup
condition.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 00972484-44fa-4f0a-8c85-7f0e8f31cc06
📒 Files selected for processing (24)
pkg/health/health_test.gopkg/lua/health_test.gopkg/lua/lua.gopkg/resource_customizations/postgresql.cnpg.io/Backup/health.luapkg/resource_customizations/postgresql.cnpg.io/Backup/health_test.yamlpkg/resource_customizations/postgresql.cnpg.io/Backup/testdata/completed.yamlpkg/resource_customizations/postgresql.cnpg.io/Backup/testdata/failed.yamlpkg/resource_customizations/postgresql.cnpg.io/Backup/testdata/finalizing.yamlpkg/resource_customizations/postgresql.cnpg.io/Backup/testdata/invalid.yamlpkg/resource_customizations/postgresql.cnpg.io/Backup/testdata/no_status.yamlpkg/resource_customizations/postgresql.cnpg.io/Backup/testdata/pending.yamlpkg/resource_customizations/postgresql.cnpg.io/Backup/testdata/running.yamlpkg/resource_customizations/postgresql.cnpg.io/Backup/testdata/unknown.yamlpkg/resource_customizations/postgresql.cnpg.io/Backup/testdata/wal_archiving_failing.yamlpkg/resource_customizations/postgresql.cnpg.io/Cluster/health.luapkg/resource_customizations/postgresql.cnpg.io/Cluster/health_test.yamlpkg/resource_customizations/postgresql.cnpg.io/Cluster/testdata/backup_started.yamlpkg/resource_customizations/postgresql.cnpg.io/Cluster/testdata/degraded.yamlpkg/resource_customizations/postgresql.cnpg.io/Cluster/testdata/healthy.yamlpkg/resource_customizations/postgresql.cnpg.io/Cluster/testdata/last_backup_failed.yamlpkg/resource_customizations/postgresql.cnpg.io/Cluster/testdata/no_status.yamlpkg/resource_customizations/postgresql.cnpg.io/Cluster/testdata/progressing.yamlpkg/resource_customizations/postgresql.cnpg.io/Cluster/testdata/stale_ready.yamlpkg/resource_customizations/postgresql.cnpg.io/Cluster/testdata/suspended.yaml
| local lastBackup = findCondition("LastBackupSucceeded") | ||
| if lastBackup ~= nil and lastBackup.status == "False" and lastBackup.reason ~= "BackupStarted" | ||
| and not conditionIsStale(lastBackup) and hs.status ~= "Degraded" and hs.status ~= "Suspended" then |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not ignore a failed last backup when its condition is stale.
Line 114 suppresses the warning when LastBackupSucceeded=False has an older observedGeneration. If Ready=True is current, the script returns Healthy instead. This violates the PR objective for a failed latest backup.
Remove not conditionIsStale(lastBackup) from this condition. Add a fixture with a current ready condition and a stale failed-backup condition.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pkg/resource_customizations/postgresql.cnpg.io/Cluster/health.lua` around
lines 112 - 114, Update the failed-backup condition in the health evaluation to
remove the conditionIsStale(lastBackup) exclusion, so any
LastBackupSucceeded=False condition still triggers the warning unless the
existing BackupStarted, Degraded, or Suspended exceptions apply. Add a fixture
covering a current Ready=True condition alongside a stale failed-backup
condition.
Fixes: #199
Summary by CodeRabbit
New Features
Tests