public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH widget-toolkit 1/1] window/FileBrowser: try reload again when getting a 503 error
Date: Thu, 27 Jan 2022 11:56:01 +0100	[thread overview]
Message-ID: <20220127105601.2741602-9-d.csapak@proxmox.com> (raw)
In-Reply-To: <20220127105601.2741602-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
---
 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 99a7a85..2aab64d 100644
--- a/src/window/FileBrowser.js
+++ b/src/window/FileBrowser.js
@@ -125,6 +125,9 @@ Ext.define("Proxmox.window.FileBrowser", {
 
 	errorHandler: function(error, msg) {
 	    let me = this;
+	    if (error?.status === 503) {
+		return false;
+	    }
 	    me.lookup('downloadBtn').setDisabled(true);
 	    if (me.initialLoadDone) {
 		Ext.Msg.alert(gettext('Error'), msg);
@@ -145,9 +148,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
@@ -195,6 +226,10 @@ Ext.define("Proxmox.window.FileBrowser", {
 		},
 	    },
 
+	    viewConfig: {
+		loadMask: false,
+	    },
+
 	    columns: [
 		{
 		    text: gettext('Name'),
-- 
2.30.2





      parent reply	other threads:[~2022-01-27 10:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 10:55 [pve-devel] [PATCH proxmox-backup/common/storage/wt] improve file-restore timeout behaviour Dominik Csapak
2022-01-27 10:55 ` [pve-devel] [PATCH proxmox-backup 1/5] restore-daemon: start disk initialization in parallel to the api Dominik Csapak
2022-01-27 10:55 ` [pve-devel] [PATCH proxmox-backup 2/5] restore-daemon: put blocking code into 'block_in_place' Dominik Csapak
2022-01-27 10:55 ` [pve-devel] [PATCH proxmox-backup 3/5] restore-daemon: avoid auto-mounting zpools Dominik Csapak
2022-01-27 10:55 ` [pve-devel] [PATCH proxmox-backup 4/5] file-restore: factor out 'list_files' Dominik Csapak
2022-01-27 10:55 ` [pve-devel] [PATCH proxmox-backup 5/5] file-restore: add 'timeout' and 'json-error' parameter Dominik Csapak
2022-01-27 10:55 ` [pve-devel] [PATCH common 1/1] PBSClient: add option for extra parameter to file_restore_list Dominik Csapak
2022-02-09 17:35   ` Thomas Lamprecht
2022-02-10  8:30     ` Wolfgang Bumiller
2022-01-27 10:56 ` [pve-devel] [PATCH storage 1/1] api: FileRestore: use new timeout and json-error parameters for list Dominik Csapak
2022-01-27 10:56 ` Dominik Csapak [this message]

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=20220127105601.2741602-9-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-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