From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 093201FF0B6 for ; Wed, 30 Sep 2026 17:22:21 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C9E9821644; Wed, 30 Sep 2026 17:22:20 +0200 (CEST) From: Jonas Theisen To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup 07/14] fix #7904: Implement "Enable" checkbox for GC jobs Date: Wed, 30 Sep 2026 17:18:05 +0200 Message-ID: <20260930152131.317493-8-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260930152131.317493-1-j.theisen@proxmox.com> References: <20260930152131.317493-1-j.theisen@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1790781736779 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.226 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: VI7AFOWQWJT2IHBIV6LSJHJ74KZ5D7VZ X-Message-ID-Hash: VI7AFOWQWJT2IHBIV6LSJHJ74KZ5D7VZ X-MailFrom: j.theisen@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 Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To allow users to disable a garbage-collection without having to remove the schedule this patch introduces an "Enable" checkbox. The value is inserted into the datastore config and honored by the scheduler by skipping GC if enabled is not set. If the value is not present it is assumed GC should run for backwards compatibility. If the checkbox is unchecked the schedule input box in the UI is also disabled and such is configured to not allow empty inputs anymore. Signed-off-by: Jonas Theisen --- src/api2/admin/datastore.rs | 1 + src/api2/admin/gc.rs | 16 +++++++++++++- src/api2/config/datastore.rs | 4 ++++ src/bin/proxmox-backup-proxy.rs | 8 +++++++ www/config/GCView.js | 2 ++ www/window/GCJobEdit.js | 39 ++++++++++++++++++++++++++++----- 6 files changed, 64 insertions(+), 6 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index bc2b2436e..641d4ee0e 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -1258,6 +1258,7 @@ pub fn garbage_collection_status( let mut info = GarbageCollectionJobStatus { store: store.clone(), schedule: store_config.gc_schedule, + enable: store_config.gc_enable, ..Default::default() }; diff --git a/src/api2/admin/gc.rs b/src/api2/admin/gc.rs index bca06897b..4bbce7255 100644 --- a/src/api2/admin/gc.rs +++ b/src/api2/admin/gc.rs @@ -45,7 +45,21 @@ pub fn list_all_gc_jobs( .collect::>(), }; - Ok(gc_info) + let mut list = Vec::new(); + + for mut job in gc_info { + let enabled = match job.enable { + Some(c) => c, + None => true, + }; + if !enabled { + job.next_run = Some(0); + } + + list.push(job); + } + + Ok(list) } const GC_ROUTER: Router = Router::new().get(&API_METHOD_LIST_ALL_GC_JOBS); diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs index e7028480c..3c372b7f6 100644 --- a/src/api2/config/datastore.rs +++ b/src/api2/config/datastore.rs @@ -571,6 +571,10 @@ pub fn update_datastore( data.gc_on_unmount = update.gc_on_unmount; } + if update.gc_enable.is_some() { + data.gc_enable = update.gc_enable; + } + macro_rules! prune_disabled { ($(($param:literal, $($member:tt)+)),+) => { $( diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index af3ebb7a7..c974da4bd 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -537,6 +537,14 @@ async fn schedule_datastore_garbage_collection() { } }; + let gc_enabled = match store_config.gc_enable { + Some(c) => c, + None => true, //if not defined assume enabled for backwards compatibility + }; + if !gc_enabled { + continue; + } + let event_str = match store_config.gc_schedule { Some(event_str) => event_str, None => continue, diff --git a/www/config/GCView.js b/www/config/GCView.js index 9fcc22344..5077f0566 100644 --- a/www/config/GCView.js +++ b/www/config/GCView.js @@ -5,6 +5,7 @@ Ext.define('pbs-gc-jobs-status', { 'upid', 'removed-bytes', 'pending-bytes', + 'enable', 'schedule', 'next-run', 'last-run-endtime', @@ -73,6 +74,7 @@ Ext.define('PBS.config.GCJobView', { datastore: data.store, id: data.store, schedule: data.schedule, + enable: data.enable, listeners: { destroy: () => this.reload(), }, diff --git a/www/window/GCJobEdit.js b/www/window/GCJobEdit.js index 6afcf7de1..e1a94754d 100644 --- a/www/window/GCJobEdit.js +++ b/www/window/GCJobEdit.js @@ -19,10 +19,39 @@ Ext.define('PBS.window.GCJobEdit', { return {}; }, - items: { - xtype: 'pbsCalendarEvent', - name: 'gc-schedule', - fieldLabel: gettext('GC Schedule'), - emptyText: gettext('none (disabled)'), + setValues: function (values) { + let me = this; + if (!values['gc-schedule'] || values['gc-schedule'] === '') { + values['gc-enable'] = false; + } + me.callParent([values]); }, + + items: [ + { + xtype: 'proxmoxcheckbox', + fieldLabel: gettext('Enable'), + name: 'gc-enable', + autoEl: { + tag: 'div', + 'data-qtip': gettext('Enable scheduled execution of this task.'), + }, + listeners: { + change: function (field, enabled) { + let me = this; + let view = me.up('pbsGCJobEdit'); + let schedule = view.down('field[name=gc-schedule]'); + schedule.setDisabled(!enabled); + }, + }, + uncheckedValue: false, + value: true, + }, + { + xtype: 'pbsCalendarEvent', + name: 'gc-schedule', + fieldLabel: gettext('GC Schedule'), + allowBlank: false, + }, + ], }); -- 2.47.3