Repository navigation
feat(deleter): project delete soft-deletes its resources - #2013
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 55 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
Coverage Report for CI Build 39894875643Coverage decreased (-0.02%) to 55.697%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
|
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 }
Resources of a deleted project
Project row and access after the delete (from #2007, together with this PR)
|
0568226 to
74cb6ad
Compare
9b57ea6 to
54f916c
Compare
The project delete now deletes the project's live resources with Delete, which keeps the row and removes its SpiceDB tuples, instead of purging every row. A resource that is already gone is skipped. Purge and resource.Filter.IncludeDeleted have no users left and are removed.
The API suite allows compute/volume for both deletes and creates its permission in the suite setup. The project in TestProjectDeleteKeepsTheRowAndRemovesAccess gets a compute/volume resource, and its row is kept with deleted_at set after the delete.
487ee5d to
46950f2
Compare
Summary
The project delete now soft-deletes the project's live resources with
resource.Service.Delete, which keeps the row and removes its SpiceDB tuples, instead of purging every row. A resource that is already gone is skipped, like the org's own resources.Purgeandresource.Filter.IncludeDeletedonly existed so the old hard project delete could clear every row that pointed at the project. The project row is now kept, so both are removed. Stacked on #2008.Changes
core/deleter/service.go: the resource step lists live resources only and callsDelete, skippingresource.ErrNotExist. The order stays: policies, then resources, then the project row. Each removed resource gets theresource.deletedaudit record that the resource delete API also writes.core/resource/service.go,core/resource/resource.go,internal/store/postgres/resource_repository.go:Purgeremoved from the service, the repository interface, and the repository. The deleter'sResourceServiceinterface drops it too; both mocks are regenerated.core/resource/filter.go,internal/store/postgres/resource_repository.go:IncludeDeletedremoved;Listalways skips deleted rows.test/e2e/regression/api_test.go: the org delete test with a disabled project now gives that project a resource. The suite allowscompute/volumefor both deletes and creates its permission in the setup, and the project inTestProjectDeleteKeepsTheRowAndRemovesAccessgets acompute/volumeresource.Test Plan
core/deleter/service_test.go: the project and org delete cases expect a live-only list andDelete; a resource that is already gone does not stop the project delete.TestPurgeremoved fromcore/resource/service_test.goandinternal/store/postgres/resource_repository_test.go, with theIncludeDeletedassertion inTestSkipsSoftDeletedResources.TestOrganizationDeleteAlsoDeletesDisabledProjectsAndGroups: after the org delete, the disabled project's row and its resource's row are kept withdeleted_atset. With the resource delete reading the project through the lookup that hides disabled projects, the org delete fails withfailed to get project, so the test covers fix(resource): a resource in a disabled project can be deleted #2006's lookup.TestProjectDeleteKeepsTheRowAndRemovesAccess: afterDeleteProject, the project'scompute/volumeresource row is kept withdeleted_atset. With the resource step skipped, this check fails.go test ./core/... ./internal/api/...and the resource and project repository suites pass.TestEndToEndAPIRegressionTestSuite,TestEndToEndServiceUsersRegressionTestSuiteandTestEndToEndPATRegressionTestSuitepass.golangci-lint run ./core/... ./internal/store/postgres/... ./test/e2e/regression/...reports no issues.SQL Safety
Listnow always starts fromfromLive(TABLE_RESOURCES), and the removedPurgewas the onlyDELETEon resources.ToSQL()callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Neverquery, _, err := ….?placeholders inside single-quoted SQL literals ingoqu.L.//nolint:forbidigoor// #nosec G20xannotations.