Check for any changes between the running config and the currently applied config and guard against executing pve-sdn-commit if the configuration is unchanged.
Signed-off-by: Stefan Hanreich <s.hanre...@proxmox.com> Link: https://lore.proxmox.com/20250718123313.208460-4-s.hanre...@proxmox.com --- bin/pve-sdn-commit | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/bin/pve-sdn-commit b/bin/pve-sdn-commit index b174f46d9..cf3fd7480 100644 --- a/bin/pve-sdn-commit +++ b/bin/pve-sdn-commit @@ -7,6 +7,11 @@ use Time::HiRes qw(usleep); use PVE::Cluster; use PVE::Network::SDN; +use PVE::Network::SDN::Zones; +use PVE::Network::SDN::Vnets; +use PVE::Network::SDN::Subnets; +use PVE::Network::SDN::Controllers; +use PVE::Tools; for (my $i = 0; !PVE::Cluster::check_cfs_quorum(1); $i++) { print "waiting for pmxcfs mount to appear and get quorate...\n" @@ -15,6 +20,44 @@ for (my $i = 0; !PVE::Cluster::check_cfs_quorum(1); $i++) { usleep(100 * 1000); } +sub has_pending_changes { + my ($pending_config) = @_; + + for my $entity (values $pending_config->{ids}->%*) { + return 1 if $entity->{state}; + } + + return 0; +} + +sub sdn_changed { + my $running_config = PVE::Network::SDN::running_config(); + + my $configs = { + zones => PVE::Network::SDN::Zones::config(), + vnets => PVE::Network::SDN::Vnets::config(), + subnets => PVE::Network::SDN::Subnets::config(), + controllers => PVE::Network::SDN::Controllers::config(), + }; + + for my $type (keys $configs->%*) { + my $pending_config = PVE::Network::SDN::pending_config( + $running_config, + $configs->{$type}, + $type, + ); + + return 1 if has_pending_changes($pending_config); + } + + return 0; +} + +if (!sdn_changed()) { + print "No changes to SDN configuration detected, skipping reload\n"; + exit 0; +} + PVE::Network::SDN::commit_config(); PVE::Network::SDN::generate_zone_config(); -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel