The quota limits are dynamic, specified in a variable in the policy configuration. You can choose the limit, by setting a value into the variable, and specifying that variable.
<Quota name='Q-1'>
<Interval>1</Interval>
<TimeUnit>minute</TimeUnit>
<Allow countRef='my_custom_variable'/>
<Identifier ref='tenant_id'/>
<Distributed>true</Distributed>
<Synchronous>false</Synchronous>
<PreciseAtSecondsLevel>false</PreciseAtSecondsLevel>
</Quota>
Presumably you will read “my_custom_variable” from the KVM. It will normally hold the “standard” value, whatever it is (maybe 100). At some point you can update that value, and when the KVM cache expires and the value is re-read from persisted store, you will get that updated value (maybe 1000) into the variable.
At that point the Quota will enforce on the new, updated limit.
I am not clear on what will happen, in the case that you update the value of the limit, during a counting interval. (During a particular minute). I suppose that if the quota bucket is partially full, for example maybe the count is at 68, the limit was 100, and then you then raise the limit to 1000 via the KVM update I just described. I suppose in this case the quota would just work the way you want for the duration of the minute. I’ve never tested this, so it’s worth testing yourself. If it doesn’t work this way out of the box you may need to execute a “ResetQuota” policy when you update the KVM.
There is also the case in which the quota has already been exceeded for the tenant, for a particular time bucket - for example the quota count is 102, and the limit is 100, and the client has already received several 429 status codes. If you then raise the limit to 1000, I am not sure of the behavior here, either. Mayb e it will just work the way you want, or maybe you will need ResetQuota.
Just test it and either way, you know what to do.
The 2nd part of your ask is to reset the quota back to “normal”, automatically.
I think if you want automatic behavior you will need to use a 2nd KVM, to flag that. Then daisy chain several KVM reads with conditions, to accomplish what you want. Eg
- Read KVM entry for “specialquota” for a particular tenant
- if there is a special quota setting
- check “expiry” time on special quota (this is a 2nd data item stored in the KVM entry)
- if the expiry has not passed, then set my_quota_limit to the limit specified in the specialquota
- if there is no special quota
- read from “standardquota” KVM element.
- set my_quota_limit to that value
- enforce Quota on my_quota_limit