Skip to content
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

CONSOLE-3883: Improve dynamic plugin docs #13637

Merged

Conversation

vojtechszocs
Copy link
Contributor

@vojtechszocs vojtechszocs commented Feb 26, 2024

  • Include PatternFly upgrade notes
  • Include notes on hosting plugin assets

@vojtechszocs vojtechszocs changed the title Improve dynamic plugin docs CONSOLE-3883: Improve dynamic plugin docs Feb 26, 2024
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 26, 2024
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Feb 26, 2024

@vojtechszocs: This pull request references CONSOLE-3883 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 story to target the "4.16.0" version, but no target version was set.

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.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Feb 26, 2024

@vojtechszocs: This pull request references CONSOLE-3883 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 story to target the "4.16.0" version, but no target version was set.

In response to this:

  • Include PatternFly upgrade notes
  • Include notes on hosting plugin assets

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 component/sdk Related to console-plugin-sdk approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 26, 2024
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

Thanks @vojtechszocs 👍

@opayne1 FYI


## Serving plugin assets

Dynamic plugins are deployed on a cluster via OLM operators. Each plugin deployment should include a web
Copy link
Member

Choose a reason for hiding this comment

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

It's not required to use an OLM operator, just a good way to deploy and manage your plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@spadgett Should I rephrase it differently?

Copy link
Member

Choose a reason for hiding this comment

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

I'd probably just say plugins are deployed as workloads on the cluster.


**Important!** Make sure to configure your plugin web server to use MIME type `text/javascript` for all
JS assets to avoid any issues with the `X-Content-Type-Options: nosniff` security header used by Console
when fetching plugin assets via Bridge URL `/api/plugins/<plugin-name>`.
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: I'd leave off the URL path here since that's an implementation detail plugins shouldn't need to know about.

The warning is a great point and important to document. It might be worth mentioning that the plugin template will have the mime types set up properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, will update.

Copy link
Contributor

Choose a reason for hiding this comment

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

just confirming: is it alright if plugin's web server adds application/javascript by default instead of explicitly text/javascript ?? (so far it is working)...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SanjalKatiyar Thanks, this actually led me to realize what the core issue was.

Check out https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options

Console loads dynamic plugin scripts by injecting <script> elements into the main DOM document.

Console Bridge server adds X-Content-Type-Options: nosniff HTTP response header to all plugin asset requests.

Web browsers that comply with X-Content-Type-Options: nosniff header will block <script> initiated requests when the MIME type of requested asset is not valid.

application/javascript is considered to be a legacy JavaScript MIME type but is still a valid one.

Looking further into this, I think it's OK to use a legacy MIME type like application/javascript.

Note that the proper MIME type for JavaScript according to current HTML spec is text/javascript.

The core of the issue is "always make sure to provide a valid mime type for JS assets" so that you won't end up facing errors in the browser like this one

Refused to execute script from 'http://localhost:9000/api/plugins/foo-plugin/some-script.js' because its MIME type ('') is not executable, and strict MIME type checking is enabled.

I will update the README accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks !


### Caching

The following table lists important plugin assets that must NOT be cached by the plugin web server.
Copy link
Member

Choose a reason for hiding this comment

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

Can they be cached if appropriate cache-control headers are returned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, AFAIK the Bridge plugin asset proxy endpoint does not do anything special in this regard. cc @jhadvig

Copy link
Member

Choose a reason for hiding this comment

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

I know @TheRealJon has fixed some caching bugs on the console side. Can we confirm it's still a limitation?

I believe we should be able to handle caching as long as it's done properly by the plugin. If this is really a restriction, we should look at adding cache-busting parameters to the console request to avoid the problem.

Copy link
Contributor Author

@vojtechszocs vojtechszocs Feb 27, 2024

Choose a reason for hiding this comment

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

@spadgett Looking into this, all plugin entry scripts are loaded using ?cacheBuster query parameter to circumvent potential caching issues on the server side. This was fixed for OCP Console 4.14 and above.

