Repository navigation
Enforce data caps: suspend an account when its usage reaches its quota - #18
Merged
Merged
Conversation
Nothing ever suspended an account over its quota, so a capped account kept working without limit. One rule now lives in store/limits.go and is applied on the traffic path (same transaction as the usage update), at read time (beside the existing expiry reconcile), and at the end of PATCH, renew and reset-usage: - An active account whose usage reaches a non-null quota is suspended with quota_exceeded; nodes drop it on their next heartbeat. Other suspend reasons and deleted accounts are never touched; a NULL quota is unlimited. - Expired wins over quota_exceeded, and adding data never revives an expired account. - A PATCH that raises the quota above usage lifts quota_exceeded; one that lowers it to usage or below suspends. Renew, reset-usage and clear_data_quota still lift. - POST /enable on an account still over its cap answers 409 quota_exhausted instead of switching it on to be suspended again a heartbeat later. - The reseller bulk reactivate and the quota report use the same rule. - Side fix: the reseller guard in EnableAccount was not NULL-safe, so a reseller enabling an already-active account got 403. README (en/fa): the bot API additions and how data caps behave. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Nothing ever suspended an account over its quota, so a capped account kept working without limit. One rule now lives in store/limits.go and is applied on the traffic path (same transaction as the usage update), at read time (beside the existing expiry reconcile), and at the end of PATCH, renew and reset-usage:
README (en/fa): the bot API additions and how data caps behave.