all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: Jakob-Tobias Winter <tobias@stuttgart.de>, pbs-devel@lists.proxmox.com
Subject: Re: [RFC PATCH proxmox 01/12] pbs-api-types: add types and schemas for snapshot attributes
Date: Mon, 16 Nov 2026 15:57:46 +0100	[thread overview]
Message-ID: <15657713-99a5-4a09-8310-2f832fca5131@proxmox.com> (raw)
In-Reply-To: <20261113085637.57360-4-tobias@stuttgart.de>

On 11/13/26 10:07 AM, Jakob-Tobias Winter wrote:
> Snapshots get attributes, each of them a key with a list of values.
> They are meant for information a client knows about the source of a
> backup, like the tags and the resource pool of a Proxmox VE guest.
> 
> An attribute is passed as 'KEY=VALUE', once per value of a key. A
> value is never joined with other values into one string, so a list
> of tags cannot be garbled by a separator.
> 
> Signed-off-by: Jakob-Tobias Winter <tobias@stuttgart.de>
> ---
>   pbs-api-types/src/datastore.rs | 22 +++++++++++++++++++++-
>   pbs-api-types/src/lib.rs       |  3 +++
>   2 files changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
> index 7685deee..978253ee 100644
> --- a/pbs-api-types/src/datastore.rs
> +++ b/pbs-api-types/src/datastore.rs
> @@ -1,4 +1,5 @@
>   use std::borrow::Borrow;
> +use std::collections::{BTreeMap, BTreeSet};
>   use std::convert::{AsRef, TryFrom};
>   use std::fmt;
>   use std::hash::{Hash, Hasher};
> @@ -28,7 +29,7 @@ use crate::{
>       DATASTORE_NOTIFY_STRING_SCHEMA, Fingerprint, GC_SCHEDULE_SCHEMA,
>       GROUP_OR_SNAPSHOT_PATH_REGEX_STR, GroupFilter, MaintenanceMode, MaintenanceType,
>       PROXMOX_SAFE_ID_FORMAT, PROXMOX_SAFE_ID_REGEX_STR, PRUNE_SCHEDULE_SCHEMA, SHA256_HEX_REGEX,
> -    SINGLE_LINE_COMMENT_SCHEMA, SNAPSHOT_PATH_REGEX_STR, UPID, Userid,
> +    SINGLE_LINE_COMMENT_SCHEMA, SNAPSHOT_ATTRIBUTE_RE, SNAPSHOT_PATH_REGEX_STR, UPID, Userid,
>       VERIFY_JOB_READ_THREADS_SCHEMA, VERIFY_JOB_VERIFY_THREADS_SCHEMA,
>   };
>   
> @@ -52,6 +53,8 @@ const_regex! {
>       pub GROUP_OR_SNAPSHOT_PATH_REGEX = concatcp!(r"^", GROUP_OR_SNAPSHOT_PATH_REGEX_STR, r"$");
>   
>       pub DATASTORE_MAP_REGEX = concatcp!(r"^(?:", PROXMOX_SAFE_ID_REGEX_STR, r"=)?", PROXMOX_SAFE_ID_REGEX_STR, r"$");
> +
> +    pub SNAPSHOT_ATTRIBUTE_REGEX = concatcp!(r"^", SNAPSHOT_ATTRIBUTE_RE, r"$");

nit: SNAPSHOT_ATTRIBUTE_RE is not used anywhere else AFAICS, so would be 
best in-lined directly. On the other hand, I think it would be 
preferable to have separate attribute key and attribute value types, so 
it would make sense to concatenate them from regex definitions for each 
of these.

>   }
>   
>   pub const CHUNK_DIGEST_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&SHA256_HEX_REGEX);
> @@ -90,6 +93,23 @@ pub const BACKUP_GROUP_SCHEMA: Schema = StringSchema::new("Backup Group")
>       .format(&BACKUP_GROUP_FORMAT)
>       .schema();
>   
> +pub const SNAPSHOT_ATTRIBUTE_FORMAT: ApiStringFormat =
> +    ApiStringFormat::Pattern(&SNAPSHOT_ATTRIBUTE_REGEX);
> +
> +pub const SNAPSHOT_ATTRIBUTE_SCHEMA: Schema = StringSchema::new(
> +    "Snapshot attribute, a key and one of its values. A key with several values is given once \
> +    per value.",
> +)
> +.format(&SNAPSHOT_ATTRIBUTE_FORMAT)
> +.type_text("KEY=VALUE")
> +.schema();
> +
> +pub const SNAPSHOT_ATTRIBUTE_LIST_SCHEMA: Schema =
> +    ArraySchema::new("List of snapshot attributes.", &SNAPSHOT_ATTRIBUTE_SCHEMA).schema();
> +
> +/// The attributes of a snapshot, each key has a set of values.
> +pub type SnapshotAttributes = BTreeMap<String, BTreeSet<String>>;

nit: Why was the BTreeMap and BTreeSet choosen over plain Vec<String, 
Vec<String>> here?

Not sure if the number of expected attributes would out-weight the 
additional memory footprint...

Further, instead of plain `String`s I would prefer dedicated types for 
key and value of attributes, to avoid possible misuse of this type by 
constructing it from unverified strings. See also comment on next patch...

> +
>   /// The maximal, inclusive depth for namespaces from the root ns downwards
>   ///
>   /// The datastore root name space is at depth zero (0), so we have in total eight (8) levels
> diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs
> index 21ef733d..cb1c231c 100644
> --- a/pbs-api-types/src/lib.rs
> +++ b/pbs-api-types/src/lib.rs
> @@ -94,6 +94,9 @@ pub const GROUP_OR_SNAPSHOT_PATH_REGEX_STR: &str =
>           r"(", BACKUP_TYPE_RE, ")/(", BACKUP_ID_RE, ")(?:/(", BACKUP_TIME_RE, r"))?",
>       );
>   
> +#[rustfmt::skip]
> +pub const SNAPSHOT_ATTRIBUTE_RE: &str = r"[a-z][a-z0-9\-]{0,31}=[A-Za-z0-9._+/\-]{1,128}";
> +
>   mod acl;
>   pub use acl::*;
>   
> 
> base-commit: 9bf4383b6ad4225367c7824023ad74769388de8f





  reply	other threads:[~2026-11-16 14:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  8:56 [RFC PATCH many 00/12] snapshot attributes for tags and pools of PVE guests, tape job filter Jakob-Tobias Winter
2026-11-13  8:56 ` [RFC PATCH proxmox 01/12] pbs-api-types: add types and schemas for snapshot attributes Jakob-Tobias Winter
2026-11-16 14:57   ` Christian Ebner [this message]
2026-11-18 12:54   ` Samuel Rufinatscha
2026-11-13  8:56 ` [RFC PATCH proxmox 02/12] pbs-api-types: tape: add attribute filter to backup jobs Jakob-Tobias Winter
2026-11-16 14:57   ` Christian Ebner
2026-11-13  8:56 ` [RFC PATCH proxmox-backup 03/12] datastore: add attributes to backup snapshots Jakob-Tobias Winter
2026-11-16 14:57   ` Christian Ebner
2026-11-18 12:55   ` Samuel Rufinatscha
2026-11-13  8:56 ` [RFC PATCH proxmox-backup 04/12] fix #7452: api: datastore: add endpoints for snapshot attributes Jakob-Tobias Winter
2026-11-16 14:57   ` Christian Ebner
2026-11-13  8:56 ` [RFC PATCH proxmox-backup 05/12] tape: backup job: allow selecting groups by " Jakob-Tobias Winter
2026-11-18 13:06   ` Samuel Rufinatscha
2026-11-18 15:19     ` Christian Ebner
2026-11-13  8:56 ` [RFC PATCH proxmox-backup 06/12] ui: tape backup job: add attribute filter Jakob-Tobias Winter
2026-11-13  8:56 ` [RFC PATCH proxmox-backup 07/12] docs: describe snapshot attributes and the tape job " Jakob-Tobias Winter
2026-11-13  8:56 ` [RFC PATCH storage 08/12] pbs: add helper to set the attributes of a backup snapshot Jakob-Tobias Winter
2026-11-13  8:56 ` [RFC PATCH guest-common 09/12] vzdump: add pbs-snapshot-attributes option Jakob-Tobias Winter
2026-11-13  8:56 ` [RFC PATCH manager 10/12] vzdump: store guest tags and pool as snapshot attributes on PBS Jakob-Tobias Winter
2026-11-13  8:56 ` [RFC PATCH manager 11/12] ui: backup job: add selector for PBS snapshot attributes Jakob-Tobias Winter
2026-11-13  8:56 ` [RFC PATCH docs 12/12] vzdump: describe snapshot attributes on Proxmox Backup Server Jakob-Tobias Winter
2026-11-16 14:57 ` [RFC PATCH many 00/12] snapshot attributes for tags and pools of PVE guests, tape job filter Christian Ebner
2026-11-18 13:07   ` Samuel Rufinatscha
2026-11-18 14:22 ` Samuel Rufinatscha
2026-11-19 11:58   ` Jakob-Tobias Winter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15657713-99a5-4a09-8310-2f832fca5131@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=tobias@stuttgart.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal