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

Switch AppView to use new getResources. #3872

Merged
merged 5 commits into from
Dec 3, 2021
Merged

Conversation

absoludity
Copy link
Contributor

@absoludity absoludity commented Dec 1, 2021

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

Description of the change

Switches the AppView to use the new getResources action (using the resources plugin), with minimal changes to other code.

Checking the application detail for the Kubeapps app now only shows a single request for api server's getResources rather than 16 or so watch requests directly to the k8s api server:

kubeapps-watch-resources

And creating a new installation watches for updates so that the UI gets updated when pods are ready:

apache-install

Benefits

  • Single request for watching all resources.
  • No longer hitting the k8s API server to do so
  • Can now remove lots of code and simplify other code.

Possible drawbacks

See what CI says.

Applicable issues

Additional information

There will be a few PRs to follow removing lots of code, extracting the current ResourceRef model and all its dependencies, removing the request for all resource kinds from the server, and other indicated improvements like not watching all resources etc.

BTW: This is the third PR in a series, I've not yet landed the first until I hear that we're good to do so (ie., when the current release tag is final). Let me know :)

@absoludity
Copy link
Contributor Author

absoludity commented Dec 1, 2021

Hmm, CI disagrees with my local experience - with app details displayed without the resources. I'll check in the morning. EDIT: Fixed in 79bd8a4

Base automatically changed from 3779-dashboard-1-actions to master December 1, 2021 22:43
@@ -1,4 +1,5 @@
import actions from "actions";
import { getType } from "typesafe-actions";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've refactored a little in this file because the existing tests aren't testing that actions are dispatched by the view, but rather that the actions themselves are called... this meant that my test passed even though I'd missed dispatching the action. So I've left the existing tests as they are but updated the ones for the functionality that I'm changing so that they actually assert that the correct action is dispatched. The other issue I had from what I'd included in the diff yesterday was that I hadn't enabled the resources plugin :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the info and refactoring the test. I've just hit the same issue... the error message wasn't clear at all so, almost running out of ideas I decided to check if the resources plugin was enabled... 🤦

Signed-off-by: Michael Nelson <minelson@vmware.com>
Signed-off-by: Michael Nelson <minelson@vmware.com>
Signed-off-by: Michael Nelson <minelson@vmware.com>
Signed-off-by: Michael Nelson <minelson@vmware.com>
@absoludity
Copy link
Contributor Author

absoludity commented Dec 2, 2021

This PR is the next to merge into master, when reviewed - so if someone has time (I've added you antonio, but no problem if it waits for @castelblanque on Friday or next week... in fact I'll add you both ;) )

Copy link
Contributor

@antgamdia antgamdia left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks!
Sorry for the delay in taking a look at it... with the release I totally forgot about it.

@@ -33,4 +33,4 @@ maintainers:
name: kubeapps
sources:
- https://github.com/kubeapps/kubeapps
version: 7.6.2-dev0
version: 7.6.1-dev1
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if decreasing the version is intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, must have missed the patch when resolving the conflict. Updated.

@@ -1605,6 +1605,7 @@ kubeappsapis:
##
enabledPlugins:
- helm
- resources
Copy link
Contributor

Choose a reason for hiding this comment

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

😁

// TODO(minelson): Update to watch only those resources that
// we're interested in watching change (deployments, statefulsets etc.)
// and get the rest.
dispatch(actions.kube.getResources(app!.installedPackageRef!, app!.apiResourceRefs, true));
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess typescript transpiler is not smart enough to know app is != undefined at this point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure of the sequence of events, but it appears to be happy without them now.

// TODO(minelson): Update to watch only those resources that
// we're interested in watching change (deployments, statefulsets etc.)
// and get the rest.
dispatch(actions.kube.getResources(app!.installedPackageRef!, app!.apiResourceRefs, true));
return function cleanup() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! btw, we are not usually using cleanup functions. Perhaps at some point, we should revisit it to ensure we don't have any resource left (I recall to have seen some unmount warnings at the console)

Copy link
Contributor Author

@absoludity absoludity Dec 2, 2021

Choose a reason for hiding this comment

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

Yeah, it's required here, because unmounting this component triggers this cleanup letting us complete the request (and remove the subscription from the state, which reminds me, I want to remove it from the state as it's no longer necessary to track there. I'll do that in my current branch).

@absoludity absoludity merged commit fff3cfb into master Dec 3, 2021
@absoludity absoludity deleted the 3779-dashboard-2-appview branch December 3, 2021 03:16
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.

None yet

2 participants