public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	 Gabriel Goller <g.goller@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup 2/2] status: use Option on avail/used datastore attrs
Date: Thu, 7 Dec 2023 18:33:31 +0100 (CET)	[thread overview]
Message-ID: <851906853.3039.1701970411636@webmail.proxmox.com> (raw)
In-Reply-To: <20231207143527.282373-3-g.goller@proxmox.com>

But why is it still i64? I would expect u64.


> On 7.12.2023 15:35 CET Gabriel Goller <g.goller@proxmox.com> wrote:
> 
>  
> Instead of returning -1 if we can't get the attributes, we use an
> Option which will not be serialized on `None`.
> 
> Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
> ---
>  pbs-api-types/src/datastore.rs | 19 +++++++++++--------
>  src/api2/status.rs             |  6 +++---
>  2 files changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
> index d4ead1d1..c361dc30 100644
> --- a/pbs-api-types/src/datastore.rs
> +++ b/pbs-api-types/src/datastore.rs
> @@ -1302,12 +1302,15 @@ pub struct DataStoreStatus {
>  /// Status of a Datastore
>  pub struct DataStoreStatusListItem {
>      pub store: String,
> -    /// 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 Size of the underlying storage in bytes.
> +    #[serde(skip_serializing_if = "Option::is_none")]
> +    pub total: Option<i64>,
> +    /// The used bytes of the underlying storage.
> +    #[serde(skip_serializing_if = "Option::is_none")]
> +    pub used: Option<i64>,
>      /// The available bytes of the underlying storage. (-1 on error)
> -    pub avail: i64,
> +    #[serde(skip_serializing_if = "Option::is_none")]
> +    pub avail: Option<i64>,
>      /// A list of usages of the past (last Month).
>      #[serde(skip_serializing_if = "Option::is_none")]
>      pub history: Option<Vec<Option<f64>>>,
> @@ -1335,9 +1338,9 @@ impl DataStoreStatusListItem {
>      pub fn empty(store: &str, err: Option<String>) -> Self {
>          DataStoreStatusListItem {
>              store: store.to_owned(),
> -            total: -1,
> -            used: -1,
> -            avail: -1,
> +            total: None,
> +            used: None,
> +            avail: None,
>              history: None,
>              history_start: None,
>              history_delta: None,
> diff --git a/src/api2/status.rs b/src/api2/status.rs
> index ff7d4cbd..6e758187 100644
> --- a/src/api2/status.rs
> +++ b/src/api2/status.rs
> @@ -68,9 +68,9 @@ pub async fn datastore_status(
>  
>          let mut entry = DataStoreStatusListItem {
>              store: store.clone(),
> -            total: status.total as i64,
> -            used: status.used as i64,
> -            avail: status.available as i64,
> +            total: Some(status.total as i64),
> +            used: Some(status.used as i64),
> +            avail: Some(status.available as i64),
>              history: None,
>              history_start: None,
>              history_delta: None,
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




  parent reply	other threads:[~2023-12-07 17:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 14:35 [pbs-devel] [PATCH proxmox-backup 0/2] Fix DatastoreListSummary on limited permissions Gabriel Goller
2023-12-07 14:35 ` [pbs-devel] [PATCH proxmox-backup 1/2] ui: datastore summary handle non-existent values Gabriel Goller
2023-12-07 14:35 ` [pbs-devel] [PATCH proxmox-backup 2/2] status: use Option on avail/used datastore attrs Gabriel Goller
2023-12-07 17:07   ` Dietmar Maurer
2023-12-07 17:10     ` Dietmar Maurer
2023-12-07 17:33   ` Dietmar Maurer [this message]
2023-12-11  8:46     ` Gabriel Goller

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=851906853.3039.1701970411636@webmail.proxmox.com \
    --to=dietmar@proxmox.com \
    --cc=g.goller@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