* [PATCH-SERIES network 0/2] assert vnet zone exists on create and update
@ 2026-07-03 10:47 Daniel Kral
2026-07-03 10:47 ` [PATCH network 1/2] prefix specific sdn resource type to existence assertion string Daniel Kral
2026-07-03 10:47 ` [PATCH network 2/2] api: vnets: assert vnet zone exists on create and update Daniel Kral
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Kral @ 2026-07-03 10:47 UTC (permalink / raw)
To: pve-devel
If a VNet is created or updated with an empty zone '' or a non-existing
zone identifier, the API handler will die with a slighly confusing error
message:
create sdn vnet object failed: cannot lookup undefined type! at
/usr/share/perl5/PVE/API2/Network/SDN/Vnets.pm line 326.
Therefore, use the helper sdn_zones_config(), which asserts whether the
zone identifier is non-empty and existing.
Daniel Kral (2):
prefix specific sdn resource type to existence assertion string
api: vnets: assert vnet zone exists on create and update
src/PVE/API2/Network/SDN/Vnets.pm | 8 ++++----
src/PVE/Network/SDN/Controllers.pm | 2 +-
src/PVE/Network/SDN/Dns.pm | 2 +-
src/PVE/Network/SDN/Ipams.pm | 2 +-
src/PVE/Network/SDN/Zones.pm | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH network 1/2] prefix specific sdn resource type to existence assertion string
2026-07-03 10:47 [PATCH-SERIES network 0/2] assert vnet zone exists on create and update Daniel Kral
@ 2026-07-03 10:47 ` Daniel Kral
2026-07-03 10:47 ` [PATCH network 2/2] api: vnets: assert vnet zone exists on create and update Daniel Kral
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Kral @ 2026-07-03 10:47 UTC (permalink / raw)
To: pve-devel
The non-empty assertion strings already prefixed each sdn resource type,
but the existence assertion did not.
This makes error messages more clearer if multiple sdn resources are
provided, e.g. as API parameters by users.
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
src/PVE/Network/SDN/Controllers.pm | 2 +-
src/PVE/Network/SDN/Dns.pm | 2 +-
src/PVE/Network/SDN/Ipams.pm | 2 +-
src/PVE/Network/SDN/Zones.pm | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/PVE/Network/SDN/Controllers.pm b/src/PVE/Network/SDN/Controllers.pm
index 4336b86..b2c2f9d 100644
--- a/src/PVE/Network/SDN/Controllers.pm
+++ b/src/PVE/Network/SDN/Controllers.pm
@@ -28,7 +28,7 @@ sub sdn_controllers_config {
die "no sdn controller ID specified\n" if !$id;
my $scfg = $cfg->{ids}->{$id};
- die "sdn '$id' does not exist\n" if (!$noerr && !$scfg);
+ die "sdn controller '$id' does not exist\n" if (!$noerr && !$scfg);
return $scfg;
}
diff --git a/src/PVE/Network/SDN/Dns.pm b/src/PVE/Network/SDN/Dns.pm
index 76833ea..db2f930 100644
--- a/src/PVE/Network/SDN/Dns.pm
+++ b/src/PVE/Network/SDN/Dns.pm
@@ -21,7 +21,7 @@ sub sdn_dns_config {
die "no sdn dns ID specified\n" if !$id;
my $scfg = $cfg->{ids}->{$id};
- die "sdn '$id' does not exist\n" if (!$noerr && !$scfg);
+ die "sdn dns '$id' does not exist\n" if (!$noerr && !$scfg);
return $scfg;
}
diff --git a/src/PVE/Network/SDN/Ipams.pm b/src/PVE/Network/SDN/Ipams.pm
index 00aa20c..179bdf7 100644
--- a/src/PVE/Network/SDN/Ipams.pm
+++ b/src/PVE/Network/SDN/Ipams.pm
@@ -93,7 +93,7 @@ sub sdn_ipams_config {
die "no sdn ipam ID specified\n" if !$id;
my $scfg = $cfg->{ids}->{$id};
- die "sdn '$id' does not exist\n" if (!$noerr && !$scfg);
+ die "sdn ipam '$id' does not exist\n" if (!$noerr && !$scfg);
return $scfg;
}
diff --git a/src/PVE/Network/SDN/Zones.pm b/src/PVE/Network/SDN/Zones.pm
index 4c1468c..f668303 100644
--- a/src/PVE/Network/SDN/Zones.pm
+++ b/src/PVE/Network/SDN/Zones.pm
@@ -35,7 +35,7 @@ sub sdn_zones_config {
die "no sdn zone ID specified\n" if !$id;
my $scfg = $cfg->{ids}->{$id};
- die "sdn '$id' does not exist\n" if (!$noerr && !$scfg);
+ die "sdn zone '$id' does not exist\n" if (!$noerr && !$scfg);
return $scfg;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH network 2/2] api: vnets: assert vnet zone exists on create and update
2026-07-03 10:47 [PATCH-SERIES network 0/2] assert vnet zone exists on create and update Daniel Kral
2026-07-03 10:47 ` [PATCH network 1/2] prefix specific sdn resource type to existence assertion string Daniel Kral
@ 2026-07-03 10:47 ` Daniel Kral
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Kral @ 2026-07-03 10:47 UTC (permalink / raw)
To: pve-devel
If a VNet is created or updated with an empty zone '' or a non-existing
zone identifier, the API handler will die with a slighly confusing error
message:
create sdn vnet object failed: cannot lookup undefined type! at
/usr/share/perl5/PVE/API2/Network/SDN/Vnets.pm line 326.
Therefore, use the helper sdn_zones_config(), which asserts whether the
zone identifier is non-empty and existing.
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
src/PVE/API2/Network/SDN/Vnets.pm | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/PVE/API2/Network/SDN/Vnets.pm b/src/PVE/API2/Network/SDN/Vnets.pm
index b8faeac..3f1cb1b 100644
--- a/src/PVE/API2/Network/SDN/Vnets.pm
+++ b/src/PVE/API2/Network/SDN/Vnets.pm
@@ -322,8 +322,8 @@ __PACKAGE__->register_method({
my $zone_cfg = PVE::Network::SDN::Zones::config();
my $zoneid = $cfg->{ids}->{$id}->{zone};
- my $plugin_config = $zone_cfg->{ids}->{$zoneid};
- my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type});
+ my $zone_scfg = PVE::Network::SDN::Zones::sdn_zones_config($zone_cfg, $zoneid);
+ my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($zone_scfg->{type});
$plugin->vnet_update_hook($cfg, $id, $zone_cfg);
PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg);
@@ -398,8 +398,8 @@ __PACKAGE__->register_method({
my $zone_cfg = PVE::Network::SDN::Zones::config();
my $zoneid = $cfg->{ids}->{$id}->{zone};
- my $plugin_config = $zone_cfg->{ids}->{$zoneid};
- my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type});
+ my $zone_scfg = PVE::Network::SDN::Zones::sdn_zones_config($zone_cfg, $zoneid);
+ my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($zone_scfg->{type});
$plugin->vnet_update_hook($cfg, $id, $zone_cfg);
PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg);
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-03 10:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03 10:47 [PATCH-SERIES network 0/2] assert vnet zone exists on create and update Daniel Kral
2026-07-03 10:47 ` [PATCH network 1/2] prefix specific sdn resource type to existence assertion string Daniel Kral
2026-07-03 10:47 ` [PATCH network 2/2] api: vnets: assert vnet zone exists on create and update Daniel Kral
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox