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 CC12B1FF15E for ; Mon, 27 Oct 2025 15:25:39 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E9B517A95; Mon, 27 Oct 2025 15:26:07 +0100 (CET) From: Christian Ebner To: pdm-devel@lists.proxmox.com Date: Mon, 27 Oct 2025 15:25:51 +0100 Message-ID: <20251027142551.458160-6-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251027142551.458160-1-c.ebner@proxmox.com> References: <20251027142551.458160-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761575152911 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.046 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 Subject: [pdm-devel] [RFC datacenter-manager 5/5] pdm-api-types: calculate upwards trending datastore usage property X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" To allow filtering of PBS datastore resources with upwards trending storage usage. Calculate base on the current system time. Signed-off-by: Christian Ebner --- lib/pdm-api-types/src/resource.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/resource.rs index 10ea123..c7f24c2 100644 --- a/lib/pdm-api-types/src/resource.rs +++ b/lib/pdm-api-types/src/resource.rs @@ -1,4 +1,5 @@ use std::convert::Infallible; +use std::time::{SystemTime, UNIX_EPOCH}; use anyhow::{bail, Error}; use serde::{Deserialize, Serialize}; @@ -122,6 +123,17 @@ impl Resource { if r.usage > PBS_DATASTORE_CRITICAL_USAGE_THRESHOLD { properties.push("critical-usage".to_string()); } + if let Some(estimated_full) = r.estimated_full_date { + if let Ok(now) = SystemTime::now().duration_since(UNIX_EPOCH) { + let threshold = now.as_secs() + PBS_DATASTORE_FILLUP_THRESHOLD; + if estimated_full > 0 + && (estimated_full as u64) > now.as_secs() + && (estimated_full as u64) < threshold + { + properties.push("uptrendig-usage".to_string()); + } + } + } } properties.join(",") } -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel