From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 1DCD268D7E for ; Tue, 22 Mar 2022 09:15:31 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0CB9C1B123 for ; Tue, 22 Mar 2022 09:15:01 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 615191B119 for ; Tue, 22 Mar 2022 09:15:00 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2C45D4179B for ; Tue, 22 Mar 2022 09:15:00 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 22 Mar 2022 09:14:57 +0100 Message-Id: <20220322081457.514284-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.151 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [status.rs, datastore.rs, status.total] Subject: [pbs-devel] [PATCH proxmox-backup] api: datastore_status: restore api/gui compatibiltity X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Mar 2022 08:15:31 -0000 the latest changes to this api call changed/removed some things that were actually necessary for the gui. Readd those and document them this time. The change from u64 to i64 limits us to 8EiB of Datastore sizes (instead if 16EiB) but if we reach that, we must adapt most other parts to use 128bit sizes anyway Signed-off-by: Dominik Csapak --- pbs-api-types/src/datastore.rs | 19 ++++++++++++------- src/api2/status.rs | 13 +++++++------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 36d86c98..158ae140 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -653,25 +653,30 @@ pub struct DataStoreStatus { /// Status of a Datastore pub struct DataStoreStatusListItem { pub store: String, - /// The Size of the underlying storage in bytes. - pub total: u64, - /// The used bytes of the underlying storage. - pub used: u64, - /// The available bytes of the underlying storage. - pub avail: u64, + /// The Size of the underlying storage in bytes. (-1 on error) + pub total: i64, + /// The used bytes of the underlying storage. (-1 on error) + pub used: i64, + /// The available bytes of the underlying storage. (-1 on error) + pub avail: i64, /// A list of usages of the past (last Month). + #[serde(skip_serializing_if="Option::is_none")] pub history: Option>>, /// History start time (epoch) + #[serde(skip_serializing_if="Option::is_none")] pub history_start: Option, /// History resolution (seconds) + #[serde(skip_serializing_if="Option::is_none")] pub history_delta: Option, /// Estimation of the UNIX epoch when the storage will be full. /// This is calculated via a simple Linear Regression (Least /// Squares) of RRD data of the last Month. Missing if there are /// not enough data points yet. If the estimate lies in the past, - /// the usage is decreasing. + /// the usage is decreasing or not changing. + #[serde(skip_serializing_if="Option::is_none")] pub estimated_full_date: Option, /// An error description, for example, when the datastore could not be looked up + #[serde(skip_serializing_if="Option::is_none")] pub error: Option, } diff --git a/src/api2/status.rs b/src/api2/status.rs index 2da512e1..b422baba 100644 --- a/src/api2/status.rs +++ b/src/api2/status.rs @@ -62,9 +62,9 @@ pub fn datastore_status( Err(err) => { list.push(DataStoreStatusListItem { store: store.clone(), - total: 0, - used: 0, - avail: 0, + total: -1, + used: -1, + avail: -1, history: None, history_start: None, history_delta: None, @@ -78,9 +78,9 @@ pub fn datastore_status( let mut entry = DataStoreStatusListItem { store: store.clone(), - total: status.total, - used: status.used, - avail: status.avail, + total: status.total as i64, + used: status.used as i64, + avail: status.avail as i64, history: None, history_start: None, history_delta: None, @@ -133,6 +133,7 @@ pub fn datastore_status( if usage_list.len() >= 7 { entry.estimated_full_date = match linear_regression(&time_list, &usage_list) { Some((a, b)) if b != 0.0 => Some(((1.0 - a) / b).floor() as i64), + Some((_, b)) if b == 0.0 => Some(0), // infinite estimate, set to past for gui to detect _ => None, }; } -- 2.30.2