[pbs-devel] [PATCH proxmox-backup] fix #5622: backup client: properly handle rate/burst parameters

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Aug 7 21:20:52 CEST 2024


On 23/07/2024 12:04, Dominik Csapak wrote:
> the rate and burst parameters are integers, so the mapping from value
> with `.as_str()` will always return `None` effectively never
> applying any rate limit at all.
> 
> To fix it, just map from u64 to HumanByte.
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> 
> Alternatively, we could introduce a new string schema to parse into
> HumanByte, if that's preferred. (Did not do it that way, because this
> fix was way faster for me and is also OK in my opinion).

I mean, tbh. it seems like this was the original intention, i.e. that one can
also pass HumanByte here, which would be pretty convenient. 

FWIW, this was u64 back when added and there's a commit that changes this in a
(buggy) way to the as_str, when HumanByte got introduced:

2d5287fb ("use RateLimitConfig for HttpClient and pull")

Sadly the comment message of this and the previous ones are basically
non-existent, but I faintly remember that Dietmar and I talked about this back
then, and I'm pretty sure that my stance back then is as now: I find it odd
that the API and config can have this written in HumanByte form but not on the
CLI, where it'd be actually the most useful place; as the API is either
accessed through web UI, where one can transform this from a human readable
form to bytes or through a automation system, which normally have ways to
allow X*1024 or the like calculations.

So I'd rather go towards a HuamnByte based schema, albeit as the
TRAFFIC_CONTROL_RATE_SCHEMA and TRAFFIC_CONTROL_BURST_SCHEMA are only used
in the client CLI code anyway I'd actually drop them from pbs-api-types as
they are obviously confusing (not used in the actual API) and either declare a
ClientRateLimitConfig struct there (that is then flattened in the client backup
schema definition) or just have something directly in the client code.





More information about the pbs-devel mailing list