From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 4DFB91FF13E for ; Fri, 06 Mar 2026 18:13:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 76D23DB7; Fri, 6 Mar 2026 18:14:21 +0100 (CET) Message-ID: Date: Fri, 6 Mar 2026 18:13:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH pve-network v4 9/9] api: add dry-run endpoint for sdn apply to preview changes To: Gabriel Goller , pve-devel@lists.proxmox.com References: <20260306125315.190298-1-g.goller@proxmox.com> <20260306125315.190298-19-g.goller@proxmox.com> Content-Language: en-US From: Hannes Laimer In-Reply-To: <20260306125315.190298-19-g.goller@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1772817192437 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.000 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.617 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.892 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.622 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: J2AO5VJH72XGK4IJZUADXDNCNRL6I3RU X-Message-ID-Hash: J2AO5VJH72XGK4IJZUADXDNCNRL6I3RU X-MailFrom: h.laimer@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: nit inline On 2026-03-06 13:54, Gabriel Goller wrote: > Allows users to see the diff of frr and interfaces configuration files > before applying SDN changes. Previously this was not possible and the > user had to apply and then see what changed. For the ifupdown2 dry-run > to work, pull out the running_config generation to the parent functions. > > Also add an option to the compile_running_cfg function so that we can > skip the /etc/network/interfaces.d/sdn file version bump. This means > when nothing has been changed and dry-run is pressed, nothing will be > shown. > > Rename a few constants so that they don't clash with local variables. > > Signed-off-by: Gabriel Goller > --- > src/PVE/API2/Network/SDN.pm | 88 ++++++++++++++++++++++++++++++++ > src/PVE/Network/SDN.pm | 36 ++++++++----- > src/PVE/Network/SDN/Fabrics.pm | 10 +++- > src/PVE/Network/SDN/Zones.pm | 3 +- > src/test/debug/generateconfig.pl | 3 +- > src/test/run_test_zones.pl | 2 +- > 6 files changed, 124 insertions(+), 18 deletions(-) > > diff --git a/src/PVE/API2/Network/SDN.pm b/src/PVE/API2/Network/SDN.pm > index b35a588d391d..b98bc9146004 100644 > --- a/src/PVE/API2/Network/SDN.pm > +++ b/src/PVE/API2/Network/SDN.pm > @@ -3,6 +3,9 @@ package PVE::API2::Network::SDN; > use strict; > use warnings; > [..] > + > +__PACKAGE__->register_method({ > + name => 'dry-run', > + path => 'dry-run', > + method => 'GET', > + permissions => { > + check => ['perm', '/nodes/{node}', ['Sys.Modify']], very much a nit, and doesn't warrant a v5, but Sys.Audit is probably more fitting > + }, > + description => > + "Dry-run the SDN apply action and return the difference between the current configuration and the pending configuration", > + protected => 1, > + proxyto => 'node', > + parameters => { > + additionalProperties => 0, > + properties => { > + node => get_standard_option('pve-node'), > + }, > + }, > + > + returns => { > + type => 'object', > + properties => { > + "frr-diff" => { > + type => 'string', > + description => > + 'The difference between the current and pending FRR configuration.', > + }, > + "interfaces-diff" => { > + type => 'string', > + description => > + 'The difference between the current and pending /etc/network/interfaces.d/sdn configuration.', > + }, > + }, > + }, [..] > > PVE::Network::SDN::Zones::write_etc_network_config($network_config); > print "/etc/network/interfaces.d/sdn\n"; > diff --git a/src/test/run_test_zones.pl b/src/test/run_test_zones.pl > index 806225735e6b..8986c5c52c9f 100755 > --- a/src/test/run_test_zones.pl > +++ b/src/test/run_test_zones.pl > @@ -145,7 +145,7 @@ foreach my $test (@tests) { > my $name = $test; > my $expected = read_file("./$test/expected_sdn_interfaces"); > > - my $result = eval { PVE::Network::SDN::generate_raw_etc_network_config() }; > + my $result = eval { PVE::Network::SDN::generate_raw_etc_network_config($sdn_config) }; > > if (my $err = $@) { > diag("got unexpected error - $err");