Skip to content

Conversation

Leo6Leo
Copy link
Contributor

@Leo6Leo Leo6Leo commented Aug 27, 2025

Description

The function getConsoleRequestHeaders provided by the dynamic plugin SDK returns empty headers

Step to reproduce

  1. Start the dynamic demo plugin and the console from this PR: https://github.com/jgbernalp/console/tree/console-headers-test
  2. Navigate to http://localhost:9000/test-utility-consumer

Root cause

   // This fails in dynamic plugin context
   const store = storeHandler.getStore(); // undefined
   if (!store) return undefined; // ❌ here it returns undefined instead of headers

Fix

By adding the condition check, if store DNE, we will still return the header, instead of undefined.

Note

This bug is reproduced on 4.20, 4.19. The rest of the release versions haven't been tested yet, as there are some issues with the dynamic-plugin build process that I am trying to figure out.

/cc @TheRealJon @logonoff @krishagarwal278

@openshift-ci-robot
Copy link
Contributor

@Leo6Leo: No Jira issue with key CONSOLE-60779 exists in the tracker at https://issues.redhat.com/.
Once a valid jira issue is referenced in the title of this pull request, request a refresh with /jira refresh.

In response to this:

Description

The function getConsoleRequestHeaders provided by the dynamic plugin SDK returns empty headers

Step to reproduce

  1. Start the dynamic demo plugin and the console from this PR: https://github.com/jgbernalp/console/tree/console-headers-test
  2. Navigate to http://localhost:9000/test-utility-consumer

Root cause

  // This fails in dynamic plugin context
  const store = storeHandler.getStore(); // undefined
  if (!store) return undefined; // ❌ here it returns undefined instead of headers

Fix

By adding the condition check, if store DNE, we will still return the header, instead of undefined.

Note

This bug is reproduced on 4.20, 4.19. The rest of the release versions haven't been tested yet, as there are some issues with the dynamic-plugin build process that I am trying to figure out.

/cc @TheRealJon @logonoff @krishagarwal278

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 component/sdk Related to console-plugin-sdk label Aug 27, 2025
@Leo6Leo Leo6Leo changed the title CONSOLE-60779: Console headers are empty when used from a dynamic plugin OCPBUGS-60779: Console headers are empty when used from a dynamic plugin Aug 27, 2025
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 27, 2025
@openshift-ci-robot
Copy link
Contributor

@Leo6Leo: This pull request references Jira Issue OCPBUGS-60779, which is invalid:

  • expected the bug to target the "4.20.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Description

The function getConsoleRequestHeaders provided by the dynamic plugin SDK returns empty headers

Step to reproduce

  1. Start the dynamic demo plugin and the console from this PR: https://github.com/jgbernalp/console/tree/console-headers-test
  2. Navigate to http://localhost:9000/test-utility-consumer

Root cause

  // This fails in dynamic plugin context
  const store = storeHandler.getStore(); // undefined
  if (!store) return undefined; // ❌ here it returns undefined instead of headers

Fix

By adding the condition check, if store DNE, we will still return the header, instead of undefined.

Note

This bug is reproduced on 4.20, 4.19. The rest of the release versions haven't been tested yet, as there are some issues with the dynamic-plugin build process that I am trying to figure out.

/cc @TheRealJon @logonoff @krishagarwal278

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.

@Leo6Leo Leo6Leo changed the title OCPBUGS-60779: Console headers are empty when used from a dynamic plugin OCPBUGS-60969: Console headers are empty when used from a dynamic plugin Aug 27, 2025
@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 27, 2025
@openshift-ci-robot
Copy link
Contributor

@Leo6Leo: This pull request references Jira Issue OCPBUGS-60969, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.20.0) matches configured target version for branch (4.20.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Description

The function getConsoleRequestHeaders provided by the dynamic plugin SDK returns empty headers

Step to reproduce

  1. Start the dynamic demo plugin and the console from this PR: https://github.com/jgbernalp/console/tree/console-headers-test
  2. Navigate to http://localhost:9000/test-utility-consumer

Root cause

  // This fails in dynamic plugin context
  const store = storeHandler.getStore(); // undefined
  if (!store) return undefined; // ❌ here it returns undefined instead of headers

Fix

By adding the condition check, if store DNE, we will still return the header, instead of undefined.

Note

This bug is reproduced on 4.20, 4.19. The rest of the release versions haven't been tested yet, as there are some issues with the dynamic-plugin build process that I am trying to figure out.

/cc @TheRealJon @logonoff @krishagarwal278

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 requested a review from yapei August 27, 2025 21:03
@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Aug 27, 2025

/cherry-pick release-4.19

@openshift-cherrypick-robot

@Leo6Leo: once the present PR merges, I will cherry-pick it on top of release-4.19 in a new PR and assign it to you.

In response to this:

/cherry-pick release-4.19

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 component/core Related to console core functionality label Sep 4, 2025
@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Sep 5, 2025

/retest-required

1 similar comment
@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Sep 6, 2025

/retest-required

@jgbernalp
Copy link
Contributor

@Leo6Leo I think this PR is ready, right?

@jgbernalp
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2025
@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Sep 15, 2025

/cc @jhadvig @TheRealJon @spadgett

@openshift-ci openshift-ci bot requested review from jhadvig and spadgett September 15, 2025 13:49
@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Sep 15, 2025

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. and removed jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Sep 15, 2025
@openshift-ci-robot
Copy link
Contributor

@Leo6Leo: This pull request references Jira Issue OCPBUGS-60969, which is invalid:

  • expected the bug to target either version "4.21." or "openshift-4.21.", but it targets "4.20.0" instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/jira refresh

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.

@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Sep 15, 2025

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Sep 15, 2025
@openshift-ci-robot
Copy link
Contributor

@Leo6Leo: This pull request references Jira Issue OCPBUGS-60969, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

In response to this:

/jira refresh

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.

@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Sep 15, 2025

/retest-required

composeEnhancers(applyMiddleware(thunk)),
);

