refactor(kubernetes): A few minor refactors and perf fixes #3813
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These are all small changes I had on local branches while I was doing performance profiling. The refactor commits have no performance effect, but I made them while trying to split up the code into smaller pieces that I could understand better so I think they're worth commiting for that reason.
perf(kubernetes): Reduce deserialization of kubernetes pods
We're currently deserializing the entire kubernetes pod object when we actually only need the status. Given that pods are very common objects, it's worth only deserializing the status to speed up the server groups endpoint.
refactor(kubernetes): Remove unused variable isNamespaced
refactor(kubernetes): Pull some logic from translateClusters
The translateCluster function gets both server groups and load balancers; it would be more clear to have separate functions to do each of these.
refactor(kubernetes): Remove translateCluster function
Now that translateCluster has been split into two smaller functions, remove it and call the two smaller ones.