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 30F721FF136 for ; Mon, 09 Mar 2026 16:48:38 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2AB6124F7; Mon, 9 Mar 2026 16:48:30 +0100 (CET) Date: Mon, 9 Mar 2026 16:48:26 +0100 From: Gabriel Goller To: pve-devel@lists.proxmox.com Subject: Re: [PATCH pve-network v4 9/9] api: add dry-run endpoint for sdn apply to preview changes Message-ID: Mail-Followup-To: pve-devel@lists.proxmox.com References: <20260306125315.190298-1-g.goller@proxmox.com> <20260306125315.190298-19-g.goller@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20260306125315.190298-19-g.goller@proxmox.com> User-Agent: NeoMutt/20241002-35-39f9a6 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1773071274605 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.015 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 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: UGKQTJ3ZDM3IQB7UMI2O2VUIVXZ5UTYY X-Message-ID-Hash: UGKQTJ3ZDM3IQB7UMI2O2VUIVXZ5UTYY X-MailFrom: g.goller@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: > +__PACKAGE__->register_method({ > + name => 'dry-run', > + path => 'dry-run', > + method => 'GET', > + permissions => { > + check => ['perm', '/nodes/{node}', ['Sys.Modify']], > + }, > + 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.', > + }, > + }, > + }, > + code => sub { > + my ($param) = @_; > + > + my $cfg = PVE::Network::SDN::compile_running_cfg(); > + > + my $fabric_cfg = PVE::Network::SDN::Fabrics::config(0); > + my $frr_cfg = PVE::Network::SDN::generate_frr_raw_config($cfg, $fabric_cfg); > + my $new_cfg_frr = PVE::Network::SDN::Frr::raw_config_to_string($frr_cfg); > + > + # compile running config and skip version bump > + my $running_cfg = PVE::Network::SDN::compile_running_cfg(1); Ah, a small oopsie happened here :( The $running_cfg declaration should be at the top instead of the $cfg declaration. This way we don't skip the version bump when having a fabrics-only sdn config. > + > + my $new_interfaces_cfg = > + PVE::Network::SDN::generate_raw_etc_network_config($running_cfg); > + > + my ($frr_tmp_filename, $frr_tmp_fh) = PVE::File::tempfile_contents($new_cfg_frr, 700); > + > + my ($interfaces_tmp_filename, $interfaces_tmp_fh) = > + PVE::File::tempfile_contents($new_interfaces_cfg, 700); > + > + my $return_value = {}; > + $return_value->{"frr-diff"} = get_diff('/etc/frr/frr.conf', $frr_tmp_filename); > + $return_value->{"interfaces-diff"} = > + get_diff('/etc/network/interfaces.d/sdn', $interfaces_tmp_filename); > + > + close($frr_tmp_fh); > + close($interfaces_tmp_fh); > + return $return_value; > + }, > +}); > + > 1; > [snip] Gabriel