public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network 1/1] ipam: remove fallback code for ipam.db and mac cache
Date: Fri,  1 Aug 2025 14:10:27 +0200	[thread overview]
Message-ID: <20250801121029.201766-4-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20250801121029.201766-1-s.hanreich@proxmox.com>

With the upgrade to PVE 9, those files should have been successfully
migrated on all nodes, so we do not need to fallback on the old files
anymore.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 src/PVE/Network/SDN/Ipams.pm           | 30 +-------------------------
 src/PVE/Network/SDN/Ipams/PVEPlugin.pm | 28 +-----------------------
 2 files changed, 2 insertions(+), 56 deletions(-)

diff --git a/src/PVE/Network/SDN/Ipams.pm b/src/PVE/Network/SDN/Ipams.pm
index 7ec0f06..00aa20c 100644
--- a/src/PVE/Network/SDN/Ipams.pm
+++ b/src/PVE/Network/SDN/Ipams.pm
@@ -21,35 +21,7 @@ PVE::Network::SDN::Ipams::PhpIpamPlugin->register();
 PVE::Network::SDN::Ipams::Plugin->init();
 
 my $macdb_filename = "sdn/mac-cache.json";
-my $macdb_filename_legacy = 'priv/macs.db';
-
-cfs_register_file(
-    $macdb_filename,
-    sub {
-        my ($filename, $data) = @_;
-        if (defined($data)) {
-            return json_reader($filename, $data);
-        } else {
-            # TODO: remove legacy cache file handling with PVE 9+ after ensuring all call sites got
-            # switched over.
-            return cfs_read_file($macdb_filename_legacy);
-        }
-    },
-    sub {
-        my ($filename, $data) = @_;
-        # TODO: remove below with PVE 9+, add a pve8to9 check to allow doing so.
-        if (-e $macdb_filename_legacy && -e $macdb_filename) {
-            # only clean-up if we succeeded to write the new path at least once
-            unlink $macdb_filename_legacy
-                or $!{ENOENT}
-                or warn "failed to unlink legacy MAC cache - $!\n";
-        }
-        return json_writer->($filename, $data);
-    },
-);
-
-# drop reading $macdb_filename_legacy with PVE 9+ - for now do not write it anymore.
-cfs_register_file($macdb_filename_legacy, \&json_reader, undef);
+cfs_register_file($macdb_filename, \&json_reader, \&json_writer);
 
 sub json_reader {
     my ($filename, $data) = @_;
diff --git a/src/PVE/Network/SDN/Ipams/PVEPlugin.pm b/src/PVE/Network/SDN/Ipams/PVEPlugin.pm
index 6764d79..d2aba1e 100644
--- a/src/PVE/Network/SDN/Ipams/PVEPlugin.pm
+++ b/src/PVE/Network/SDN/Ipams/PVEPlugin.pm
@@ -14,37 +14,11 @@ use Digest::SHA;
 use base('PVE::Network::SDN::Ipams::Plugin');
 
 my $ipamdb_file = "sdn/pve-ipam-state.json";
-my $ipamdb_file_legacy = "priv/ipam.db";
 
 PVE::Cluster::cfs_register_file(
     $ipamdb_file,
-    sub {
-        my ($filename, $data) = @_;
-        if (defined($data)) {
-            return PVE::Network::SDN::Ipams::PVEPlugin->parse_config($filename, $data);
-        } else {
-            # TODO: remove legacy state file handling with PVE 9+ after ensuring all call sites got
-            # switched over.
-            return cfs_read_file($ipamdb_file_legacy);
-        }
-    },
-    sub {
-        my ($filename, $data) = @_;
-        # TODO: remove below with PVE 9+, add a pve8to9 check to allow doing so.
-        if (-e $ipamdb_file_legacy && -e $ipamdb_file) {
-            # only clean-up if we succeeded to write the new path at least once
-            unlink $ipamdb_file_legacy
-                or $!{ENOENT}
-                or warn "failed to unlink legacy IPAM DB - $!\n";
-        }
-        return PVE::Network::SDN::Ipams::PVEPlugin->write_config($filename, $data);
-    },
-);
-
-PVE::Cluster::cfs_register_file(
-    $ipamdb_file_legacy,
     sub { PVE::Network::SDN::Ipams::PVEPlugin->parse_config(@_); },
-    undef, # no writer for legacy file, all must go to the new file.
+    sub { PVE::Network::SDN::Ipams::PVEPlugin->write_config(@_); },
 );
 
 sub type {
-- 
2.47.2


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-08-01 12:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-01 12:10 [pve-devel] [PATCH cluster/manager/network 0/3] remove legacy ipam and mac db from observed files Stefan Hanreich
2025-08-01 12:10 ` [pve-devel] [PATCH pve-cluster 1/1] pmxcfs: remove legacy ipam db and mac cache files Stefan Hanreich
2025-08-01 12:52   ` Thomas Lamprecht
2025-08-01 12:10 ` [pve-devel] [PATCH pve-manager 1/1] pve8to9: check for legacy ipam db or " Stefan Hanreich
2025-08-01 14:27   ` [pve-devel] applied: " Thomas Lamprecht
2025-08-01 12:10 ` Stefan Hanreich [this message]
2025-08-01 13:19   ` [pve-devel] [PATCH pve-network 1/1] ipam: remove fallback code for ipam.db and mac cache Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250801121029.201766-4-s.hanreich@proxmox.com \
    --to=s.hanreich@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal