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

Fix Re-Rendering Caused by API Discovery #603

Merged
merged 1 commit into from
Oct 9, 2018

Conversation

alecmerdler
Copy link
Contributor

@alecmerdler alecmerdler commented Sep 28, 2018

Description

Refactor Firehose component to simplify complex/hacky React lifecyle logic. Ensure that Firehose does not re-render when API discovery runs if its own data is loaded.

Testing

Open a terminal alongside the browser window and create a CRD:

$ kubectl create -f https://gist.githubusercontent.com/alecmerdler/df6a32ef511721fd8e633251a8dbc140/raw/d272d015756c96651fc8a0cfbce5cdeab902d0d5/cluster.crd.yaml

The list/detail view should not be affected.

Addresses https://jira.coreos.com/browse/CONSOLE-812

@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 28, 2018
@spadgett
Copy link
Member

This seems to make things much better, but I'm still seeing some flicker.

I wish we better understood why the websocket keeps closing:

WS closed abnormally - starting polling loop over! k8s-actions.ts:216
destroying websocket: /api/kubernetes/apis/apiregistration.k8s.io/v1/apiservices?watch=true&resourceVersion=106518 ws-factory.js:250
apiservices timed out - restarting polling

@alecmerdler
Copy link
Contributor Author

alecmerdler commented Sep 28, 2018

@spadgett When writing the PackageManifest API server, I was seeing this in the logs occacionally:

streamwatcher.go:103] Unexpected EOF during watch stream event decoding: unexpected EOF

This may be a problem with Kubernetes API server code in general. Regardless, this fix will work for non-admin users who have to use polling instead of listing apiservices.

@spadgett
Copy link
Member

I'm seeing some other errors with this change:

No model registered for Pod firehose.jsx:146
[Show/hide message details.] TypeError: props.obj is undefined[Learn More] horizontal-nav.jsx:103
./public/components/utils/horizontal-nav.jsx/HorizontalNav.prototype.render
horizontal-nav.jsx:103

@alecmerdler alecmerdler force-pushed the CONSOLE-812 branch 3 times, most recently from 2df679f to 993bd2d Compare October 1, 2018 14:46
@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 1, 2018
@alecmerdler alecmerdler force-pushed the CONSOLE-812 branch 7 times, most recently from a5702bc to 2664136 Compare October 1, 2018 20:20
@@ -281,16 +281,20 @@ class NamespaceDropdown_ extends React.Component {

const NamespaceDropdown = connect(namespaceDropdownStateToProps)(NamespaceDropdown_);

const NamespaceSelector_ = ({useProjects, inFlight}) => inFlight
const NamespaceSelector_ = ({useProjects, inFlight, loaded}) => inFlight && !loaded
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to prevent this component from re-rendering.

@@ -94,14 +103,25 @@ export const NavBar = ({pages, basePath}) => {
};
NavBar.displayName = 'NavBar';

/** @augments {React.PureComponent<{className?: string, label?: string, pages: {href: string, name: string, component: React.ComponentType}[], match: any, resourceKeys?: string[]}>} */
export class HorizontalNav extends React.PureComponent {
export class HorizontalNav extends React.PureComponent<HorizontalNavProps> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No changes here other than converting to TypeScript.

k8sModels: resources.reduce((models, {kind}) => models.set(kind, k8s.getIn(['RESOURCES', 'models', kind])), ImmutableMap()),
loaded: reduxIDs.every(id => k8s.getIn([id, 'loaded'])),
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 So this solution prevents the entire view from being re-rendered, but something is causing Firehose to be unmounted when RESOURCES.inFlight changes, which causes the WebSockets to be briefly terminated. However, the re-rendering only affects the list rows now and is pretty fast.

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 @alecmerdler. This is a huge improvement 👍

We can investigate Firehose getting unmounted separately.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 2, 2018
@spadgett
Copy link
Member

spadgett commented Oct 2, 2018

/hold

@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 Oct 2, 2018
@spadgett
Copy link
Member

spadgett commented Oct 2, 2018

Holding to make sure our CI runs

@openshift-ci-robot openshift-ci-robot removed lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 2, 2018
builder-run.sh Outdated
@@ -30,5 +30,6 @@ docker run $ENV_STR --rm --net=host \
--user="${BUILDER_RUN_USER}" \
$VOLUME_MOUNT \
-v "$(pwd)":/go/src/github.com/openshift/console \
--shm-size=256m \
Copy link
Contributor Author

@alecmerdler alecmerdler Oct 5, 2018

Choose a reason for hiding this comment

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

Used this suggestion to fix the WebDriver error.

@alecmerdler alecmerdler force-pushed the CONSOLE-812 branch 7 times, most recently from 74093b7 to 59c5187 Compare October 8, 2018 15:24
@openshift openshift deleted a comment from spadgett Oct 8, 2018
@alecmerdler alecmerdler force-pushed the CONSOLE-812 branch 11 times, most recently from c8e0fa3 to cb24649 Compare October 9, 2018 17:49
@@ -82,13 +82,15 @@ describe('Performance test', () => {
};

it(`downloads new bundle for ${routeName}`, async() => {
await browser.get(`${appHost}/status/all-namespaces`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding this fixes the weird "Performance" e2e test failure.

@spadgett
Copy link
Member

spadgett commented Oct 9, 2018

👍

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 9, 2018
@openshift-merge-robot openshift-merge-robot merged commit 58cdcbb into openshift:master Oct 9, 2018
@alecmerdler alecmerdler deleted the CONSOLE-812 branch October 9, 2018 22:41
@spadgett spadgett mentioned this pull request Oct 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants