feat(actions): Add cloudnativepg reload, restart, promote, suspend and resume actions#24192
Conversation
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
❌ Preview Environment deleted from BunnyshellAvailable commands (reply to this comment):
|
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
…ions Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
resource_customizations/postgresql.cnpg.io/Cluster/actions/testdata/cluster_restart.yaml
Show resolved
Hide resolved
resource_customizations/postgresql.cnpg.io/Cluster/actions/testdata/cluster_reload.yaml
Show resolved
Hide resolved
resource_customizations/postgresql.cnpg.io/Cluster/actions/testdata/cluster_promoting.yaml
Show resolved
Hide resolved
resource_customizations/postgresql.cnpg.io/Cluster/actions/testdata/cluster_promoting.yaml
Outdated
Show resolved
Hide resolved
resource_customizations/postgresql.cnpg.io/Cluster/testdata/cluster_promoting.yaml
Show resolved
Hide resolved
resource_customizations/postgresql.cnpg.io/Cluster/testdata/cluster_reloaded.yaml
Show resolved
Hide resolved
resource_customizations/postgresql.cnpg.io/Cluster/testdata/cluster_restarted.yaml
Show resolved
Hide resolved
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #24192 +/- ##
==========================================
- Coverage 62.58% 62.58% -0.01%
==========================================
Files 352 352
Lines 49759 49759
==========================================
- Hits 31142 31141 -1
- Misses 15640 15641 +1
Partials 2977 2977 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Rouke Broersma <mobrockers@gmail.com>
blakepettersson
left a comment
There was a problem hiding this comment.
I don't have insights into cloudnativepg but from a healthcheck perspective it LGTM
|
@blakepettersson thanks! Do you want me to get someone from cloudnativepg to review this from their pov before this is merged? |
|
@rouke-broersma if you have/know someone that can chime in that'd be highly appreciated! If that's not (easily) possible I can still merge this PR |
|
@sxd since you contributed the original health check and you're a member of cnpg I think you would be most suited for reviewing this pr. If you have the time I would really appreciate it you could take a look! |
|
Hi @rouke-broersma |
|
Sorry for the delay! I took a quick view and I have some questions/observations: I'm going to try to do more practical test on this this week and I'll keep you posted!! Regards, |
|
Hi @sxd No worries, thanks for taking a look!
|
|
@sxd have you been able to test out the custom actions? :) |
There was a problem hiding this comment.
Pull request overview
This PR adds custom actions for CloudNativePG Cluster resources, enabling operational tasks like reload, restart, promote, suspend, and resume directly from ArgoCD. It also improves the test normalizer to use apiVersion group disambiguation to prevent Kind name collisions, and extends the health check to detect reconciliation suspension.
- Adds five new CloudNativePG Cluster actions (reload, restart, promote, suspend, resume) with conditional availability based on cluster state
- Refactors test normalizer from kind-only to group+kind-based resource identification
- Extends health check to detect and report suspended reconciliation state
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| util/lua/custom_actions_test.go | Refactors normalizer to use API group disambiguation; adds CloudNativePG Cluster normalization for action annotations |
| resource_customizations/postgresql.cnpg.io/Cluster/health.lua | Removes duplicate status entry; adds reconciliation suspension detection |
| resource_customizations/postgresql.cnpg.io/Cluster/health_test.yaml | Adds test case for suspended reconciliation state |
| resource_customizations/postgresql.cnpg.io/Cluster/actions/discovery.lua | Implements action discovery with conditional promotion based on healthy replicas |
| resource_customizations/postgresql.cnpg.io/Cluster/actions/*/action.lua | Implements reload, restart, promote, suspend, and resume actions |
| resource_customizations/postgresql.cnpg.io/Cluster/actions/action_test.yaml | Adds comprehensive action tests for all new CloudNativePG actions |
| resource_customizations/postgresql.cnpg.io/Cluster/actions/testdata/*.yaml | Provides test data for action validation |
| resource_customizations/postgresql.cnpg.io/Cluster/testdata/cluster_reconcile_suspended.yaml | Test data for health check with suspended reconciliation |
| docs/operator-manual/resource_actions_builtin.md | Documents the five new CloudNativePG Cluster actions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
resource_customizations/postgresql.cnpg.io/Cluster/actions/restart/action.lua
Outdated
Show resolved
Hide resolved
resource_customizations/postgresql.cnpg.io/Cluster/actions/discovery.lua
Outdated
Show resolved
Hide resolved
resource_customizations/postgresql.cnpg.io/Cluster/actions/promote/action.lua
Show resolved
Hide resolved
resource_customizations/postgresql.cnpg.io/Cluster/actions/resume/action.lua
Outdated
Show resolved
Hide resolved
resource_customizations/postgresql.cnpg.io/Cluster/actions/reload/action.lua
Outdated
Show resolved
Hide resolved
resource_customizations/postgresql.cnpg.io/Cluster/actions/suspend/action.lua
Outdated
Show resolved
Hide resolved
Signed-off-by: Rouke Broersma <rouke.broersma@infosupport.com>
12313c4 to
4d310c8
Compare
…hy instance as next primary Signed-off-by: Rouke Broersma <rouke.broersma@infosupport.com>
Signed-off-by: Rouke Broersma <rouke.broersma@infosupport.com>
|
@blakepettersson I've addressed the feedback by @sxd and there hasn't been any new feedback so I consider this ready to merge. We can always adjust later in a patch if necessary based on user feedback. Better to get it out there so we can get feedback from more people imo. |
|
Sorry @rouke-broersma I was able to test only half of it but it should be ok, will ask some users for more feedback on this |
|
@rouke-broersma sounds good to me! Thanks for your patience! |
…d resume actions (argoproj#24192) Signed-off-by: Rouke Broersma <mobrockers@gmail.com> Signed-off-by: Rouke Broersma <rouke.broersma@infosupport.com> Signed-off-by: hai.yue <hai.yue@ingka.com>
…d resume actions (argoproj#24192) Signed-off-by: Rouke Broersma <mobrockers@gmail.com> Signed-off-by: Rouke Broersma <rouke.broersma@infosupport.com>
…d resume actions (argoproj#24192) Signed-off-by: Rouke Broersma <mobrockers@gmail.com> Signed-off-by: Rouke Broersma <rouke.broersma@infosupport.com> Signed-off-by: rumstead <37445536+rumstead@users.noreply.github.com>
Improves custom action result normalization to check for apiVersion Group, this reduces the chance that a Kind with the same name but the wrong api group is normalized accidentally in resource actions tests.
Adds specific actions for cloudnativepg that trigger the operator to execute an operational task that should not be governed by gitops. The following tasks are added:
The cloudnativepg health check is extended to support detecting the reconciliation suspension
The promotion action is disabled if no healthy replicas are available to promote:
The promotion action is enabled if there are healthy replicas:
Before any promotion status:
During promotion status:
After promotion:
The reload action triggers the operation to reconciliate the cluster resources:
And the restart action triggers a rolling restart without a primary failover:
Checklist: