fix(spurctld): delete sacctmgr users atomically - #451
Conversation
|
The core fix looks correct: a single transaction with proper rollback on partial failure ( One additional note: the new regression test is |
There was a problem hiding this comment.
Pull request overview
This PR fixes a correctness gap in the accounting RPC for sacctmgr delete user by making user/association deletion transactional, supporting “all accounts” deletion when the account field is omitted, and returning a gRPC NotFound instead of reporting success when nothing was actually deleted.
Changes:
- Update the
remove_usergRPC handler to detect zero deletions and returnStatus::not_foundinstead of false success. - Rework
db::remove_userto delete matchingassociationsandusersrows within a single SQL transaction, treating an emptyaccountas “all accounts”. - Add a focused PostgreSQL regression test covering one-account deletion, all-account deletion, association cleanup, and repeated deletion behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/spurctld/src/accounting/grpc.rs | Returns NotFound when remove_user deletes zero rows, avoiding misleading “Done.” on no-op deletes. |
| crates/spurctld/src/accounting/db.rs | Makes remove_user transactional across associations + users, supports empty-account-as-all, and adds a regression test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
40017c7 to
9003f06
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #451 +/- ##
==========================================
- Coverage 74.25% 74.24% -0.01%
==========================================
Files 165 165
Lines 59071 59425 +354
==========================================
+ Hits 43862 44116 +254
- Misses 15209 15309 +100 🚀 New features to boost your workflow:
|
056a7f7 to
b8d21dd
Compare
Fixes #435.
sacctmgr delete usercould reportDone.without deleting anything because the all-accounts form sent an empty account while the database required an exact account match. The RPC also ignored zero affected rows.This change deletes matching
usersandassociationsrows in one transaction, treats an omitted account as all accounts, and returnsNotFoundwhen no row was removed instead of reporting false success.Testing:
cargo fmt --all --checkcargo clippy --workspace --exclude spur-ffi --all-targets --lockedcargo test --locked