// Make store globally available for dynamic plugins
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this what storeHandler.getStore() is for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on my research and learning, I found the different storeHandler is used:
Main console: console/dynamic-plugin-sdk/src/app/storeHandler (source)
Plugin: @openshift-console/dynamic-plugin-sdk/lib/app/storeHandler (compiled)

And this leads to the different store to be used. By setting the store to the shared global space, we can make sure that same store get used. This is my understanding, what do you think? @TheRealJon

Copy link
Member

Choose a reason for hiding this comment

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

@Leo6Leo, we've always had a singleton Redux store instance. It's already declared globally in the storeHandler you referenced. @vojtechszocs could you clarify how this should work?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Leo6Leo @TheRealJon

The root cause of the problem seems to be that storeHandler.setStore function is not called right after the Redux store instance is created and initialized in public/redux.ts module.

So I think the only change we need for this bugfix is to modify public/redux.ts like so:

// ...
import storeHandler from '@console/dynamic-plugin-sdk/src/app/storeHandler';
// ...

storeHandler.setStore(store);

export default store;

Bugfix PRs should contain minimal changes to address the immediate issue. We can further improve the Redux handling code in follow-up non-bugfix PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After applying @vojtechszocs 's fix

I have performed the fix @vojtechszocs suggested locally, I can see that the store is successfully initialized, but that doesn't solve the problem with the storeHandler.getStore() returning undefined in the getConsoleRequestHeaders() function, calling it from the file dynamic-demo-plugin/src/components/UtilityConsumer.tsx. But I think this change makes sense to me and it is necessary, since the store should be set when the store is being created.

Further investigation

One key observation I found is that: whether storeHandler.getStore() returning undefined or the real store value in the getConsoleRequestHeaders() function, it depends on where it get called.

Screenshot 2025-09-24 at 4 22 59 PM
  • When getConsoleRequestHeaders() is called from somewhere else, the function proceed as expected:
Screenshot 2025-09-24 at 4 22 21 PM

Therefore, I think the root cause I found here is still valid.

different storeHandler is used:
Main console: console/dynamic-plugin-sdk/src/app/storeHandler (source)
Plugin: @openshift-console/dynamic-plugin-sdk/lib/app/storeHandler (compiled)

And here is a quote from the LLM that I think is a reasonable explanation to me:

The console uses Webpack Module Federation to load dynamic plugins. Which means:
Main Application Context: our main app (console/frontend) has its own module context with its own instance of storeHandler.
Plugin Context: the dynamic plugin (console/dynamic-demo-plugin) runs in a separate webpack container/module context and gets its own separate instance of storeHandler

So I think the approach of making the store become global makes sense. As suggested, we should only have 1 redux store, should we consider making that store become global?

Copy link
Member

Choose a reason for hiding this comment

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

I think if we do fix it this way, it should be commented with a FIXME and a CONSOLE project issue to look further into this. We probably shouldn't leak the internal application state into the window scope as a long-term solution.

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2025
Copy link
Contributor

openshift-ci bot commented Oct 1, 2025

New changes are detected. LGTM label has been removed.

Copy link
Contributor

openshift-ci bot commented Oct 1, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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

Copy link
Contributor

openshift-ci bot commented Oct 1, 2025

@Leo6Leo: 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/frontend 04696de link true /test frontend
ci/prow/okd-scos-e2e-aws-ovn 04696de link false /test okd-scos-e2e-aws-ovn

Full PR test history. Your PR dashboard.

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.

@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Oct 1, 2025

This PR will be closed soon as another better approach is found here: #15556.

@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Oct 3, 2025

The issue has been resolved in #15556, now closing this PR.

@Leo6Leo Leo6Leo closed this Oct 3, 2025
@openshift-ci-robot
Copy link
Contributor

@Leo6Leo: This pull request references Jira Issue OCPBUGS-60969. The bug has been updated to no longer refer to the pull request using the external bug tracker.

In response to this:

Description

The function getConsoleRequestHeaders provided by the dynamic plugin SDK returns empty headers

Step to reproduce

  1. Start the dynamic demo plugin and the console from this PR: https://github.com/jgbernalp/console/tree/console-headers-test
  2. Navigate to http://localhost:9000/test-utility-consumer

Root cause

  // This fails in dynamic plugin context
  const store = storeHandler.getStore(); // undefined
  if (!store) return undefined; // ❌ here it returns undefined instead of headers

Fix

By adding the condition check, if store DNE, we will still return the header, instead of undefined.

Note

This bug is reproduced on 4.20, 4.19. The rest of the release versions haven't been tested yet, as there are some issues with the dynamic-plugin build process that I am trying to figure out.

/cc @TheRealJon @logonoff @krishagarwal278

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/core Related to console core functionality component/sdk Related to console-plugin-sdk jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants