From 8cec7b28b019b2eedf2ecb6a8d78ec674cc01ebf Mon Sep 17 00:00:00 2001 From: Subhash Khileri Date: Tue, 28 Apr 2026 16:09:53 +0530 Subject: [PATCH] fix: resilient namespace deletion in TeardownReporter with retry --- docs/.vitepress/config.ts | 2 +- docs/changelog.md | 8 +++++++- package.json | 2 +- src/playwright/teardown-reporter.ts | 17 +++++++++++++++-- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 7997a0e..69b6588 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -33,7 +33,7 @@ export default defineConfig({ { text: "Examples", link: "/examples/" }, { text: "Overlay Testing", link: "/overlay/" }, { - text: "v1.1.34", + text: "v1.1.35", items: [{ text: "Changelog", link: "/changelog" }], }, ], diff --git a/docs/changelog.md b/docs/changelog.md index 41a6393..a0ca4a2 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,7 +2,13 @@ All notable changes to this project will be documented in this file. -## [1.1.34] - Current +## [1.1.35] - Current + +### Fixed + +- **Resilient namespace deletion in TeardownReporter**: Retry once with 5s delay and catch errors to prevent cluster connectivity failures (e.g. DNS `EAI_AGAIN`) from crashing Playwright before it generates the HTML report. + +## [1.1.34] ### Added diff --git a/package.json b/package.json index 884f180..b014c29 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@red-hat-developer-hub/e2e-test-utils", - "version": "1.1.34", + "version": "1.1.35", "description": "Test utilities for RHDH E2E tests", "license": "Apache-2.0", "repository": { diff --git a/src/playwright/teardown-reporter.ts b/src/playwright/teardown-reporter.ts index 2f71029..a62edf5 100644 --- a/src/playwright/teardown-reporter.ts +++ b/src/playwright/teardown-reporter.ts @@ -117,13 +117,26 @@ export default class TeardownReporter implements Reporter { } } - // Delete namespaces only in CI + // Retry + catch to avoid crashing Playwright if the cluster becomes unreachable. + const maxAttempts = 2; if (process.env.CI === "true") { for (const ns of namespaces) { console.log( `[TeardownReporter] Deleting namespace "${ns}" (project: ${projectName})`, ); - await k8sClient.deleteNamespace(ns); + for (let attempt = 1; attempt <= maxAttempts; attempt++) { + try { + await k8sClient.deleteNamespace(ns); + break; + } catch (error) { + console.error( + `[TeardownReporter] Failed to delete namespace "${ns}" (attempt ${attempt}/${maxAttempts}):`, + error, + ); + if (attempt < maxAttempts) + await new Promise((r) => setTimeout(r, 5000)); + } + } } } }