-
Notifications
You must be signed in to change notification settings - Fork 364
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: reduce the number of api calls from Workspace Create Modal #9735
Conversation
✅ Deploy Preview for determined-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9735 +/- ##
=======================================
Coverage 53.34% 53.35%
=======================================
Files 1257 1257
Lines 154493 154522 +29
Branches 3298 3307 +9
=======================================
+ Hits 82422 82451 +29
Misses 71921 71921
Partials 150 150
Flags with carried forward coverage won't be shown. Click here to find out more.
|
cc0159c
to
779a5d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes working great! added some comments especially around improvements to the approach I proposed given that you're now making the getKubernetesResourceManagers
call in the cluster store.
also one concern is that the code coverage numbers for this PR are low, and we're trying to improve unit testing/line coverage for web. I don't necessarily think we need to block this fix/release on it, but could you create a separate ticket for going back and adding unit tests for this?
webui/react/src/pages/WorkspaceList/WorkspaceActionDropdown.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if namespaceBindingsList
and resourceQuotasList
need to be fresh per open, i strongly suggest keeping the useAsync
calls and instead adding the open and resourceManagers checks to the workspaceId checks. As is, manually calling the callbacks introduces edge cases around stale information overwriting new information.
e23340e
to
62ad3f2
Compare
62ad3f2
to
6c18698
Compare
const resourceQuotasList = useAsync( | ||
async (canceller) => { | ||
if (workspaceId === undefined) { | ||
if (workspaceId === undefined || Loadable.getOrElse([], resourceManagers).length <= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: array length cant be negative
if (workspaceId === undefined || Loadable.getOrElse([], resourceManagers).length <= 0) { | |
if (workspaceId === undefined || Loadable.getOrElse([], resourceManagers).length === 0) { |
questions: i see workspaceId === undefined || Loadable.getOrElse([], resourceManagers).length <= 0
prevent APIs in useAsync
to be called many times. Just wondering if its safe enough. are there any situations that pass through the conditions and end up calling many API calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a good point -- i do think we need to keep whether or not the modal is open as a prop because once resourceManagers
returns a non-zero length, all the other modals in the sidebars will begin to make requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically my suggestion was to use the workspaceId
check to function the same as the open
prop check -- it's only defined when the user opens an edit modal, then goes back to undefined
onClose
. always undefined
on create modals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: in addition to changing length check, we could consolidate all of these to one reused var, something like const resourceManagers = Loadable.getOrElse([], loadableResourceManagers)
webui/react/src/pages/WorkspaceList/WorkspaceActionDropdown.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backend LGTM; had a question, suggestion, or whatever for some frontend code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for finding the BE fixes for those errors! please note nit comment and test coverage concern, but other than that web LGTM.
const resourceQuotasList = useAsync( | ||
async (canceller) => { | ||
if (workspaceId === undefined) { | ||
if (workspaceId === undefined || Loadable.getOrElse([], resourceManagers).length <= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: in addition to changing length check, we could consolidate all of these to one reused var, something like const resourceManagers = Loadable.getOrElse([], loadableResourceManagers)
created https://hpe-aiatscale.atlassian.net/browse/DET-10445 for writing tests @johnkim-det |
2f1fb54
to
023f582
Compare
(cherry picked from commit 20ed126)
Ticket
DET-10443
Description
Workspace Create Modal was calling 3 API's multiple times - which was slowing down the webUi severely. Reduced the number of calls and made the code more efficient.
Test Plan
Check for both Agent and Kubernetes RM for both admin/non admin users:
Verify that Namespace Bindings and Resource Quotas can only be set by Cluster Admins in the webui
Checklist
docs/release-notes/
See Release Note for details.