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 E9C0D6FE05 for ; Wed, 1 Sep 2021 16:49:29 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 961799DD0 for ; Wed, 1 Sep 2021 16:48:59 +0200 (CEST) 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 CF8DC9D3C for ; Wed, 1 Sep 2021 16:48:54 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A6EBC444AB; Wed, 1 Sep 2021 16:48:54 +0200 (CEST) Message-ID: <843c0eb1-20ac-c47f-92c0-5ef89083ecfb@proxmox.com> Date: Wed, 1 Sep 2021 16:48:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:92.0) Gecko/20100101 Thunderbird/92.0 Content-Language: en-US To: Proxmox Backup Server development discussion , Hannes Laimer References: <20210830111505.38694-1-h.laimer@proxmox.com> <20210830111505.38694-6-h.laimer@proxmox.com> From: Dominik Csapak In-Reply-To: <20210830111505.38694-6-h.laimer@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.920 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 NICE_REPLY_A -0.932 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [mod.rs, datastore.rs, status.rs] Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup 05/15] api2: add 'is_available' to DataStoreConfig 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: Wed, 01 Sep 2021 14:49:30 -0000 comment inline: On 8/30/21 13:14, Hannes Laimer wrote: > --- > src/api2/admin/datastore.rs | 14 ++++++++++++++ > src/api2/status.rs | 19 ++++++++++++++++++- > src/api2/types/mod.rs | 2 ++ > 3 files changed, 34 insertions(+), 1 deletion(-) > > diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs > index f3c52413..16559678 100644 > --- a/src/api2/admin/datastore.rs > +++ b/src/api2/admin/datastore.rs > @@ -606,6 +606,19 @@ pub fn status( > _info: &ApiMethod, > rpcenv: &mut dyn RpcEnvironment, > ) -> Result { > + let (config, _digest) = datastore::config()?; > + let store_config = config.lookup("datastore", &store)?; > + if !check_if_available(&store_config).is_ok() { > + return Ok(DataStoreStatus { > + total: 0, > + used: 0, > + avail: 0, > + is_available: false, > + gc_status: None, > + counts: None, > + }); > + } > + > let datastore = DataStore::lookup_datastore(&store)?; > let storage = crate::tools::disks::disk_usage(&datastore.base_path())?; > let (counts, gc_status) = if verbose { > @@ -631,6 +644,7 @@ pub fn status( > total: storage.total, > used: storage.used, > avail: storage.avail, > + is_available: true, > gc_status, > counts, > }) > diff --git a/src/api2/status.rs b/src/api2/status.rs > index 3aff91e7..06990743 100644 > --- a/src/api2/status.rs > +++ b/src/api2/status.rs > @@ -21,7 +21,7 @@ use crate::api2::types::{ > Authid, > }; > > -use crate::backup::DataStore; > +use crate::backup::{check_if_available, DataStore}; > use crate::config::datastore; > use crate::tools::statistics::{linear_regression}; > use crate::config::cached_user_info::CachedUserInfo; > @@ -53,6 +53,10 @@ use crate::config::acl::{ > type: Integer, > description: "The available bytes of the underlying storage", > }, > + "is-available": { > + type: bool, > + description: "The datastore is available, relevent if it is removable", > + }, > history: { > type: Array, > optional: true, > @@ -103,6 +107,18 @@ pub fn datastore_status( > continue; > } > > + let store_config = config.lookup("datastore", &store)?; > + if !check_if_available(&store_config).is_ok() { > + list.push(json!({ > + "store": store, > + "total": -1, > + "used": -1, > + "avail": -1, > + "is-available": false, > + })); why -1 here, but 0 at the top? the api users should be able to see that its not available by the: 'is-available' flag anyway > + continue; > + } > + > let datastore = match DataStore::lookup_datastore(&store) { > Ok(datastore) => datastore, > Err(err) => { > @@ -123,6 +139,7 @@ pub fn datastore_status( > "total": status.total, > "used": status.used, > "avail": status.avail, > + "is-available": true, > "gc-status": datastore.last_gc_status(), > }); > > diff --git a/src/api2/types/mod.rs b/src/api2/types/mod.rs > index bd3c7ac5..4d9ed691 100644 > --- a/src/api2/types/mod.rs > +++ b/src/api2/types/mod.rs > @@ -371,6 +371,8 @@ pub struct DataStoreStatus { > pub used: u64, > /// Available space (bytes). > pub avail: u64, > + /// Datastore is available, relevant if it is removable > + pub is_available: bool, > /// Status of last GC > #[serde(skip_serializing_if="Option::is_none")] > pub gc_status: Option, >