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

feat: allow users with role Viewer and above to view resource quotas #9822

Merged
merged 8 commits into from
Aug 15, 2024

Conversation

salonig23
Copy link
Contributor

@salonig23 salonig23 commented Aug 14, 2024

Ticket

DET-10430

Description

Allowed users with Viewer, Editor, Editor Restricted, Editor Project Restricted, Gen AI and Workspace Admin to be able to view resource quotas in the WebUI when RBAC is enabled. Cluster Admin can still modify and view resource quotas. Allowed all users to view quotas when RBAC is disabled. This involved allowing users who cannot modify the workspaces to also see the Edit Workspace Modal but they will be seeing a "Config" option instead of "Edit Workspace".

Test Plan

Set up minikube and create a namespace "test-ns" with a resource quota of 2.

  • Login as Cluster Admin and create a workspace "w1" with no namespace binding, "w2" with auto-created namespace binding and some resource quota. and "w3" with "test-ns" as the namespace.
  • Edit "w1" and change the binding to an auto-created namespace with some resource quota. Make sure it saves correctly.
  • Edit "w2" and change the binding to "test-ns". Make sure that the updated resource quota shows up as 2.
  • Edit "w3" and change the binding to an auto-created namespace with a resource quota of 2, and make sure that it saves correctly.
  • login with Workspace Admin, and try to make changes to some of the workspaces and make sure that resource quota is not editable and there are no errors while saving the workspaces.
  • log in as workspace creator and make sure that viewing resource quota is non visible.
  • log in with the rest of the roles and make sure that resource quotas show up correctly and noneditable for:
  1. Workspace with no binding
  2. workspace with binding but no quota
  3. workspace with autocreated binding and quota
  4. workspace with other namespace binding and quota

Checklist

  • Changes have been manually QA'd
  • New features have been approved by the corresponding PM
  • User-facing API changes have the "User-facing API Change" label
  • Release notes have been added as a separate file under docs/release-notes/
    See Release Note for details.
  • Licenses have been included for new code which was copied and/or modified from any external code

@cla-bot cla-bot bot added the cla-signed label Aug 14, 2024
Copy link

codecov bot commented Aug 14, 2024

Codecov Report

Attention: Patch coverage is 13.48315% with 77 lines in your changes missing coverage. Please review.

Project coverage is 54.35%. Comparing base (91d0b67) to head (1981395).
Report is 11 commits behind head on main.

Files Patch % Lines
...ebui/react/src/components/WorkspaceCreateModal.tsx 0.00% 56 Missing ⚠️
master/internal/workspace/authz_rbac.go 0.00% 9 Missing ⚠️
master/internal/api_workspace.go 0.00% 5 Missing ⚠️
master/internal/workspace/authz_permissive.go 0.00% 3 Missing ⚠️
master/internal/workspace/authz_basic_impl.go 0.00% 2 Missing ⚠️
...rc/pages/WorkspaceList/WorkspaceActionDropdown.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9822      +/-   ##
==========================================
- Coverage   54.38%   54.35%   -0.03%     
==========================================
  Files        1261     1261              
  Lines      155770   155842      +72     
  Branches     3540     3542       +2     
==========================================
- Hits        84711    84710       -1     
- Misses      70921    70994      +73     
  Partials      138      138              
Flag Coverage Δ
backend 45.20% <0.00%> (-0.04%) ⬇️
harness 72.61% <ø> (ø)
web 53.67% <17.14%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
webui/react/src/hooks/usePermissions.ts 77.17% <100.00%> (+0.35%) ⬆️
master/internal/workspace/authz_basic_impl.go 1.61% <0.00%> (-0.06%) ⬇️
...rc/pages/WorkspaceList/WorkspaceActionDropdown.tsx 0.00% <0.00%> (ø)
master/internal/workspace/authz_permissive.go 1.56% <0.00%> (-0.08%) ⬇️
master/internal/api_workspace.go 63.49% <0.00%> (-0.14%) ⬇️
master/internal/workspace/authz_rbac.go 0.35% <0.00%> (-0.02%) ⬇️
...ebui/react/src/components/WorkspaceCreateModal.tsx 0.00% <0.00%> (ø)

... and 6 files with indirect coverage changes

Copy link

netlify bot commented Aug 14, 2024

Deploy Preview for determined-ui ready!

Name Link
🔨 Latest commit 1981395
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/66be7f32c69af60008bfd4c1
😎 Deploy Preview https://deploy-preview-9822--determined-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@salonig23 salonig23 marked this pull request as ready for review August 15, 2024 16:32
@salonig23 salonig23 requested review from a team as code owners August 15, 2024 16:32
@salonig23 salonig23 removed the request for review from ShreyaLnuHpe August 15, 2024 17:18
Copy link
Contributor

@johnkim-det johnkim-det left a comment

Choose a reason for hiding this comment

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

looks like the e2e testing issue is related to a bug in this PR when editing an existing workspace -- the toggles don't seem to work.

webui/react/src/components/WorkspaceCreateModal.tsx Outdated Show resolved Hide resolved
webui/react/src/components/WorkspaceCreateModal.tsx Outdated Show resolved Hide resolved
webui/react/src/components/WorkspaceCreateModal.tsx Outdated Show resolved Hide resolved
webui/react/src/components/WorkspaceCreateModal.tsx Outdated Show resolved Hide resolved
webui/react/src/components/WorkspaceCreateModal.tsx Outdated Show resolved Hide resolved
err = workspace.AuthZProvider.Get().CanGetWorkspaceID(
ctx, *curUser, req.Id,
err = workspace.AuthZProvider.Get().CanViewResourceQuotas(
ctx, *curUser,
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of removing the CanGetWorkspaceID check, should we maybe do
a.getWorkspaceAndCheckCanDoActions(ctx, req.Id, false, workspace.AuthZProvider.Get().CanGetWorkspace, workspace.AuthZProvider.Get().CanViewResourceQuotas) so that we perform both of these checks? Or do we not need the CanGetWorkspaceID check here?

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 don't think we can check 2 permissions at a time, so I added both checks in a different way

Copy link
Contributor

@amandavialva01 amandavialva01 left a comment

Choose a reason for hiding this comment

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

This LGTM modulo one comment!
Can we maybe add some unit tests in postgres_rbac_intg_test.go just to make sure the permissions are properly added to these respective roles?

Copy link
Contributor

@johnkim-det johnkim-det left a comment

Choose a reason for hiding this comment

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

web LGTM

Copy link
Contributor

@amandavialva01 amandavialva01 left a comment

Choose a reason for hiding this comment

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

LGTM, awesome work!

@salonig23 salonig23 merged commit f7846cb into main Aug 15, 2024
82 of 96 checks passed
@salonig23 salonig23 deleted the allow-viewers-resource-quota branch August 15, 2024 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants