public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] api: datastore_status: restore api/gui compatibiltity
Date: Tue, 22 Mar 2022 09:14:57 +0100	[thread overview]
Message-ID: <20220322081457.514284-1-d.csapak@proxmox.com> (raw)

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 <d.csapak@proxmox.com>
---
 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<Vec<Option<f64>>>,
     /// History start time (epoch)
+    #[serde(skip_serializing_if="Option::is_none")]
     pub history_start: Option<u64>,
     /// History resolution (seconds)
+    #[serde(skip_serializing_if="Option::is_none")]
     pub history_delta: Option<u64>,
     /// 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<i64>,
     /// An error description, for example, when the datastore could not be looked up
+    #[serde(skip_serializing_if="Option::is_none")]
     pub error: Option<String>,
 }
 
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





             reply	other threads:[~2022-03-22  8:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22  8:14 Dominik Csapak [this message]
2022-03-22  8:18 ` Dominik Csapak

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=20220322081457.514284-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-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