homelab: v0.3.1 — fix k8s db PG target (resolve CNPG primary pod, not the Service)
`k8s db <app>` (Postgres path) execed `pg-cluster-rw`, which is the CNPG read-write SERVICE, not a pod — so kubectl exec failed with `pods "pg-cluster-rw" not found`. The unit test only checked the plan; the verb was never fired at live state (the gap flagged in v0.2), so it shipped broken. Fix: the PG plan now carries a label selector (cnpg.io/instanceRole=primary) instead of a pod name, and k8s db resolves the actual primary POD via `kubectl get pod -l <selector>` before exec. MySQL path (real pod mysql-standalone-0) unchanged. Live-verified both paths (psql + mysql). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
90c944a265
commit
787ce4edfa
4 changed files with 25 additions and 6 deletions
|
|
@ -34,7 +34,9 @@ func TestK8sTargetObjectRef(t *testing.T) {
|
|||
|
||||
func TestPlanDBExecPostgresDefault(t *testing.T) {
|
||||
p := planDBExec("fire-planner", "", "SELECT 1", false)
|
||||
if p.ns != "dbaas" || p.pod != "pg-cluster-rw" || p.container != "postgres" {
|
||||
// pg-cluster-rw is a Service, so the PG plan resolves the primary POD by
|
||||
// label rather than naming an (un-exec-able) Service.
|
||||
if p.ns != "dbaas" || p.pod != "" || p.selector != "cnpg.io/instanceRole=primary" || p.container != "postgres" {
|
||||
t.Fatalf("unexpected pg target: %+v", p)
|
||||
}
|
||||
// db name defaults to the app; SQL passed via -tAc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue