Skip to content

Fix two kuttl test races: multi-pod log read and pgbouncer certificate rotation - #4573

Open
ValClarkson wants to merge 3 commits into
CrunchyData:REL_5_8from
ValClarkson:fix/kuttl-backup-standby-and-pgbouncer-cert-races-rel-5-8
Open

ValClarkson wants to merge 3 commits into
CrunchyData:REL_5_8from
ValClarkson:fix/kuttl-backup-standby-and-pgbouncer-cert-races-rel-5-8

Conversation

@ValClarkson

Copy link
Copy Markdown
Contributor

Backport of #4570 to REL_5_8.

  • pgbackrest-backup-standby: kubectl get pods -o name returns one line per
    pod, which fails kubectl logs with "arguments in resource/name form may not
    have more than one slash". Select a single pod and move the check into
    01-assert.yaml so kuttl retries it.
  • pgbouncer: step 12 accepted the first Loaded line in the log, which was
    usually its own wipe's reload rather than the rotation. Wait for the
    regenerated certificate.

Test-only; no product code changes.

The replica-create backup Job is meant to fail, so Kubernetes replaces
its Pod and several Pods carry the pgbackrest-backup=replica-create
label by the time step 01 runs. `kubectl get pods -o name` returned all
of them as one newline-joined string, and passing that to `kubectl logs`
failed with "arguments in resource/name form may not have more than one
slash". The log read came back empty and the step reported "did not find
expected standby cluster error", which had nothing to do with standby
clusters.

Some of those Pods also exit on the pgBackRest configuration hash
comparison before a backup runs, so their logs cannot contain the
expected error even when nothing is wrong. Iterate over every matching
Pod, retry the lookup and the log read together rather than reading once,
and print each Pod's exit code and logs when the error is not found.
Step 12 wiped the stored PgBouncer certificate and then treated the
first 'Loaded' line from the pgbouncer-config sidecar as proof that the
regenerated certificate was live. That line can be the reload caused by
the wipe itself: PGO regenerates the certificate within a couple of
seconds, but kubelet needs considerably longer to propagate the updated
Secret into the pod's projected volume. When the wipe's own reload was
matched, step 13 read back the unchanged certificate and step 14 failed
with 'Certificate did not change!'.

Wait instead for the certificate mounted in the pod to differ from the
one served before the wipe. That is the condition that decides what step
13 reads, so matching it removes the race rather than narrowing it.
kuttl runs a TestStep's commands exactly once and only loops the assert
phase, so the retry helper in this file never retried; it printed a
message, slept five seconds and failed the step. Every other file in the
tree that uses that helper is a TestAssert.

Make this one an assert too so kuttl owns the retrying, and drop the
bounded shell loop that was standing in for it. Nesting a shell loop
inside a command kuttl already re-runs multiplies the two timeouts and
repeats the failure output on every attempt. The per-pod iteration stays,
since a single pass still has to check every Pod. Move the verbose log
dump into a collector, which kuttl runs once after the assert gives up
rather than on each attempt.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant