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 1FF4C69181 for ; Thu, 12 Nov 2020 11:31:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 16B0CD801 for ; Thu, 12 Nov 2020 11:30:46 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 88562D7F7 for ; Thu, 12 Nov 2020 11:30: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 53C3A42117 for ; Thu, 12 Nov 2020 11:30:45 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Thu, 12 Nov 2020 11:30:31 +0100 Message-Id: <20201112103034.159849-3-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201112103034.159849-1-f.gruenbichler@proxmox.com> References: <20201112103034.159849-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.023 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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, me.store, datastore.rs] Subject: [pbs-devel] [PATCH proxmox-backup 2/5] api: make expensive parts of datastore status opt-in 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, 12 Nov 2020 10:31:16 -0000 used in the PBS GUI, but also for PVE usage queries which don't need all the extra expensive information.. Signed-off-by: Fabian Grünbichler --- src/api2/admin/datastore.rs | 16 ++++++++++++++-- src/api2/types/mod.rs | 16 ++++++++++++---- www/datastore/Summary.js | 2 +- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index df666156..857fb903 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -525,7 +525,14 @@ fn get_snapshots_count(store: &DataStore) -> Result { store: { schema: DATASTORE_SCHEMA, }, + verbose: { + type: bool, + default: false, + optional: true, + description: "Include additional information like snapshot counts and GC status.", + }, }, + }, returns: { type: DataStoreStatus, @@ -537,13 +544,18 @@ fn get_snapshots_count(store: &DataStore) -> Result { /// Get datastore status. pub fn status( store: String, + verbose: bool, _info: &ApiMethod, _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let datastore = DataStore::lookup_datastore(&store)?; let storage = crate::tools::disks::disk_usage(&datastore.base_path())?; - let counts = get_snapshots_count(&datastore)?; - let gc_status = datastore.last_gc_status(); + let (counts, gc_status) = match verbose { + true => { + (Some(get_snapshots_count(&datastore)?), Some(datastore.last_gc_status())) + }, + false => (None, None), + }; Ok(DataStoreStatus { total: storage.total, diff --git a/src/api2/types/mod.rs b/src/api2/types/mod.rs index 59323327..44cfef94 100644 --- a/src/api2/types/mod.rs +++ b/src/api2/types/mod.rs @@ -707,8 +707,14 @@ pub struct Counts { #[api( properties: { - "gc-status": { type: GarbageCollectionStatus, }, - counts: { type: Counts, } + "gc-status": { + type: GarbageCollectionStatus, + optional: true, + }, + counts: { + type: Counts, + optional: true, + }, }, )] #[derive(Serialize, Deserialize)] @@ -722,9 +728,11 @@ pub struct DataStoreStatus { /// Available space (bytes). pub avail: u64, /// Status of last GC - pub gc_status: GarbageCollectionStatus, + #[serde(skip_serializing_if="Option::is_none")] + pub gc_status: Option, /// Group/Snapshot counts - pub counts: Counts, + #[serde(skip_serializing_if="Option::is_none")] + pub counts: Option, } #[api( diff --git a/www/datastore/Summary.js b/www/datastore/Summary.js index 41fd7c85..5e7cfede 100644 --- a/www/datastore/Summary.js +++ b/www/datastore/Summary.js @@ -78,7 +78,7 @@ Ext.define('PBS.DataStoreInfo', { let datastore = encodeURIComponent(view.datastore); me.store = Ext.create('Proxmox.data.ObjectStore', { interval: 5*1000, - url: `/api2/json/admin/datastore/${datastore}/status`, + url: `/api2/json/admin/datastore/${datastore}/status/?verbose=true`, }); me.store.on('load', me.onLoad, me); }, -- 2.20.1