public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH proxmox-ve-rs v4 18/22] common: sdn: fabrics: implement validation
Date: Fri, 11 Jul 2025 13:38:48 +0200	[thread overview]
Message-ID: <3rvfbqioyuce7qdw53ddi3qgeblvqh3fecygqrgtqenbjzrqna@bwxmlenrbxm2> (raw)
In-Reply-To: <nnzimwl5m7tkwspwwzcmgh6dgsq7zbqclis4taicuwe3nilct6@rizuyx2q6xrv>

On Fri, Jul 11, 2025 at 11:40:56AM +0200, Gabriel Goller wrote:
> > > [snip]
> > > diff --git a/proxmox-ve-config/src/sdn/fabric/mod.rs b/proxmox-ve-config/src/sdn/fabric/mod.rs
> > > index 3342a7053d3f..a2132e8aff3f 100644
> > > --- a/proxmox-ve-config/src/sdn/fabric/mod.rs
> > > +++ b/proxmox-ve-config/src/sdn/fabric/mod.rs
> > > @@ -1,11 +1,13 @@
> > >  pub mod section_config;
> > > 
> > > -use std::collections::BTreeMap;
> > > +use std::collections::{BTreeMap, HashSet};
> > >  use std::marker::PhantomData;
> > >  use std::ops::Deref;
> > > 
> > >  use serde::{Deserialize, Serialize};
> > > 
> > > +use crate::common::valid::Validatable;
> > > +
> > >  use crate::sdn::fabric::section_config::{
> > >      fabric::{
> > >          Fabric, FabricDeletableProperties, FabricId, FabricSection, FabricSectionUpdater,
> > > @@ -34,15 +36,38 @@ pub enum FabricConfigError {
> > >      FabricDoesNotExist(String),
> > >      #[error("node '{0}' does not exist in fabric '{1}'")]
> > >      NodeDoesNotExist(String, String),
> > > +    #[error("node IP {0} is outside the IP prefix {1} of the fabric")]
> > > +    NodeIpOutsideFabricRange(String, String),
> > >      #[error("node has a different protocol than the referenced fabric")]
> > >      ProtocolMismatch,
> > >      #[error("fabric '{0}' already exists in config")]
> > >      DuplicateFabric(String),
> > >      #[error("node '{0}' already exists in config for fabric {1}")]
> > >      DuplicateNode(String, String),
> > > +    #[error("fabric {0} contains nodes with duplicated IPs")]
> > > +    DuplicateNodeIp(String),
> > > +    #[error("fabric '{0}' does not have an IP prefix configured for the node IP {1}")]
> > > +    FabricNoIpPrefixForNode(String, String),
> > > +    #[error("node '{0}' does not have an IP configured for this fabric prefix {1}")]
> > > +    NodeNoIpForFabricPrefix(String, String),
> > > +    #[error("fabric '{0}' does not have an IP prefix configured")]
> > > +    FabricNoIpPrefix(String),
> > > +    #[error("node '{0}' does not have an IP configured")]
> > > +    NodeNoIp(String),
> > > +    #[error("interface is already in use by another fabric")]
> > > +    DuplicateInterface,
> > > +    #[error("IPv6 is currently not supported for protocol {0}")]
> > > +    NoIpv6(String),
> > 
> > ^ "NoIpv6" is a weird variant name for this. Maybe use Ipv6Unsupported.
> 
> Agree, changed it.
> 
> > I also wonder if we really need all those messages as separate variants.
> > As a followup to the previous thoughts on error types: Generally I think
> > only errors which are worth distinguishing need their own variants. We
> > definitely don't need one for every single message.
> 
> IMO what we could do is split it up in multiple enums and have a sort of
> tree structure at the end.
> 
> > The ones here could probably all just be a single `Invalid(String)`.
> > (Or if we don't want to expose `String` here,
> > `Validation(ValidationError)`, with the inner one being a newtype
> > wrapper around the `String`.
> 
> Hmm but then why create custom error types at all? This is the same as
> having strings where we can't distinguish between errors.

1) Hygiene.

You don't want to have multiple different generic error type helper
crates in your dependency tree just for "messages".

2) Having an overview of what can go wrong.

3) Error *handling*:

Most of the time it is enough to know "classes" of errors in the code.

- Error class: the user passed invalid data:
  In this case, certain validation functions could also be made
  available in a wasm crate, which the UI could use to display useful
  errors to the user in an input form.
  But the caller will almost never need to execute specific code based
  on which particular error happened, which means this can be a single
  variant with a message.
  (Unless you want to implement suggestions to the user on the UI
  side... but then such cases can still be specialized later. Eg. the
  error type can have an optional "source" error which could then be
  zero-zised "tag" types the UI could check via
  `.source().downcast()`...)

- The config is invalid:
  In addition to the invalid input from the user, someone may have
  manually modified the on-disk configuration files, so this case should
  be distinguishable somehow.
  Callers of the code could perhaps try an older backed-up version of
  the config.

- An internal error happened:
  Here callers usually cannot recover and that's the "catch-all" for
  pretty much everything beyond the caller's control...

- Bubbling up specific errors from deeper in the stack:
  For instance, code which uses the `proxmox-client` crate should be
  able to tell if the underlying HTTP connection responded with an
  *error* as opposed to there being problems with the *network* stack:
  Eg. in PDM we connect to a PVE cluster node to call an API method. If
  the API method returns an *error*, then we pass it on to the caller.
  But if a *network* error happens, eg. the `connect()` call fails, PDM
  will try another cluster node. The proxmox-client crate *itself*,
  however, only cares about dealing with a single target node.)

