I have a simple Quota policy that I want to reset by using the ResetQuota policy, but I cannot get ResetQuota to work. My Quota policy:
<Quota async="false" continueOnError="false" enabled="true" name="Quota-PreFlow"> <DisplayName>Quota-PreFlow</DisplayName> <Interval>1</Interval> <TimeUnit>hour</TimeUnit> <Allow count="100"/> <Synchronous>true</Synchronous> <Distributed>true</Distributed> </Quota>
If I call ResetQuota with no Identifier, current count is unchanged meaning ResetQuota did nothing. Shouldn't it be reset to 100?:
<ResetQuota async="false" continueOnError="false" enabled="true" name="Reset-Preflow-Quota"> <DisplayName>Reset Preflow Quota</DisplayName> <Quota name="Quota-PreFlow"> </Quota> </ResetQuota>
I then added an Identifier in the Quota policy:
<Quota async="false" continueOnError="false" enabled="true" name="Quota-PreFlow"> <DisplayName>Quota-PreFlow</DisplayName> <Interval>1</Interval> <TimeUnit>hour</TimeUnit> <Allow count="100"/> <Synchronous>true</Synchronous> <Distributed>true</Distributed> <Identifier ref="request.queryparam.id"/> </Quota>
Before ResetQuota policy, the count for the id="smg" was 96. After the ResetQuota it was 196, meaning the value in ResetQuota was added to current count - it was not reset to 100.
<ResetQuota async="false" continueOnError="false" enabled="true" name="Reset-Preflow-Quota"> <DisplayName>Reset Preflow Quota</DisplayName> <Quota name="Quota-PreFlow"> <Identifier name="identifierName" ref="request.queryparam.id"> <Allow>100</Allow> </Identifier> </Quota> </ResetQuota>
If I take <Allow> out of ResetQuota, then it does nothing. After the call, the current count for the Quota is unchanged:
<ResetQuota async="false" continueOnError="false" enabled="true" name="Reset-Preflow-Quota"> <DisplayName>Reset Preflow Quota</DisplayName> <Quota name="Quota-PreFlow"> <Identifier name="identifierName" ref="request.queryparam.id"> </Identifier> </Quota> </ResetQuota>
Some more info. For the first scenario with no identifier, here are the flow vars.
Before:
ratelimit.Quota-PreFlow.allowed.count 100 ratelimit.Quota-PreFlow.available.count 97 ratelimit.Quota-PreFlow.identifier _default ratelimit.Quota-PreFlow.total.exceed.count 0 ratelimit.Quota-PreFlow.used.count 3
After:
ratelimit.Quota-PreFlow.allowed.count 100 ratelimit.Quota-PreFlow.available.count 96 ratelimit.Quota-PreFlow.identifier _default ratelimit.Quota-PreFlow.total.exceed.count 0 ratelimit.Quota-PreFlow.used.count 4
With the identifier "smg".
Before:
ratelimit.Quota-PreFlow.allowed.count 100 ratelimit.Quota-PreFlow.available.count 95 ratelimit.Quota-PreFlow.identifier smg ratelimit.Quota-PreFlow.total.exceed.count 0 ratelimit.Quota-PreFlow.used.count 5
After:
ratelimit.Quota-PreFlow.allowed.count 100 ratelimit.Quota-PreFlow.available.count 194 ratelimit.Quota-PreFlow.identifier smg ratelimit.Quota-PreFlow.total.exceed.count 0 ratelimit.Quota-PreFlow.used.count -94
@sgilson , I can able to reproduce same, Policy name is misleading in this case. Ideally it should reset to original counter value instead of adding the count to existing available count. Yes, It doesn't work on global identifier.
Thanks @Anil Sagar, based on how it seems to work, the ResetQuota policy should really be called "IncreaseQuota" or "TempIncreaseQuota" because the way it works is:
- Add a value to available.count
- Subtract that same value from used.count
- Discard the changes when the Quota policy next resets
Answer by sgilson · Nov 12, 2015 at 04:07 PM
I updated the ResetQuota doc with this info.
Stephen