Repository navigation
Description
User Story
As an operator who deletes workspaces, I want to know what state a workspace is in after workspace delete is refused, so I can predict whether its users can still create resources in it.
Problem Statement
DeleteWorkspace marks the workspace Terminating (sets deletion_time and the phase) before it checks for blocking resources. If any exist, it returns failed_precondition ("still contains resources"). The workspace stays Terminating and rejects new resources until the blocking ones are removed and the delete is retried. See crates/openshell-server/src/grpc/workspace.rs.
Nothing public says this. The DeleteWorkspace RPC comment is "Delete a workspace by name", WorkspacePhase has no comments, and the docs show only the workspace delete command. The conformance tests added in #4607 assert the behavior, which conformance should do only for public contracts.
Impact / Why This Matters
A refused delete changes the workspace's state and blocks new creates, which a user wouldn't expect from an error. It differs from a Kubernetes namespace delete, which cascades instead of refusing. The marking does close a real race: without it, a create could slip in between the resource scan and the final delete.
Proposed Design
Decide one of:
- Keep the behavior and make it a contract. Document it in the
DeleteWorkspaceandWorkspacePhaseproto comments and in the workspace docs. The conformance assertions then stay as they are. - Refuse without a state change. Scan for blocking resources first and return the error with the workspace still
Active. If the scan is empty, markTerminatingand scan again to close the race. Update the conformance tests to match.
Acceptance Criteria
- The state after a refused delete is documented in the proto comments and the workspace docs, or the behavior is changed as in option 2.
- The
workspace_terminating_rejects_createsandworkspace_full_crud_lifecycleconformance tests assert only documented behavior.
Alternatives Considered
Cascade-delete the blocking resources, as Kubernetes does for a namespace. This removes user data on one command, so it needs a separate decision.
Context
Raised while reviewing #4607. The tests there preserve what the legacy workspace_lifecycle e2e test already asserted.
Activity