feat: collect kube pod/node describes, namespace events, and object dumps - #872
Conversation
…umps Container logs alone often miss failures under restartPolicy: Never + backoffLimit: 0 (ImagePullBackOff, FailedScheduling, OOMKilled), and the namespace is deleted at cleanup before anyone can look. Add kubectl describe for pods/nodes/jobs/services/secrets, plus namespace events and get-all, archived alongside existing logs so they survive teardown. Also consolidate the previously duplicated per-pod log collection loop in kube_cleanup() and rescue_engine_logs() into shared collect_namespace_diagnostics() and collect_pod_diagnostics() helpers, following the pattern remotehosts.py already uses for collect_podman_log()/collect_chroot_log() (return success/failure, let cleanup gate destructive teardown on it, let rescue discard it) -- this was going to get worse with each new collection type added to two duplicated copies instead of one. Secrets use `describe`, never `-o yaml`, so pull credentials never land in the run archive. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
PR Review: rickshaw#872 — feat: collect kube pod/node describes, namespace events, and object dumpsSummary: This PR enhances Kubernetes endpoint diagnostic collection by archiving Bugs
Issues
Documentation
File Coverage
Limitations
VerdictRequest changes — While consolidating log collection into helper functions is a great design improvement, treating failures of optional/diagnostic commands like |
…anup
Review feedback: describe node requires cluster-scoped RBAC that a
namespace-restricted user may not have, and this failure was propagating
into kube_cleanup()'s errors flag, blocking namespace deletion. Verified
empirically against a live cluster that empty jobs/services/secrets
describe calls return exit 0 (not the failure the review also flagged),
but decouple all of the new diagnostic types from cleanup-gating anyway --
only the pre-existing gating signals (container log failures, namespace
'get all' failures, and delete-command failures) should still block
cleanup. New diagnostics are best-effort by design.
Also fixes a pre-existing docstring typo in the two new functions
('rule then all' -> 'rule them all').
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Thanks for the review. Addressed in 84ba5ca: Fixed:
Investigated but not changed:
Re-tested both the normal cleanup path and the error/rescue path against the live cluster after these changes; namespace deletion completes cleanly with 0 occurrences of "Skipping namespace cleanup due to prior errors" and all diagnostic artifacts are still collected. |
atheurer
left a comment
There was a problem hiding this comment.
LGTM! The refactoring is clean, and decoupling the new diagnostic collections so they don't block cleanup under restricted RBAC handles the multi-tenant edge case nicely.
Summary
kubectl describecollection for pods, nodes, jobs, services, and secrets, plus namespaceget eventsandget all, archived to the run'sengine-logs/sysinfodirectories so this evidence survives namespace deletion at cleanup. Container logs alone miss a lot of failure modes here since the per-engine Job spec usesrestartPolicy: Never+backoffLimit: 0(no logs at all forImagePullBackOff/FailedScheduling/OOMKilled/FailedMount).describe, never-o yaml, so registry pull credentials never land in the run archive.kube_cleanup()andrescue_engine_logs()into two shared helpers,collect_namespace_diagnostics()andcollect_pod_diagnostics(), mirroring the pattern remotehosts.py already uses forcollect_podman_log()/collect_chroot_log()(return success/failure; cleanup gates destructive teardown on it, rescue discards it). The two collectors were deliberately kept separate in commit 8081e5c, but with several new diagnostic types landing in both, duplicating each addition twice was no longer worth it.Test plan
Ran against a live OpenShift cluster with
fio.kube.json, both the normal and error paths:<pod>.describe.txt.xz+<engine>.txt.xzinengine-logs/, andget-all.txt.xz/events.txt.xz/node-<name>.describe.txt.xz/jobs.describe.txt.xz/services.describe.txt.xz/secrets.describe.txt.xzinsysinfo/endpoint/<label>/, with real content in each, correct per-node dedup, and clean namespace deletion afterward.--dry-run=server), which failscreate_cs_pods()before any pod is ever created. Confirmed viaendpoint-stderrout.txt.xz:rescue_engine_logs()fired at the correct log level,collect_namespace_diagnostics()wroteget-all.txt.xz/events.txt.xzeven with zero pods, andcollect_pod_diagnostics()'s "no pods" guard logged and returned cleanly instead of crashing on a missingpodskey.python3 -m py_compileonkube.py🤖 Generated with Claude Code