[pve-devel] [PATCH V2 pve-network 4/7] catch errors on sdn config generation

Alexandre Derumier aderumier at odiso.com
Tue Jun 2 11:20:24 CEST 2020


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Network/SDN/Zones.pm            | 8 +++++++-
 PVE/Network/SDN/Zones/QinQPlugin.pm | 1 +
 PVE/Network/SDN/Zones/VlanPlugin.pm | 2 ++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/PVE/Network/SDN/Zones.pm b/PVE/Network/SDN/Zones.pm
index b8dc54c..552b334 100644
--- a/PVE/Network/SDN/Zones.pm
+++ b/PVE/Network/SDN/Zones.pm
@@ -109,7 +109,13 @@ sub generate_etc_network_config {
 	}
 
 	my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type});
-	$plugin->generate_sdn_config($plugin_config, $zone, $id, $vnet, $controller, $interfaces_config, $config);
+	eval {
+	    $plugin->generate_sdn_config($plugin_config, $zone, $id, $vnet, $controller, $interfaces_config, $config);
+	};
+	if($@) {
+	    warn "zone $zone : vnet $id : $@";
+	    next;
+	}
     }
 
     my $raw_network_config = "\#version:$version\n";
diff --git a/PVE/Network/SDN/Zones/QinQPlugin.pm b/PVE/Network/SDN/Zones/QinQPlugin.pm
index 20c0986..2ae2649 100644
--- a/PVE/Network/SDN/Zones/QinQPlugin.pm
+++ b/PVE/Network/SDN/Zones/QinQPlugin.pm
@@ -52,6 +52,7 @@ sub generate_sdn_config {
     my $vlanprotocol = $plugin_config->{'vlan-protocol'};
     my $ctag = $vnet->{tag};
     my $alias = $vnet->{alias};
+    die "can't find bridge $bridge" if !-d "/sys/class/net/$bridge";
 
     my $vlan_aware = PVE::Tools::file_read_firstline("/sys/class/net/$bridge/bridge/vlan_filtering");
     my $is_ovs = 1 if !-d "/sys/class/net/$bridge/brif";
diff --git a/PVE/Network/SDN/Zones/VlanPlugin.pm b/PVE/Network/SDN/Zones/VlanPlugin.pm
index aeff1a4..d3dc857 100644
--- a/PVE/Network/SDN/Zones/VlanPlugin.pm
+++ b/PVE/Network/SDN/Zones/VlanPlugin.pm
@@ -41,6 +41,8 @@ sub generate_sdn_config {
     my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $interfaces_config, $config) = @_;
 
     my $bridge = $plugin_config->{bridge};
+    die "can't find bridge $bridge" if !-d "/sys/class/net/$bridge";
+
     my $vlan_aware = PVE::Tools::file_read_firstline("/sys/class/net/$bridge/bridge/vlan_filtering");
     my $is_ovs = 1 if !-d "/sys/class/net/$bridge/brif";
 
-- 
2.20.1




More information about the pve-devel mailing list