-
Notifications
You must be signed in to change notification settings - Fork 750
OCPBUGS-71237: Persist console sessions across pod restarts #16911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| import { test, expect } from '../../fixtures'; | ||
| import { performLogin } from '../../setup/login-helper'; | ||
|
|
||
| const CONSOLE_NAMESPACE = 'openshift-console'; | ||
| const CONSOLE_DEPLOYMENT = 'console'; | ||
|
|
||
| test.describe( | ||
| 'Session persistence across pod restarts', | ||
| { tag: ['@admin', '@slow'] }, | ||
| () => { | ||
| test.setTimeout(300_000); | ||
|
|
||
| test('session survives console pod deletion', async ({ page, k8sClient }) => { | ||
| const baseURL = process.env.WEB_CONSOLE_URL || 'http://localhost:9000'; | ||
|
|
||
| await test.step('Log in to the console', async () => { | ||
| const htpasswdUser = process.env.BRIDGE_HTPASSWD_USERNAME; | ||
| const htpasswdPass = process.env.BRIDGE_HTPASSWD_PASSWORD; | ||
| const htpasswdIdp = process.env.BRIDGE_HTPASSWD_IDP; | ||
|
|
||
| if (htpasswdUser && htpasswdPass) { | ||
| await performLogin(page, baseURL, htpasswdUser, htpasswdPass, htpasswdIdp); | ||
| } else { | ||
| const kubeadminPassword = process.env.BRIDGE_KUBEADMIN_PASSWORD; | ||
| test.skip(!kubeadminPassword, 'No credentials configured'); | ||
| await performLogin(page, baseURL, 'kubeadmin', kubeadminPassword!, 'kube:admin'); | ||
| } | ||
|
|
||
| await expect(page.getByTestId('user-dropdown-toggle')).toBeVisible({ timeout: 60_000 }); | ||
| }); | ||
|
|
||
| await test.step('Verify dashboard loads', async () => { | ||
| await page.goto(`${baseURL}/dashboards`, { waitUntil: 'domcontentloaded' }); | ||
| await expect(page).toHaveTitle(/Overview/); | ||
| }); | ||
|
|
||
| await test.step('Delete all console pods', async () => { | ||
| const pods = await k8sClient.getPods(CONSOLE_NAMESPACE); | ||
| const consolePods = pods.filter( | ||
| (p) => p.metadata?.labels?.['component'] === 'ui', | ||
| ); | ||
|
|
||
| expect(consolePods.length).toBeGreaterThan(0); | ||
|
|
||
| for (const pod of consolePods) { | ||
| await k8sClient.deletePod(pod.metadata!.name!, CONSOLE_NAMESPACE); | ||
| } | ||
| }); | ||
|
|
||
| await test.step('Wait for new console pods to be ready', async () => { | ||
| await k8sClient.waitForDeploymentReady(CONSOLE_DEPLOYMENT, CONSOLE_NAMESPACE, 180_000); | ||
| }); | ||
|
|
||
| await test.step('Verify session persisted — no login redirect', async () => { | ||
| await page.goto(`${baseURL}/k8s/cluster/nodes`, { | ||
| waitUntil: 'domcontentloaded', | ||
| timeout: 60_000, | ||
| }); | ||
|
|
||
| await expect(page.getByTestId('user-dropdown-toggle')).toBeVisible({ timeout: 30_000 }); | ||
| await expect(page).toHaveTitle(/Nodes/); | ||
| expect(page.url()).not.toContain('oauth-openshift'); | ||
| expect(page.url()).not.toContain('/login'); | ||
| }); | ||
| }); | ||
|
|
||
| test('session survives console plugin toggle', async ({ page, k8sClient }) => { | ||
| const baseURL = process.env.WEB_CONSOLE_URL || 'http://localhost:9000'; | ||
|
|
||
| await test.step('Log in to the console', async () => { | ||
| const htpasswdUser = process.env.BRIDGE_HTPASSWD_USERNAME; | ||
| const htpasswdPass = process.env.BRIDGE_HTPASSWD_PASSWORD; | ||
| const htpasswdIdp = process.env.BRIDGE_HTPASSWD_IDP; | ||
|
|
||
| if (htpasswdUser && htpasswdPass) { | ||
| await performLogin(page, baseURL, htpasswdUser, htpasswdPass, htpasswdIdp); | ||
| } else { | ||
| const kubeadminPassword = process.env.BRIDGE_KUBEADMIN_PASSWORD; | ||
| test.skip(!kubeadminPassword, 'No credentials configured'); | ||
| await performLogin(page, baseURL, 'kubeadmin', kubeadminPassword!, 'kube:admin'); | ||
| } | ||
|
|
||
| await expect(page.getByTestId('user-dropdown-toggle')).toBeVisible({ timeout: 60_000 }); | ||
| }); | ||
|
|
||
| let pluginName: string | undefined; | ||
|
|
||
| await test.step('Find an enabled ConsolePlugin to toggle', async () => { | ||
| const consoleOperator = await k8sClient.customObjectsApi.getClusterCustomObject({ | ||
| group: 'operator.openshift.io', | ||
| version: 'v1', | ||
| plural: 'consoles', | ||
| name: 'cluster', | ||
| }); | ||
|
|
||
| const plugins: string[] = | ||
| (consoleOperator.body as any)?.spec?.plugins ?? []; | ||
| pluginName = plugins[0]; | ||
| test.skip(!pluginName, 'No enabled ConsolePlugins found on this cluster'); | ||
| }); | ||
|
|
||
| await test.step('Disable the plugin via operator config', async () => { | ||
| const consoleOperator = await k8sClient.customObjectsApi.getClusterCustomObject({ | ||
| group: 'operator.openshift.io', | ||
| version: 'v1', | ||
| plural: 'consoles', | ||
| name: 'cluster', | ||
| }); | ||
|
|
||
| const currentPlugins: string[] = | ||
| (consoleOperator.body as any)?.spec?.plugins ?? []; | ||
| const updatedPlugins = currentPlugins.filter((p: string) => p !== pluginName); | ||
|
|
||
| await k8sClient.mergePatchResource( | ||
| '/apis/operator.openshift.io/v1/consoles/cluster', | ||
| { spec: { plugins: updatedPlugins } }, | ||
| ); | ||
| }); | ||
|
|
||
| await test.step('Wait for console rollout', async () => { | ||
| // The operator triggers a new rollout when plugin config changes. | ||
| // Delete the console pods to force immediate restart, then wait for readiness. | ||
| const pods = await k8sClient.getPods(CONSOLE_NAMESPACE); | ||
| const consolePods = pods.filter( | ||
| (p) => p.metadata?.labels?.['component'] === 'ui', | ||
| ); | ||
| for (const pod of consolePods) { | ||
| await k8sClient.deletePod(pod.metadata!.name!, CONSOLE_NAMESPACE); | ||
| } | ||
| await k8sClient.waitForDeploymentReady(CONSOLE_DEPLOYMENT, CONSOLE_NAMESPACE, 180_000); | ||
| }); | ||
|
|
||
| await test.step('Verify session persisted after plugin toggle', async () => { | ||
| await page.goto(`${baseURL}/dashboards`, { | ||
| waitUntil: 'domcontentloaded', | ||
| timeout: 60_000, | ||
| }); | ||
|
|
||
| await expect(page.getByTestId('user-dropdown-toggle')).toBeVisible({ timeout: 30_000 }); | ||
| await expect(page).toHaveTitle(/Overview/); | ||
| expect(page.url()).not.toContain('oauth-openshift'); | ||
| expect(page.url()).not.toContain('/login'); | ||
| }); | ||
|
|
||
| await test.step('Re-enable the plugin', async () => { | ||
| const consoleOperator = await k8sClient.customObjectsApi.getClusterCustomObject({ | ||
| group: 'operator.openshift.io', | ||
| version: 'v1', | ||
| plural: 'consoles', | ||
| name: 'cluster', | ||
| }); | ||
|
|
||
| const currentPlugins: string[] = | ||
| (consoleOperator.body as any)?.spec?.plugins ?? []; | ||
| if (!currentPlugins.includes(pluginName!)) { | ||
| currentPlugins.push(pluginName!); | ||
| await k8sClient.mergePatchResource( | ||
| '/apis/operator.openshift.io/v1/consoles/cluster', | ||
| { spec: { plugins: currentPlugins } }, | ||
| ); | ||
| } | ||
| }); | ||
| }); | ||
| }, | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: openshift/console
Length of output: 15116
🏁 Script executed:
Repository: openshift/console
Length of output: 30341
🏁 Script executed:
Repository: openshift/console
Length of output: 278
Gate readiness on the requested disruption.
metadata.generationand wait for it to increase before callingwaitForDeploymentReady. Otherwise, stale readiness can pass without a rollout.📍 Affects 1 file
frontend/e2e/tests/console/session-persistence.spec.ts#L50-L52(this comment)frontend/e2e/tests/console/session-persistence.spec.ts#L120-L124🤖 Prompt for AI Agents