Skip to content

CONSOLE-5196: Refresh admin auth mid-run to prevent session expiry cascade - #16877

Open
shahsahil264 wants to merge 1 commit into
openshift:mainfrom
shahsahil264:CONSOLE-5196-auth-refresh
Open

CONSOLE-5196: Refresh admin auth mid-run to prevent session expiry cascade#16877
shahsahil264 wants to merge 1 commit into
openshift:mainfrom
shahsahil264:CONSOLE-5196-auth-refresh

Conversation

@shahsahil264

@shahsahil264 shahsahil264 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Analysis / Root cause:

Playwright CI runs all ~300 e2e tests using a single storageState (saved OAuth session cookies) created once at the start of the run. The OpenShift OAuth session has a fixed TTL, and with 300+ tests running across 2 workers (~50 min total runtime), the session can expire mid-run — typically around test ~220 when dev-console tests begin.

When the session expires:

  1. warmupSPA navigates to / but the console backend rejects the stale cookie
  2. The browser is redirected to oauth-openshift.../oauth/authorize then auth/callback
  3. The page lands on the last-visited page (Topology) instead of a page with page-heading
  4. page-heading is never found so the test fails
  5. The storageState file on disk is never updated, so every subsequent test loads the same stale cookies causing a cascade failure (10-20+ tests fail in a row)

