public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Elias Huhsovitz <e.huhsovitz@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Elias Huhsovitz <e.huhsovitz@proxmox.com>
Subject: [PATCH manager 1/2] fix #7860: api: pool: do not delete when used by backup job
Date: Wed, 30 Sep 2026 16:51:42 +0200	[thread overview]
Message-ID: <20260930145143.210066-2-e.huhsovitz@proxmox.com> (raw)
In-Reply-To: <20260930145143.210066-1-e.huhsovitz@proxmox.com>

Currently, deleting a pool that is used by a backup is allowed. This
results in a suboptimal configuration where calling the API endpoint
`/cluster/backup-info/not-backed-up` fails, because it tries to query
the VMs from the non-existent pool.

Mitigate this issue by not allowing pools used by backups to be deleted.

Signed-off-by: Elias Huhsovitz <e.huhsovitz@proxmox.com>
---
 PVE/API2/Pool.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/PVE/API2/Pool.pm b/PVE/API2/Pool.pm
index 63aff5bb..a0ff8a31 100644
--- a/PVE/API2/Pool.pm
+++ b/PVE/API2/Pool.pm
@@ -475,6 +475,19 @@ __PACKAGE__->register_method({
     },
 });
 
+my sub check_pool_used_in_backup_job {
+    my ($pool) = @_;
+
+    my $backup_jobs = cfs_read_file('jobs.cfg');
+
+    for my $job_id (keys $backup_jobs->{ids}->%*) {
+        my $referenced_pool = $backup_jobs->{ids}->{$job_id}->{pool};
+        next if !defined($referenced_pool);
+        next if $referenced_pool ne $pool;
+        die "pool '$pool' is used in backup job '$job_id'\n";
+    }
+}
+
 __PACKAGE__->register_method({
     name => 'delete_pool',
     protected => 1,
@@ -524,6 +537,8 @@ __PACKAGE__->register_method({
                     die "pool '$pool' is not empty (contains storage '$storeid')\n";
                 }
 
+                check_pool_used_in_backup_job($pool);
+
                 delete($usercfg->{pools}->{$pool});
                 PVE::AccessControl::delete_pool_acl($pool, $usercfg);
 
-- 
2.47.3





  reply	other threads:[~2026-09-30 14:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 14:51 [PATCH manager 0/2] fix #7860: api: pool: do not delete when used by backup job Elias Huhsovitz
2026-09-30 14:51 ` Elias Huhsovitz [this message]
2026-09-30 14:51 ` [PATCH manager 2/2] api: pool: update delete enpoint description to match behaviour Elias Huhsovitz

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=20260930145143.210066-2-e.huhsovitz@proxmox.com \
    --to=e.huhsovitz@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