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

Only watch resources that are updated in UX. #3902

Merged
merged 3 commits into from
Dec 7, 2021

Conversation

absoludity
Copy link
Contributor

Signed-off-by: Michael Nelson minelson@vmware.com

Description of the change

Rather than watching all resources for an installed package (as Kubeapps has done for quite some time), this PR updates so that we only watch the resources which are updated in the UX and just fetch the rest once only when the AppView is mounted.

Benefits

Viewing Kubeapps, for example, now results in only 13 watches on the k8s API server (from the plugin), rather than ~40.

Possible drawbacks

Applicable issues

Additional information

Signed-off-by: Michael Nelson <minelson@vmware.com>
Signed-off-by: Michael Nelson <minelson@vmware.com>
Signed-off-by: Michael Nelson <minelson@vmware.com>
@@ -39,7 +39,7 @@ export const requestResources = createAction("REQUEST_RESOURCES", resolve => {
watch: boolean,
handler: (r: GetResourcesResponse) => void,
onError: (e: Event) => void,
onComplete: (pkg: InstalledPackageReference) => void,
onComplete: () => void,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was no need for the arg since it can be included via closure.

return () => {};
}

const parsedRefs = parseResources(app.apiResourceRefs);
setAppViewResourceRefs(parsedRefs);
return () => {};
}, [app, cluster, kinds, appViewResourceRefs]);
}, [app?.apiResourceRefs]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just cleaned up the dependencies (ie. we don't want to fire this effect whenever the app changes, only when the resource refs change).

@castelblanque
Copy link
Collaborator

Awesome! From 40 to 13 watches :)
Thank you!

@absoludity absoludity merged commit 69d86d0 into master Dec 7, 2021
@absoludity absoludity deleted the 3779-dont-watch-all-resources branch December 7, 2021 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update dashboard to use new k8s resources endpoint of api server
2 participants