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 F20E79562 for ; Tue, 26 Apr 2022 12:14:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EF7C719EA2 for ; Tue, 26 Apr 2022 12:14:05 +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 A782619E7A for ; Tue, 26 Apr 2022 12:14:03 +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 7A9EA42B83 for ; Tue, 26 Apr 2022 12:14:03 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 26 Apr 2022 12:14:01 +0200 Message-Id: <20220426101401.3216096-9-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220426101401.3216096-1-d.csapak@proxmox.com> References: <20220426101401.3216096-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.127 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH widget-toolkit v2 1/1] window/FileBrowser: try reload again when getting a 503 error X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2022 10:14:06 -0000 for the file restore, we return a 503 error when we were not finished mounting a disk in the restore vm, so ignore that error and try again (up to 10 times) so a file listing now has a "real" timeout of up to 300 seconds (30s pveproxy timeout * 10) instead of only 30, which should be enough for most situations. we also increase the proxy timeout to 60 seconds, since if one has many disks, all of them will try to load at the same time, but the browser has a maximum request limit and will stall+queue the remaining ones. so those will not run into the extjs timeout when we increase it here. for older backends without the new 503 returning feature, the calls will still run into a pveproxy timeout anyway. we also have to reimplement the 'monStoreErrors' functionality to get a slightly different behaviour: we disable the default extj loadMask of the treepanel and set it ourselves. then on 503 we leave it up, and only remove it on success or error (for non initial loads) Signed-off-by: Dominik Csapak --- src/window/FileBrowser.js | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/window/FileBrowser.js b/src/window/FileBrowser.js index 2efa988..f4a22b6 100644 --- a/src/window/FileBrowser.js +++ b/src/window/FileBrowser.js @@ -146,6 +146,9 @@ Ext.define("Proxmox.window.FileBrowser", { errorHandler: function(error, msg) { let me = this; + if (error?.status === 503) { + return false; + } me.lookup('downloadBtn').setDisabled(true); me.lookup('downloadTar').setDisabled(true); if (me.initialLoadDone) { @@ -167,9 +170,37 @@ Ext.define("Proxmox.window.FileBrowser", { let proxy = store.getProxy(); let errorCallback = (error, msg) => me.errorHandler(error, msg); - Proxmox.Utils.monStoreErrors(tree, store, true, errorCallback); proxy.setUrl(view.listURL); + proxy.setTimeout(60*1000); proxy.setExtraParams(view.extraParams); + + tree.mon(store, 'beforeload', () => { + Proxmox.Utils.setErrorMask(tree, true); + }); + tree.mon(store, 'load', (treestore, rec, success, operation, node) => { + if (success) { + Proxmox.Utils.setErrorMask(tree, false); + return; + } + if (!node.loadCount) { + node.loadCount = 0; // ensure its numeric + } + // trigger a reload if we got a 503 answer from the proxy + if (operation?.error?.status === 503 && node.loadCount < 10) { + node.collapse(); + node.expand(); + node.loadCount++; + return; + } + + let error = operation.getError(); + let msg = Proxmox.Utils.getResponseErrorMessage(error); + if (!errorCallback(error, msg)) { + Proxmox.Utils.setErrorMask(tree, msg); + } else { + Proxmox.Utils.setErrorMask(tree, false); + } + }); store.load((rec, op, success) => { let root = store.getRoot(); root.expand(); // always expand invisible root node @@ -217,6 +248,10 @@ Ext.define("Proxmox.window.FileBrowser", { }, }, + viewConfig: { + loadMask: false, + }, + columns: [ { text: gettext('Name'), -- 2.30.2