[pdm-devel] [PATCH proxmox-datacenter-manager v2 03/28] pdm-api-types: add CollectionSettings type

Stefan Hanreich s.hanreich at proxmox.com
Tue Feb 18 16:31:09 CET 2025



On 2/18/25 16:26, Wolfgang Bumiller wrote:
> On Fri, Feb 14, 2025 at 02:06:28PM +0100, Lukas Wagner wrote:
>> This commit adds the CollectionSettings type which holds settings for
>> the metric collection system. Included are collection interval, max
>> concurrency and upper/lower bounds for the metric collection loop.
>>
>> Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
>> ---
>>  lib/pdm-api-types/src/lib.rs               |   3 +
>>  lib/pdm-api-types/src/metric_collection.rs | 188 +++++++++++++++++++++
>>  2 files changed, 191 insertions(+)
>>  create mode 100644 lib/pdm-api-types/src/metric_collection.rs
>>
>> diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs
>> index 38449071..6115e41c 100644
>> --- a/lib/pdm-api-types/src/lib.rs
>> +++ b/lib/pdm-api-types/src/lib.rs
>> @@ -19,6 +19,9 @@ pub use acl::*;
>>  mod node_config;
>>  pub use node_config::*;
>>  
>> +mod metric_collection;
>> +pub use metric_collection::*;
>> +
>>  mod proxy;
>>  pub use proxy::HTTP_PROXY_SCHEMA;
>>  
>> diff --git a/lib/pdm-api-types/src/metric_collection.rs b/lib/pdm-api-types/src/metric_collection.rs
>> new file mode 100644
>> index 00000000..92487d6c
>> --- /dev/null
>> +++ b/lib/pdm-api-types/src/metric_collection.rs
>> @@ -0,0 +1,188 @@
>> +//! API types for metric collection settings.
>> +
>> +use serde::{Deserialize, Serialize};
>> +
>> +use proxmox_schema::{api, Updater};
>> +
>> +/// Default metric collection interval.
>> +pub const DEFAULT_COLLECTION_INTERVAL: u64 = 600;
>> +
>> +/// Minimum metric collection interval.
>> +pub const MIN_COLLECTION_INTERVAL: u64 = 10;
>> +
>> +/// Maximum metric collection interval.
>> +/// PVE and PBS keep 30 minutes of metric history,
>> +/// maximum is set to 25 minutes to leave some headroom.
>> +pub const MAX_COLLECTION_INTERVAL: u64 = 1500;
>> +
>> +/// Default number of concurrent connections.
>> +pub const DEFAULT_CONCURRENCY: usize = 10;
>> +/// Maximum number of concurrent connections.
>> +pub const MAX_CONCURRENCY: u64 = 50;
>> +/// Minimum number of concurrent connections (no concurrency).
>> +pub const MIN_CONCURRENCY: u64 = 1;
>> +
>> +/// Default upper bound for the random delay for the
>> +/// main metric collection loop.
>> +pub const DEFAULT_MAX_OFFSET: u64 = 10;
>> +/// Default lower bound for the random delay for the
>> +/// main metric collection loop.
>> +pub const DEFAULT_MIN_OFFSET: u64 = 0;
>> +
>> +/// Highest configurable upper bound for the random interval offset for the main loop.
>> +pub const MAX_INTERVAL_OFFSET: u64 = 300;
>> +/// Lowest configureable lower bound for the random interval offset for the main loop.
>> +pub const MIN_INTERVAL_OFFSET: u64 = 0;
>> +
>> +/// Default upper bound for the random individual connection delay.
>> +pub const DEFAULT_MAX_CONNECTION_DELAY: u64 = 100;
>> +/// Default lower bound for the random individual connection delay.
>> +pub const DEFAULT_MIN_CONNECTION_DELAY: u64 = 0;
>> +
>> +/// Highest configurable upper bound for the random individual connection delay.
>> +pub const MAX_CONNECTION_DELAY: u64 = 1000;
>> +/// Lowest configurable lower bound for the random individual connection delay.
>> +pub const MIN_CONNECTION_DELAY: u64 = 0;
>> +
>> +#[api(
>> +    properties: {
>> +        "collection-interval" : {
>> +            optional: true,
>> +            default: DEFAULT_COLLECTION_INTERVAL as isize,
>> +            minimum: MIN_COLLECTION_INTERVAL as isize,
>> +            maximum: MAX_COLLECTION_INTERVAL as isize,
> 
> I thought about this the first time around but then forgot again:
> 
> Given that it is possible we might change these types (see Stefan's
> patch for proxmox-schema) and because it is much more convenient
> anyway you could use `as _` for these casts.

fyi: I put it on the backburner for now, because the methods in SDN all
got a new parameter (because of locking). This removed the necessity of
the patch from my pov - but I can pick it up again today/tomorrow if we
want it somewhere else.




More information about the pdm-devel mailing list