Repository navigation
feat(api): delete an application with a confirmation - #323
Conversation
An application could not be deleted: only removing its whole environment removed it. Deleting needs environment.update on the application's environment and a confirmation token for application.delete on that application, issued after its name was typed and spent in the same transaction. It is refused while a replica is placed or a deployment runs, so no container is left on a server: stop the application first. A confirmable action can now be authorized on an environment. The runtime database role may delete rows of applications; their deployments, releases, allocations and domains go by cascade only. Refs #256 Signed-off-by: samuel mbabhazi <[email protected]>
…application Refs #256 Signed-off-by: samuel mbabhazi <[email protected]>
Refs #256 Signed-off-by: samuel mbabhazi <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Second part of #256 (application lifecycle): deleting an application. Stopping one is #321; the screen follows in its own pull request.
What changed
An application could not be deleted: only removing its whole environment removed it.
POST …/applications/{applicationId}/delete(204) deletes it. It needsenvironment.updateon the application's environment, so who administers the environment may delete and a developer may not, and a confirmation token forapplication.deleteon that application.application_runningwith a placed replica, 409deployment_in_progresswith a running deployment. No container can be left on a server by a deletion: the application is stopped first (feat(api): stop an application #321). A refusal does not spend the confirmation.application.deletejoins the closed catalog withenvironment.update. Issuance reads the application first to learn where it lives; an unknown application and one the requester may not administer both answer 404.node.removeis unchanged.application.deletedwith the application's name and the confirmation id.openapi.json, the API client and the route and role matrix are regenerated; SPEC 3.6, 7 and 8 describe the action, who may use it and the route.The database privilege
deploy/postgres/runtime-role.sqlgave the API noDELETEonapplications, on purpose: applications were removed only with their environment. This change grantsDELETEonapplications, and on no table that depends on it: deployments, allocations and observations still cannot be deleted by the API, only by the cascade of an application or an environment. Existing installations get the grant when the stack restarts with the new image, because thedatabase-roleservice applies that file on every start.How it was tested
Unit tests for the confirmation: the permission is asked where the application lives, for members and for API tokens; an unknown application, a resolver that does not say where the resource lives and a refused permission all answer a missing resource; a token for
application.deletecannot remove a server.Integration tests with PostgreSQL, the HTTP API, the real pipeline and the restricted runtime role:
Eight mutations, each caught (one needed that last test first), including the missing database privilege, which shows as a 503.
On a real control plane (the rig of feat(api): stop an application #321, switched to an image built from this branch, with the runtime role provisioned by the real
database-roleservice):application_running; the application is still thereconfirmation_name_mismatchapplication.deletedwith their confirmation ids, threeconfirmation.issuedNot tested
Security considerations
security-review: a destructive command with a confirmation token (rule 7), a wider database privilege for the runtime role, and the confirmation catalog extended to environment-scoped actions.environment.update, notdeploy.run. The catalog has no dedicatedapplication.deletepermission; adding one would change the role model and API token scopes, so it is left as an open question in SPEC 16.Summary by CodeRabbit