ci: clean TKE checkin env on failure#360
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the TKE “checkin regression” cleanup behavior in the merge-trigger-tke workflow so the environment is cleaned up whenever the Docker image build succeeded, even if downstream tests fail, while keeping trace collection/upload before namespace deletion and avoiding namespace recreation during cleanup.
Changes:
- Remove namespace recreation from the cleanup job, replacing it with a non-failing namespace check.
- Run the cleanup step under
always()(gated by successful image build) rather than requiring all test jobs to succeed. - Add a guard to skip cleanup work when the namespace does not exist.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if [ "$(kubectl get namespaces | grep -c mo-checkin-regression-${{ github.event.pull_request.number }})" -eq 0 ]; then | ||
| echo "namespace mo-checkin-regression-${{ github.event.pull_request.number }} does not exist, skip cleanup" | ||
| exit 0 | ||
| fi |
b0971df to
81d349b
Compare
|
Addressed the namespace check review: cleanup now uses |
| namespace="mo-checkin-regression-${{ github.event.pull_request.number }}" | ||
| if ! kubectl get namespace "$namespace" 2>/tmp/namespace-check.err; then | ||
| if grep -q "NotFound" /tmp/namespace-check.err; then | ||
| echo "namespace $namespace does not exist, skip cleanup" | ||
| exit 0 | ||
| fi | ||
| cat /tmp/namespace-check.err >&2 | ||
| exit 1 | ||
| fi |
81d349b to
38c7e99
Compare
|
Addressed the latest review as well: the namespace check no longer writes to a fixed /tmp path. It captures kubectl stderr in a local shell variable and only skips cleanup when the captured error contains NotFound; other errors still fail the step. |
|
✅ Review Complete The changes look solid and address the original issue well: Strengths:
Implementation Details:
Minor note:
Great job on improving the TKE cleanup robustness! |
Summary
Validation