Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
Coverage Report for CI Build 39458686287Coverage increased (+0.02%) to 55.64%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
CheckProjectDelete returns can_delete and the blockers that would refuse DeleteProject, with the number of blocking resources per namespace. It changes nothing. The caller needs delete permission on the project. Both check RPCs now copy the blocker count into the response.
26f3314 to
da8dac4
Compare
26c0f21 to
2e14945
Compare
|
Sandbox run: a local Frontier server with Postgres and SpiceDB in Docker, called over the Connect protocol. The binary was built from #2014 with #2011 applied, so it has main plus #2008, #2011, #2013 and #2014. Deletion config used: app:
deletion:
enabled: true
resources:
resource/aoi: { project: block, organization: allow }
resource/workflow: { project: block, organization: allow }
resource/orderitem: { project: block_unless_deletable, organization: block_unless_deletable }
resource/insight: { project: allow, organization: allow }
|
| Check | Expected | Observed |
|---|---|---|
| Check an empty project (owner) | ok, can_delete=true, no blockers | ok, can_delete=true, no blockers |
| Check by an org viewer (no delete permission) | permission_denied | permission_denied |
| Check by a user outside the org | permission_denied | permission_denied |
| Check with the project name instead of the id | not_found | not_found |
| Check with an unknown id | permission_denied | permission_denied |
| Check the first project above after deleting its 4 blocking resources (the finished order item stays) | ok, can_delete=true, no blockers | ok, can_delete=true, no blockers |
| Check a project holding only an insight (rule allow) | ok, can_delete=true, no blockers | ok, can_delete=true, no blockers |
With enabled: false, check a project holding an AOI and a resource/report |
ok, can_delete=true, no blockers | ok, can_delete=true, no blockers |
Summary
Adds the
CheckProjectDeletehandler. It returnscan_deleteand the blockers that would refuseDeleteProject, eachRESOURCES_EXISTblocker with the number of blocking resources incount. It changes nothing, so a client can show the blockers before the user tries to delete. Stacked on #2008.Changes
core/deleter/service.go:CheckProjectDeletefinds the project and returnsProjectResourceBlockers.DeleteProjectandCheckProjectDeleteshare one lookup,getProject: an id that is not a uuid returnsproject.ErrInvalidUUID, and a missing project returnsproject.ErrNotExist. Disabled projects are found.internal/api/v1beta1connect/deleter.go: theCheckProjectDeletehandler answersnot_foundfor a missing project or an id that is not a uuid.transformBlockersToPBbuilds the response blockers for both check RPCs and now copiescount.internal/api/v1beta1connect/interfaces.go,mocks/cascade_deleter.go:CheckProjectDeleteonCascadeDeleter; mock regenerated.pkg/server/connect_interceptors/authorization.go:CheckProjectDeleteneeds delete permission on the project, the same asDeleteProject. Without a rule every call was denied.Test Plan
core/deleter/service_test.goTestCheckProjectDelete: two blocking resources come back as one blocker with count 2; an allowed resource gives no blockers; a missing project returnsproject.ErrNotExist; a name returnsproject.ErrInvalidUUID.TestDeleteProjectpasses unchanged.internal/api/v1beta1connect/deleter_test.goTestHandler_CheckProjectDelete: blockers with their count andcan_deletefalse;can_deletetrue with no blockers;not_foundfor a missing project and for a name.TestProjectDeleteRefusedWhileResourcesBlock: the check reports thecompute/orderblocker with count 1 before the delete, andcan_deletetrue once the resource is deleted.go test ./core/... ./internal/api/... ./pkg/server/...passes.TestEndToEndAPIRegressionTestSuite,TestEndToEndServiceUsersRegressionTestSuiteandTestEndToEndPATRegressionTestSuitepass.golangci-lint run ./core/deleter/... ./internal/api/v1beta1connect/... ./pkg/server/... ./test/e2e/regression/...reports no issues.