This has caused repeated CI failures across multiple migration PRs (#16741, #16751), where all dev-console, topology, and webterminal tests fail with identical warmupSPA OAuth redirect errors — despite the test code being correct (proven by passing on runs where auth holds).

Solution description:

Chain an auth refresh project between every test package so each package starts with a fresh OAuth session:

admin-auth → smoke → refresh-1 → console → refresh-2 → dev-console → refresh-3 → helm → ...

This serializes packages (each depends on the previous refresh) and inserts a lightweight admin-auth-refresh-N setup project before every package after the first. Each refresh re-runs the login flow and overwrites kubeadmin.json with a fresh session. Overhead is ~35s total (7 refreshes × ~5s each).

Changes:

  • playwright.config.ts: Replace flat packages.map() with packages.flatMap() that generates interleaved refresh projects. Extract shared setupDir and chromeAuth config to reduce duplication.
  • e2e/setup/admin-auth-refresh.setup.ts: New setup file that performs the same login as admin-auth.setup.ts to refresh the storageState. Supports SKIP_GLOBAL_SETUP, configurable credentials via OPENSHIFT_USERNAME / BRIDGE_KUBEADMIN_PASSWORD, and uses import.meta.dirname.

Screenshots / screen recording:
N/A (CI infrastructure change, no UI changes)

Test setup:
Tested locally against a live OCP 5.0 cluster. Verified:

  • admin-auth creates initial kubeadmin.json
  • admin-auth-refresh-N re-logs in and overwrites kubeadmin.json
  • dev-console tests run successfully with the refreshed session (10/10 passed, zero auth redirect failures)

Test cases:

  • CI run completes without auth expiry cascade in late test packages
  • All existing tests continue to pass (no behavioral change to test execution, only dependency ordering)

Browser conformance:
N/A (no UI changes)

Additional info:
This complements PR #16780 which reduced runtime by setting WORKERS=2. That fix brought runtime from ~2h to ~50min, but session expiry still occurs non-deterministically depending on the ephemeral cluster OAuth token lifetime. This PR eliminates the root cause by refreshing auth before every package, ensuring no single package runs with a stale session regardless of total suite runtime.

Summary by CodeRabbit

  • Tests
    • Improved browser test setup for authentication refresh scenarios.
    • Added consistent Chrome integration settings, including secure-connection handling and integration user-agent configuration.
    • Updated test sequencing so authentication state is refreshed and reused reliably across packages.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 29, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@shahsahil264: This pull request references CONSOLE-5196 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "5.0.0" version, but no target version was set.

Details

In response to this:

…scade

Auth storageState is created once at test start. On CI with 300+ tests and 2 workers (~50 min runtime), the OAuth session can expire mid-run, causing every subsequent test to fail with an OAuth redirect in warmupSPA.

Split test packages into early (smoke, console) and late (dev-console, helm, knative, olm, topology, webterminal) phases with a re-login between them. The admin-auth-refresh project re-authenticates and overwrites kubeadmin.json before late packages start.

Analysis / Root cause:

Solution description:

Screenshots / screen recording:

Test setup:

Test cases:

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:

Reviewers and assignees:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 29, 2026
@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The Playwright configuration adds shared authentication setup settings and generates chained admin-auth-refresh projects between package projects. Each applicable package project depends on its refresh project and retains the admin storage state.

Changes

Playwright authentication project chaining

Layer / File(s) Summary
Shared auth-refresh setup
frontend/playwright.config.ts
The configuration adds setupDir and Chrome settings with the integration user agent and ignored HTTPS errors.
Chained package projects
frontend/playwright.config.ts
Project generation inserts admin-auth-refresh-${i} projects. Refresh projects depend on the preceding project, and package projects depend on the refresh project when applicable while retaining adminStorageState.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: rhamilto, jhadvig

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Title check ✅ Passed The title includes the Jira issue and clearly describes refreshing admin authentication to prevent session expiry failures.
Description check ✅ Passed The description covers the root cause, solution, testing, test cases, and explains why screenshots and browser testing do not apply.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The patch changes only Playwright configuration; it adds deterministic project names and no Ginkgo It(), Describe(), Context(), or When() test titles.
Test Structure And Quality ✅ Passed Not applicable: HEAD changes only frontend/playwright.config.ts; no Ginkgo or Go test code is added or modified.
Microshift Test Compatibility ✅ Passed The pull request changes only frontend/playwright.config.ts and adds no Ginkgo e2e tests or OpenShift API usage; the MicroShift compatibility check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR changes only frontend/playwright.config.ts and adds no Ginkgo e2e tests or Go test declarations, so the SNO compatibility check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed The commit changes only frontend/playwright.config.ts and adds no manifests, operators, controllers, or scheduling constraints.
Ote Binary Stdout Contract ✅ Passed The PR changes only frontend/playwright.config.ts; the diff contains no OTE binary entry points or process-level stdout writes.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The commit changes only frontend/playwright.config.ts; it adds no Ginkgo tests or IPv4-specific or external-connectivity test code.
No-Weak-Crypto ✅ Passed PR introduces no weak crypto algorithms (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or insecure secret comparisons. Changes are limited to Playwright configuration fo...
Container-Privileges ✅ Passed The commit changes only Playwright project ordering and auth setup. It adds no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, root, or allowPrivilegeEscalation setting.
No-Sensitive-Data-In-Logs ✅ Passed The PR changes only Playwright project configuration; added auth-refresh projects contain no console, logger, stdout, or credential output, and the reused login setup only fills and saves storage s...
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shahsahil264
Once this PR has been reviewed and has the lgtm label, please assign vojtechszocs for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@shahsahil264
shahsahil264 marked this pull request as ready for review July 29, 2026 14:48
@shahsahil264

Copy link
Copy Markdown
Contributor Author

/pipeline required

@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 29, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@shahsahil264

Copy link
Copy Markdown
Contributor Author

@rhamilto Can you PTAL!
Thanks

@openshift-ci
openshift-ci Bot requested review from jhadvig and rhamilto July 29, 2026 14:53
@shahsahil264 shahsahil264 changed the title CONSOLE-5196: Refresh admin auth mid-run to prevent session expiry ca… CONSOLE-5196: Refresh admin auth mid-run to prevent session expiry cascade Jul 29, 2026
@rhamilto

Copy link
Copy Markdown
Member

/test e2e-playwright

@shahsahil264

Copy link
Copy Markdown
Contributor Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@shahsahil264

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@shahsahil264

Copy link
Copy Markdown
Contributor Author

/retest

@shahsahil264

Copy link
Copy Markdown
Contributor Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@shahsahil264

Copy link
Copy Markdown
Contributor Author

/retest

2 similar comments
@shahsahil264

Copy link
Copy Markdown
Contributor Author

/retest

@TheRealJon

Copy link
Copy Markdown
Member

/retest

@fsgreco fsgreco left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the new admin-auth-refresh.setup.ts file is unnecessary; the refresh projects can point testMatch at admin-auth.setup.ts

Comment thread frontend/e2e/setup/admin-auth-refresh.setup.ts Outdated
…expiry

Auth storageState is created once at test start. On CI with 300+ tests
and 2 workers (~50 min runtime), the OAuth session can expire mid-run,
causing every subsequent test to fail with an OAuth redirect in warmupSPA.

Chain auth refresh projects between every package so each package starts
with a fresh token:

  admin-auth → smoke → refresh-1 → console → refresh-2 → dev-console → ...

Each refresh project reuses admin-auth.setup.ts (no new setup file needed).
Every package gets fresh auth regardless of how many tests any individual
package has. Scales automatically as packages are added. Overhead is
~35s total (7 refreshes × ~5s each).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shahsahil264
shahsahil264 force-pushed the CONSOLE-5196-auth-refresh branch from a940197 to 3b950fb Compare July 31, 2026 14:24
@shahsahil264

Copy link
Copy Markdown
Contributor Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/playwright.config.ts`:
- Around line 137-161: The package projects in the packages flatMap currently
form a sequential dependency chain through admin-auth-refresh-${i} and prevDep,
so an earlier failure skips later coverage. Remove inter-package dependencies
while preserving each package’s required auth setup, configure refresh projects
to run independently, and ensure failures are aggregated rather than blocking
subsequent packages. Add a CI test case with a failing test in a non-final
package and verify later package projects still execute.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c9e56c3d-226e-40ce-85f5-fa317b5897b3

📥 Commits

Reviewing files that changed from the base of the PR and between a940197 and 3b950fb.

📒 Files selected for processing (1)
  • frontend/playwright.config.ts

Comment on lines +137 to +161
...packages.flatMap((pkg, i) => {
const prevDep = i === 0 ? 'admin-auth' : packages[i - 1];
const refreshProject =
i > 0
? [
{
name: `admin-auth-refresh-${i}`,
testDir: setupDir,
testMatch: 'admin-auth.setup.ts',
dependencies: [prevDep],
use: { ...chromeAuth, launchOptions: { args: chromeArgs } },
},
]
: [];
return [
...refreshProject,
{
name: pkg,
testDir: path.resolve(__dirname, 'e2e', 'tests', pkg),
testIgnore: '**/developer/**',
dependencies: [i > 0 ? `admin-auth-refresh-${i}` : 'admin-auth'],
use: { ...chrome, storageState: adminStorageState },
},
];
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

printf '%s\n' '--- config outline ---'
ast-grep outline frontend/playwright.config.ts
printf '%s\n' '--- config lines ---'
sed -n '100,180p' frontend/playwright.config.ts
printf '%s\n' '--- related references ---'
rg -n --glob '!node_modules' 'admin-auth-refresh|admin-auth\.setup|playwright' frontend package.json .github 2>/dev/null | head -200

Repository: openshift/console

Length of output: 16744


🏁 Script executed:

printf '%s\n' '--- complete relevant config ---'
sed -n '1,175p' frontend/playwright.config.ts
printf '%s\n' '--- setup implementations ---'
sed -n '1,220p' frontend/e2e/setup/admin-auth.setup.ts
sed -n '1,180p' frontend/e2e/setup/login-helper.ts
printf '%s\n' '--- package and CI invocation context ---'
sed -n '1,70p' frontend/package.json
sed -n '150,190p' frontend/integration-tests/test-playwright-e2e.sh
rg -n --glob '!node_modules' 'test-playwright-admin|test-playwright-e2e|--max-failures|workers|fullyParallel|forbidOnly' .github frontend/config frontend 2>/dev/null | head -200

Repository: openshift/console

Length of output: 14647


🌐 Web query:

Playwright test projects dependencies dependent project runs when dependency test fails official documentation

💡 Result:

In Playwright, if a project dependency fails, the dependent projects are automatically skipped [1][2][3]. According to official Playwright documentation, dependencies are projects that must run and pass successfully before the tests in a dependent project can begin [1][2]. If any test within the dependency project fails, the dependent project will not be executed [1]. This behavior is designed to prevent tests from running in an environment that has not been correctly set up [2]. Currently, there is no native configuration option to allow dependent projects to proceed if a dependency fails [4][3]. Users have requested this functionality as a feature [4][3], but as of July 2026, the standard behavior remains that dependency failure results in the skipping of all dependent tests [1][2].

Citations:


🏁 Script executed:

python3 - <<'PY'
from pathlib import Path
import re

text = Path("frontend/playwright.config.ts").read_text()
packages = re.search(
    r"const packages = \[(.*?)\];", text, re.S
).group(1)
packages = re.findall(r"'([^']+)'", packages)

deps = {}
for i, package in enumerate(packages):
    refresh = f"admin-auth-refresh-{i}"
    if i > 0:
        deps[refresh] = [packages[i - 1]]
    deps[package] = [refresh if i > 0 else "admin-auth"]

# A dependency failure skips every transitive dependent project.
failed = {"console"}  # representative non-final package
skipped = set()
changed = True
while changed:
    changed = False
    for project, project_deps in deps.items():
        if project not in skipped and any(
            dep in failed or dep in skipped for dep in project_deps
        ):
            skipped.add(project)
            changed = True

print("package order:", packages)
print("dependencies:", deps)
print("failed project:", sorted(failed))
print("skipped projects:", sorted(skipped))
print("later packages skipped:", [
    package for package in packages[packages.index("console") + 1:]
    if package in skipped
])
PY

Repository: openshift/console

Length of output: 1167


Decouple package projects from the package dependency chain. admin-auth-refresh-${i} depends on the preceding package, and each later package depends on that refresh project. If a non-final package fails, Playwright skips its refresh project and all later packages. Run each package and refresh independently, then aggregate failures. Add a CI case with one failing test in a non-final package to ensure later package coverage runs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/playwright.config.ts` around lines 137 - 161, The package projects
in the packages flatMap currently form a sequential dependency chain through
admin-auth-refresh-${i} and prevDep, so an earlier failure skips later coverage.
Remove inter-package dependencies while preserving each package’s required auth
setup, configure refresh projects to run independently, and ensure failures are
aggregated rather than blocking subsequent packages. Add a CI test case with a
failing test in a non-final package and verify later package projects still
execute.

Comment on lines +137 to +161
...packages.flatMap((pkg, i) => {
const prevDep = i === 0 ? 'admin-auth' : packages[i - 1];
const refreshProject =
i > 0
? [
{
name: `admin-auth-refresh-${i}`,
testDir: setupDir,
testMatch: 'admin-auth.setup.ts',
dependencies: [prevDep],
use: { ...chromeAuth, launchOptions: { args: chromeArgs } },
},
]
: [];
return [
...refreshProject,
{
name: pkg,
testDir: path.resolve(__dirname, 'e2e', 'tests', pkg),
testIgnore: '**/developer/**',
dependencies: [i > 0 ? `admin-auth-refresh-${i}` : 'admin-auth'],
use: { ...chrome, storageState: adminStorageState },
},
];
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is something that is not convincing me here:

The logic depends on the packages array's order and position of its items, but nothing in the code makes this kind of constraint visible.

Anyone in the future can add, remove, or reorder packages without thinking about which one is "first", and this flatMap is creating a dependency chain where the first element smoke is treated specially.

I'm not completely sure that we should create this coupling (meaning making the order of packages so crucial).

Having said that, - in case we agree on this strict serial chain - the real issue for now is that we have only one special case: smoke, so my question is shoudn't we trade off this and just refresh every package uniformly as it already is? The tradeoff would be some seconds of refresh time for smoke package, but we could gain redability in case we want to change things in future (and of course we should point out that order in packages will matter from now on).

Suggested change
...packages.flatMap((pkg, i) => {
const prevDep = i === 0 ? 'admin-auth' : packages[i - 1];
const refreshProject =
i > 0
? [
{
name: `admin-auth-refresh-${i}`,
testDir: setupDir,
testMatch: 'admin-auth.setup.ts',
dependencies: [prevDep],
use: { ...chromeAuth, launchOptions: { args: chromeArgs } },
},
]
: [];
return [
...refreshProject,
{
name: pkg,
testDir: path.resolve(__dirname, 'e2e', 'tests', pkg),
testIgnore: '**/developer/**',
dependencies: [i > 0 ? `admin-auth-refresh-${i}` : 'admin-auth'],
use: { ...chrome, storageState: adminStorageState },
},
];
}),
...packages.map((_, i) => ({
name: `admin-auth-refresh-${i}`,
testDir: setupDir,
testMatch: 'admin-auth.setup.ts',
dependencies: [i === 0 ? 'admin-auth' : packages[i - 1]],
use: { ...chromeAuth, launchOptions: { args: chromeArgs } },
})),
...packages.map((pkg, i) => ({
name: pkg,
testDir: path.resolve(__dirname, 'e2e', 'tests', pkg),
testIgnore: '**/developer/**',
dependencies: [`admin-auth-refresh-${i}`],
use: { ...chrome, storageState: adminStorageState },
})),

@openshift-ci

openshift-ci Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@shahsahil264: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-playwright 3b950fb link false /test e2e-playwright
ci/prow/backend 3b950fb link true /test backend
ci/prow/e2e-playwright-techpreview 3b950fb link false /test e2e-playwright-techpreview

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-ci

openshift-ci Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants