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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id CAB2EB9180 for ; Thu, 7 Dec 2023 18:07:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A867114FD8 for ; Thu, 7 Dec 2023 18:07:46 +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 for ; Thu, 7 Dec 2023 18:07:45 +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 CE88F4349E for ; Thu, 7 Dec 2023 18:07:44 +0100 (CET) Date: Thu, 7 Dec 2023 18:07:43 +0100 (CET) From: Dietmar Maurer To: Proxmox Backup Server development discussion , Gabriel Goller Message-ID: <1543006921.3021.1701968863864@webmail.proxmox.com> In-Reply-To: <20231207143527.282373-3-g.goller@proxmox.com> References: <20231207143527.282373-1-g.goller@proxmox.com> <20231207143527.282373-3-g.goller@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.6-Rev55 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL 0.370 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 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, status.total, datastore.rs, proxmox.com] Subject: Re: [pbs-devel] [PATCH proxmox-backup 2/2] status: use Option on avail/used datastore attrs 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: Thu, 07 Dec 2023 17:07:46 -0000 But this is not backwards compatible. Deserialization fail now for -1 (when connecting to an old server which returns -1)? > On 7.12.2023 15:35 CET Gabriel Goller 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 > --- > 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, > + /// The used bytes of the underlying storage. > + #[serde(skip_serializing_if = "Option::is_none")] > + pub used: Option, > /// The available bytes of the underlying storage. (-1 on error) > - pub avail: i64, > + #[serde(skip_serializing_if = "Option::is_none")] > + pub avail: Option, > /// A list of usages of the past (last Month). > #[serde(skip_serializing_if = "Option::is_none")] > pub history: Option>>, > @@ -1335,9 +1338,9 @@ impl DataStoreStatusListItem { > pub fn empty(store: &str, err: Option) -> 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