Given that JSON files should be generally OK to cache (assuming we don't expect their content to change), I think I can remove the whole "Caching" section above then.

| `plugin-manifest.json` | |
| `plugin-entry.js` | Applies only to Console plugin SDK versions 0.0.x |

We generally recommend disabling caching of any JSON resources hosted by the plugin web server.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I agree with this. In particular, I'd recommend using caching for i18n message files.

I think the important thing is that caching is set up correctly and we fix any caching bugs on the console side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, you have a point with the i18n resources not supposed to be changed.

I will remove this line.


## Console 4.15

All plugins that target OpenShift Console 4.15 should upgrade to PatternFly 5.x to take advantage
Copy link
Member

Choose a reason for hiding this comment

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

I'd clarify that this is for plugins that only target 4.15 and newer, not for plugins that want to be compatible with older versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I will update it to be more explicit.

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

/lgtm

👍

@spadgett
Copy link
Member

/lgtm

Copy link
Member

@jhadvig jhadvig left a comment

Choose a reason for hiding this comment

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

Small nit otherwise looks good.
Docs Approver:
/assign @opayne1

A dynamic plugin targets one or more versions of OpenShift Console. Each Console version supports
specific version(s) of [PatternFly](https://www.patternfly.org/) in terms of CSS styling.

Check the [OpenShift Console Versions vs PatternFly Versions][console-pf-versions] table for
Copy link
Member

Choose a reason for hiding this comment

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

Lets link the table here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jhadvig This is a reference-style link to console-pf-versions declared at the end of the Markdown document.

[console-pf-versions]: ./README.md#openshift-console-versions-vs-patternfly-versions

@jhadvig jhadvig added qe-approved Signifies that QE has signed off on this PR px-approved Signifies that Product Support has signed off on this PR labels Mar 5, 2024
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Mar 5, 2024

@vojtechszocs: This pull request references CONSOLE-3883 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 story to target the "4.16.0" version, but no target version was set.

In response to this:

  • Include PatternFly upgrade notes
  • Include notes on hosting plugin assets

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.

Copy link
Contributor

@opayne1 opayne1 left a comment

Choose a reason for hiding this comment

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

Just 2 small wording/grammar related comments, but otherwise looks good so I will go ahead and approve.

I have opened a docs PR to capture these updates in the user facing docs. Open to any feedback you have!

@opayne1
Copy link
Contributor

opayne1 commented Mar 5, 2024

/label docs-approved

@openshift-ci openshift-ci bot added the docs-approved Signifies that Docs has signed off on this PR label Mar 5, 2024
Co-authored-by: Olivia Payne <opayne@redhat.com>
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 5, 2024
Copy link
Contributor

openshift-ci bot commented Mar 5, 2024

New changes are detected. LGTM label has been removed.

@vojtechszocs
Copy link
Contributor Author

@opayne1 Thank you for your comments, I've applied the suggested changes.

@rhamilto
Copy link
Member

rhamilto commented Mar 6, 2024

/lgtm
/label tide/merge-method-squash

@openshift-ci openshift-ci bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Mar 6, 2024
@rhamilto rhamilto added the lgtm Indicates that a PR is ready to be merged. label Mar 6, 2024
Copy link
Contributor

openshift-ci bot commented Mar 6, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhadvig, nicolethoen, rhamilto, spadgett, vojtechszocs

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

The pull request process is described 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

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 7bfcdc2 and 2 for PR HEAD f337740 in total

@rhamilto
Copy link
Member

rhamilto commented Mar 7, 2024

/retest

2 similar comments
@rhamilto
Copy link
Member

rhamilto commented Mar 7, 2024

/retest

@vojtechszocs
Copy link
Contributor Author

/retest

Copy link
Contributor

openshift-ci bot commented Mar 7, 2024

@vojtechszocs: all tests passed!

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/test-infra repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 77d383d into openshift:master Mar 7, 2024
6 checks passed
@openshift-bot
Copy link
Contributor

[ART PR BUILD NOTIFIER]

This PR has been included in build openshift-enterprise-console-container-v4.16.0-202403081048.p0.g77d383d.assembly.stream.el8 for distgit openshift-enterprise-console.
All builds following this will include this PR.

Lucifergene pushed a commit to Lucifergene/console that referenced this pull request Mar 12, 2024
* Improve dynamic plugin docs

* Add section on PF CSS styling

* Address review comments

* Apply suggestions from code review

Co-authored-by: Olivia Payne <opayne@redhat.com>

---------

Co-authored-by: Olivia Payne <opayne@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/sdk Related to console-plugin-sdk docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants