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

Bug 1768616: Allow gating RoutePage extensions by feature flags #3246

Conversation

vojtechszocs
Copy link
Contributor

Follow up to #3066 (comment) the RoutePage extension now supports gating by Console feature flags.

Entry modules of following plugins were modified to utilize this feature:

Entry module of operator-lifecycle-manager (cc @alecmerdler) now uses declared consumed extension types (the as operator in TypeScript is a "force" cast and should be avoided if possible).

@jtomasek Can you please verify this with existing Metal3 plugin routes?

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Nov 5, 2019
@openshift-ci-robot
Copy link
Contributor

@vojtechszocs: This pull request references Bugzilla bug 1768616, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Bug 1768616: Allow gating RoutePage extensions by feature flags

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.

@openshift-ci-robot openshift-ci-robot added component/ceph Related to ceph-storage-plugin component/core Related to console core functionality component/kubevirt Related to kubevirt-plugin component/metal3 Related to metal3-plugin component/noobaa Related to noobaa-storage-plugin size/M Denotes a PR that changes 30-99 lines, ignoring generated files. component/olm Related to OLM component/sdk Related to console-plugin-sdk labels Nov 5, 2019
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 5, 2019
@vojtechszocs
Copy link
Contributor Author

cc @spadgett

@spadgett spadgett added this to the v4.3 milestone Nov 5, 2019
@spadgett
Copy link
Member

spadgett commented Nov 5, 2019

/assign

@pcbailey
Copy link
Contributor

pcbailey commented Nov 6, 2019

@vojtechszocs I don't see any problems with the changes made to the network attachment definitions plugin.

@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 6, 2019
@afreen23
Copy link
Contributor

afreen23 commented Nov 7, 2019

Ack @vojtechszocs

Copy link

@jtomasek jtomasek left a comment

Choose a reason for hiding this comment

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

I can confirm that metal3-plugin routes are no more applied on cloud based cluster (AWS). On bare metal cluster the routes are applied as expected.

@jtomasek
Copy link

jtomasek commented Nov 7, 2019

/test e2e-gcp-console

@spadgett
Copy link
Member

spadgett commented Nov 7, 2019

/retest

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

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 7, 2019
@vojtechszocs
Copy link
Contributor Author

Thanks everyone for the review, FYI the second commit 2d48790 removes React.memo usage from AppContents component.

@christianvogt Are you OK with that? The effective change is:

- // use `withRouter` to force a re-render when routes change since we are using React.memo
const AppContents = connect((state: RootState) => ({
- activePerspective: getActivePerspective(state),
+ pageRouteExtensions: getPageRouteExtensions(state),
- }))(
-   withRouter(
-     React.memo(({ activePerspective }) => (
+ }))(({ pageRouteExtensions }) => (

),
);
pageRouteExtensions: getPageRouteExtensions(state),
}))(({ pageRouteExtensions }) => (
Copy link
Contributor

@christianvogt christianvogt Nov 7, 2019

Choose a reason for hiding this comment

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

Won't this cause a re-render here on every state change since getPageRouteExtensions returns a new array.

Specifically I forgot the use case for using memo. But I believe this was all related to performance to reduce unnecessary re-renders.

@vojtechszocs Did you do any comparisons?

Edit note: the memo and withRouter was added before the use of connect. It was used to prevent unnecessary re-renders.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did some comparisons. It doesn't look like we're worse than before.
However we have regressed (even without this change) from the original performance fix here: #1558

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Won't this cause a re-render here on every state change since getPageRouteExtensions returns a new array.

That's correct 😞

plugins.registry
  .getRoutePages()
  .filter((e) => plugins.registry.isExtensionInUse(e, flags))

yields a new array, due to filter in getRoutePages(). However, the content of such array should stay the same in case of state changes that don't effect RoutePage extensions, since we're operating on the same extension objects (this.extensions in ExtensionRegistry).

I'll update the code to ensure we don't re-render unless RoutePage extension required feature flags change.

@vojtechszocs Did you do any comparisons?

I'll update the code and will do some comparisons.

I did some comparisons. It doesn't look like we're worse than before.
However we have regressed (even without this change) from the original performance fix here: #1558

Maybe we can open a bug to track it so we don't forget about it.

@spadgett
Copy link
Member

spadgett commented Nov 7, 2019

/retest

@spadgett
Copy link
Member

spadgett commented Nov 7, 2019

/hold
as @christianvogt has review comments

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 7, 2019
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 7, 2019
@vojtechszocs
Copy link
Contributor Author

@christianvogt @spadgett

I've split AppContents_ (actual component) vs. AppContents (Redux-connected HOC) while using connectToFlags to ensure a re-render when feature flags used to gate RoutePage extensions are changed.

This component split is very similar to existing DefaultPage_ vs. DefaultPage.

Since connectToFlags injects new flags object upon every state change, we can't React.memo on that. We could React.memo on activePerspective but I don't think it changes that frequently to justify its memoization, right?

Let me know what you think.

@spadgett
Copy link
Member

spadgett commented Nov 8, 2019

Since connectToFlags injects new flags object upon every state change, we can't React.memo on that.

I think you can based on the discussion above, #3246 (review). React.memo will do a shallow comparison of each object in props, which should work here.

@christianvogt
Copy link
Contributor

christianvogt commented Nov 8, 2019

You don't need memo because react-redux connect uses the pure option by default which internally uses memo.

Latest change to the connect args looks better now.

@christianvogt
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 8, 2019
@christianvogt
Copy link
Contributor

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 8, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christianvogt, jtomasek, 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

@christianvogt
Copy link
Contributor

/retest

@openshift-merge-robot openshift-merge-robot merged commit b45de53 into openshift:master Nov 8, 2019
@openshift-ci-robot
Copy link
Contributor

@vojtechszocs: All pull requests linked via external trackers have merged. Bugzilla bug 1768616 has been moved to the MODIFIED state.

In response to this:

Bug 1768616: Allow gating RoutePage extensions by feature flags

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.

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. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/ceph Related to ceph-storage-plugin component/core Related to console core functionality component/kubevirt Related to kubevirt-plugin component/metal3 Related to metal3-plugin component/noobaa Related to noobaa-storage-plugin component/olm Related to OLM component/sdk Related to console-plugin-sdk lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants