serviceability: allow count > max in Device::validate#3600
Merged
Conversation
Remove the structural count <= max invariants in Device::validate so operators can lower a per-device cap below the live count. Admission- time gates in user create_core enforce the cap when new users connect, so reducing the cap simply prevents further growth and lets the live count drain through natural churn. Affects all four caps: max_users, max_unicast_users, max_multicast_subscribers, max_multicast_publishers. Before this change, 'doublezero device update --max-multicast-subscribers N' (or any of the other caps) failed with MaxMulticastSubscribersExceeded whenever the current count exceeded N, blocking graceful shrinking.
6db0de2 to
1d7c814
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
count <= maxinvariants fromDevice::validate(max_users,max_unicast_users,max_multicast_subscribers,max_multicast_publishers) so operators can lower a per-device cap below the live count.processors/user/create_core.rscontinue to reject new users when the cap is hit, so reducing the cap simply prevents further growth and the live count drains through natural churn.max_users, and extends the same operator-friendly behavior to the per-type caps added in serviceability: add per-device unicast and multicast user limits #2863.Why
Today
doublezero device update --max-multicast-subscribers N(or any of the other caps) fails withMaxMulticastSubscribersExceededwhenever the current count exceeds N — making the cap a hard floor at the live count. There's no graceful way to shrink a cap. The structural invariant invalidate()duplicates the admission check at user creation time; only the admission check meaningfully gates behavior, so removing the structural one is safe.Example on testnet:
Testing Verification
test_state_device_validate_error_max_users_exceeded,test_max_users_exceeded) to instead assert thatvalidate()succeeds whencount > maxfor all four caps.device_test.rs(11 pass) anduser_tests.rs(6 pass) to confirm nothing else relied on the structural invariant.