-
Notifications
You must be signed in to change notification settings - Fork 659
OCPBUGS-60969: Console headers are empty when used from a dynamic plugin #15439
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
OCPBUGS-60969: Console headers are empty when used from a dynamic plugin #15439
Conversation
…fore accessing state
@Leo6Leo: No Jira issue with key CONSOLE-60779 exists in the tracker at https://issues.redhat.com/. In response to this:
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: This pull request references Jira Issue OCPBUGS-60779, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
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: 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
Requesting review from QA contact: The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
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. |
/cherry-pick release-4.19 |
@Leo6Leo: once the present PR merges, I will cherry-pick it on top of In response to this:
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. |
frontend/packages/console-dynamic-plugin-sdk/src/utils/fetch/console-fetch-utils.ts
Show resolved
Hide resolved
/retest-required |
1 similar comment
/retest-required |
@Leo6Leo I think this PR is ready, right? |
/lgtm |
/jira refresh |
@Leo6Leo: This pull request references Jira Issue OCPBUGS-60969, which is invalid:
Comment In response to this:
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. |
/jira refresh |
@Leo6Leo: This pull request references Jira Issue OCPBUGS-60969, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
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. |
/retest-required |
composeEnhancers(applyMiddleware(thunk)), | ||
); | ||
|
||
// Make store globally available for dynamic plugins |
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.
Isn't this what storeHandler.getStore()
is for?
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.
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
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.
@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?
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.
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.
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.
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.
- When
getConsoleRequestHeaders()
is called from the file dynamic-demo-plugin/src/components/UtilityConsumer.tsx, we can see that it shows the store is undefined.

- When
getConsoleRequestHeaders()
is called from somewhere else, the function proceed as expected:

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?
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.
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.
New changes are detected. LGTM label has been removed. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jgbernalp, Leo6Leo 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 |
@Leo6Leo: The following tests failed, say
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. |
This PR will be closed soon as another better approach is found here: #15556. |
The issue has been resolved in #15556, now closing this PR. |
@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:
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. |
Description
The function getConsoleRequestHeaders provided by the dynamic plugin SDK returns empty headers
Step to reproduce
Root cause
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