> 
> > Internally there can be a helper
> > `fn FabricConfigError::validation(impl Into<String>)`.
> > >      // should usually not occur, but we still check for it nonetheless
> > >      #[error("mismatched fabric_id")]
> > >      FabricIdMismatch,
> > > +    // this is technically possible, but we don't allow it
> > > +    #[error("duplicate OSPF area")]
> > > +    DuplicateOspfArea,
> > > +    #[error("IP prefix {0} in fabric '{1}' overlaps with IPv4 prefix {2} in fabric '{3}'")]
> > > +    OverlappingIp4Prefix(String, String, String, String),
> > > +    #[error("IPv6 prefix {0} in fabric '{1}' overlaps with IPv6 prefix {2} in fabric '{3}'")]
> > > +    OverlappingIp6Prefix(String, String, String, String),
> > >  }
> > > 
> > >  /// An entry in a [`FabricConfig`].
> > > @@ -367,6 +392,93 @@ impl From<Fabric> for FabricEntry {
> > >      }
> > >  }
> > > [snip]
> 
> Thanks!
> 


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2025-07-11 11:38 UTC|newest]

Thread overview: 129+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-02 14:49 [pve-devel] [PATCH access-control/cluster/docs/gui-tests/manager/network/proxmox{, -firewall, -ve-rs, -perl-rs, -widget-toolkit} v4 00/76] Add SDN Fabrics Gabriel Goller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox v4 1/5] network-types: initial commit Gabriel Goller
2025-07-03 13:11   ` Wolfgang Bumiller
2025-07-03 13:46     ` Stefan Hanreich
2025-07-03 13:48       ` Stefan Hanreich
2025-07-04  7:55         ` Wolfgang Bumiller
2025-07-04 12:19     ` Gabriel Goller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox v4 2/5] network-types: make cidr and mac-address types usable by the api Gabriel Goller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox v4 3/5] network-types: add api types for ipv4/6 Gabriel Goller
2025-07-03 13:18   ` Wolfgang Bumiller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox v4 4/5] network-types: add CIDR overlap detection for IPv4 and IPv6 Gabriel Goller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox v4 5/5] api-macro: add allof schema to enum Gabriel Goller
2025-07-04 13:48   ` [pve-devel] applied: " Wolfgang Bumiller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox-firewall v4 1/1] firewall: nftables: migrate to proxmox-network-types Gabriel Goller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox-ve-rs v4 01/22] config: use proxmox_serde perl helpers Gabriel Goller
2025-07-04 14:09   ` [pve-devel] applied: " Wolfgang Bumiller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox-ve-rs v4 02/22] ve-config: move types to proxmox-network-types Gabriel Goller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox-ve-rs v4 03/22] sdn-types: initial commit Gabriel Goller
2025-07-04 14:09   ` Wolfgang Bumiller
2025-07-04 14:40     ` Gabriel Goller
2025-07-07  7:53       ` Wolfgang Bumiller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox-ve-rs v4 04/22] frr: create proxmox-frr crate Gabriel Goller
2025-07-07 11:12   ` Wolfgang Bumiller
2025-07-07 12:52     ` Gabriel Goller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox-ve-rs v4 05/22] frr: add common frr types Gabriel Goller
2025-07-07 11:18   ` Wolfgang Bumiller
2025-07-07 14:43     ` Gabriel Goller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox-ve-rs v4 06/22] frr: add openfabric types Gabriel Goller
2025-07-07 11:25   ` Wolfgang Bumiller
2025-07-07 15:19     ` Gabriel Goller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox-ve-rs v4 07/22] frr: add ospf types Gabriel Goller
2025-07-07 11:28   ` Wolfgang Bumiller
2025-07-07 17:07     ` Gabriel Goller
2025-07-02 14:49 ` [pve-devel] [PATCH proxmox-ve-rs v4 08/22] frr: add route-map types Gabriel Goller
2025-07-07 11:52   ` Wolfgang Bumiller
2025-07-07 17:13     ` Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 09/22] frr: add generic types over openfabric and ospf Gabriel Goller
2025-07-07 11:58   ` Wolfgang Bumiller
2025-07-07 17:20     ` Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 10/22] config: sdn: fabrics: add section types Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 11/22] config: sdn: fabrics: add node " Gabriel Goller
2025-07-07 12:19   ` Wolfgang Bumiller
2025-07-07 17:22     ` Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 12/22] config: sdn: fabrics: add interface name struct Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 13/22] config: sdn: fabrics: add openfabric properties Gabriel Goller
2025-07-08  8:09   ` Wolfgang Bumiller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 14/22] config: sdn: fabrics: add ospf properties Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 15/22] config: sdn: fabrics: add api types Gabriel Goller
2025-07-08  8:15   ` Wolfgang Bumiller
2025-07-08  9:50     ` Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 16/22] config: sdn: fabrics: add section config Gabriel Goller
2025-07-08  8:18   ` Wolfgang Bumiller
2025-07-11  8:33     ` Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 17/22] config: sdn: fabrics: add fabric config Gabriel Goller
2025-07-08  8:46   ` Wolfgang Bumiller
2025-07-11  9:04     ` Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 18/22] common: sdn: fabrics: implement validation Gabriel Goller
2025-07-08 11:01   ` Wolfgang Bumiller
2025-07-11  9:40     ` Gabriel Goller
2025-07-11 11:38       ` Wolfgang Bumiller [this message]
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 19/22] sdn: fabrics: config: add conversion from / to section config Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 20/22] sdn: fabrics: implement FRR configuration generation Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 21/22] ve-config: add integrations tests Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-ve-rs v4 22/22] frr: add global ipv6 forwarding Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-perl-rs v4 1/5] pve-rs: Add PVE::RS::SDN::Fabrics module Gabriel Goller
2025-07-04 12:16   ` Wolfgang Bumiller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-perl-rs v4 2/5] pve-rs: sdn: fabrics: add api methods Gabriel Goller
2025-07-04 12:57   ` Wolfgang Bumiller
2025-07-04 15:56     ` Gabriel Goller
2025-07-07  7:48       ` Wolfgang Bumiller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-perl-rs v4 3/5] pve-rs: sdn: fabrics: add frr config generation Gabriel Goller
2025-07-04 13:14   ` Wolfgang Bumiller
2025-07-04 13:23     ` Stefan Hanreich
2025-07-04 13:31       ` Wolfgang Bumiller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-perl-rs v4 4/5] pve-rs: sdn: fabrics: add helper to generate ifupdown2 configuration Gabriel Goller
2025-07-04 13:29   ` Wolfgang Bumiller
2025-07-04 16:15     ` Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-perl-rs v4 5/5] pve-rs: sdn: fabrics: add helper for network API endpoint Gabriel Goller
2025-07-04 13:34   ` Wolfgang Bumiller
2025-07-04 16:31     ` Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-cluster v4 1/1] cfs: add fabrics.cfg to observed files Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-access-control v4 1/1] permissions: add ACL paths for SDN fabrics Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 01/21] sdn: fix value returned by pending_config Gabriel Goller
2025-07-04 14:29   ` Stefan Hanreich
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 02/21] debian: add dependency to proxmox-perl-rs Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 03/21] fabrics: add fabrics module Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 04/21] refactor: controller: move frr methods into helper Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 05/21] frr: add new helpers for reloading frr configuration Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 06/21] controllers: define new api for frr config generation Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 07/21] sdn: add frr config generation helpers Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 08/21] sdn: api: add check for rewriting frr configuration Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 09/21] test: isis: add test for standalone configuration Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 10/21] sdn: frr: add daemon status to frr helper Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 11/21] sdn: commit fabrics config to running configuration Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 12/21] fabrics: generate ifupdown configuration Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 13/21] fabrics: add jsonschema for fabrics and nodes Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 14/21] api: fabrics: add root-level module Gabriel Goller
2025-07-04 14:32   ` Stefan Hanreich
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 15/21] api: fabrics: add fabric submodule Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 16/21] api: fabrics: add node submodule Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 17/21] api: fabrics: add fabricnode submodule Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 18/21] controller: evpn: add fabrics integration Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 19/21] zone: vxlan: " Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 20/21] test: fabrics: add test cases for ospf and openfabric + evpn Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-network v4 21/21] frr: bump frr config version to 10.3.1 Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH proxmox-widget-toolkit v4 1/1] network selector: add type parameter Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 01/17] api: use new sdn config generation functions Gabriel Goller
2025-07-04 14:27   ` Stefan Hanreich
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 02/17] ui: fabrics: add model definitions for fabrics Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 03/17] fabric: add common interface panel Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 04/17] fabric: add OpenFabric interface properties Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 05/17] fabric: add OSPF " Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 06/17] fabric: add generic node edit panel Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 07/17] fabric: add OpenFabric node edit Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 08/17] fabric: add OSPF " Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 09/17] fabric: add generic fabric edit panel Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 10/17] fabric: add OpenFabric " Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 11/17] fabric: add OSPF " Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 12/17] fabrics: Add main FabricView Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 13/17] ui: permissions: add ACL path for fabrics Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 14/17] api: network: add include_sdn / fabric type Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 15/17] ui: add sdn networks to ceph / migration Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 16/17] ui: sdn: add evpn controller fabric integration Gabriel Goller
2025-07-02 14:50 ` [pve-devel] [PATCH pve-manager v4 17/17] ui: sdn: vxlan: add fabric property Gabriel Goller
2025-07-02 14:51 ` [pve-devel] [PATCH pve-gui-tests v4 1/1] pve: add sdn/fabrics screenshots Gabriel Goller
2025-07-02 14:51 ` [pve-devel] [PATCH pve-docs v4 1/1] fabrics: add initial documentation for sdn fabrics Gabriel Goller
2025-07-03  9:57 ` [pve-devel] [PATCH access-control/cluster/docs/gui-tests/manager/network/proxmox{, -firewall, -ve-rs, -perl-rs, -widget-toolkit} v4 00/76] Add SDN Fabrics Gabriel Goller
2025-07-09 11:27 ` Gabriel Goller
2025-07-16 13:09   ` Gabriel Goller

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=3rvfbqioyuce7qdw53ddi3qgeblvqh3fecygqrgtqenbjzrqna@bwxmlenrbxm2 \
    --to=w.bumiller@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal