* [pve-devel] [PATCH manager] ui: migrate: fix disabled migrate button glitch
@ 2023-06-22 12:15 Dominik Csapak
2023-06-22 12:53 ` [pve-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2023-06-22 12:15 UTC (permalink / raw)
To: pve-devel
under certain circumstances, the migrate button stays disabled, even
when a valid target node was selected:
* the first node that gets autoselected (most likely the second)
is not a valid migration target
* the user changes to a migration target that is a valid one
if that happens, the migration button would stay disabled.
switching once to a non valid target and would enable the button.
To fix it, we have to do two things here:
'checkQemuPreconditions' is actually an async function that awaits an
api call and uses the result to set the 'migration.allowedNodes'
property
'checkMigratePreconditions' calls 'checkQemuPreconditions' and uses the
'migration.allowedNodes' property afterwards.
but since 'checkMigratePreconditions' is not async, that happens before
the api call can return the valid data and thus leaves it empty, making
all nodes valid in the selector. (thus the initial selected node is
valid)
instead make 'checkMigratePreconditions' also async and await the result
of 'checkQemuPreconditions'
this unearthed another issue, namely we access an object that is
possibly undefined (worked out before due to race conditions) so
fallback to an empty object.
and lastly, since we want the 'disallowedNodes' set before actually
checking the qemu preconditions, we move the setting of that on
the node selector above the qemu preconditions check
(this is the only place where we set it anyway, and the source does not
change, we probably could move that out of that function altogether)
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
www/manager6/window/Migrate.js | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/www/manager6/window/Migrate.js b/www/manager6/window/Migrate.js
index c310342d..5473821b 100644
--- a/www/manager6/window/Migrate.js
+++ b/www/manager6/window/Migrate.js
@@ -155,7 +155,7 @@ Ext.define('PVE.window.Migrate', {
});
},
- checkMigratePreconditions: function(resetMigrationPossible) {
+ checkMigratePreconditions: async function(resetMigrationPossible) {
var me = this,
vm = me.getViewModel();
@@ -165,12 +165,13 @@ Ext.define('PVE.window.Migrate', {
vm.set('running', true);
}
+ me.lookup('pveNodeSelector').disallowedNodes = [vm.get('nodename')];
+
if (vm.get('vmtype') === 'qemu') {
- me.checkQemuPreconditions(resetMigrationPossible);
+ await me.checkQemuPreconditions(resetMigrationPossible);
} else {
me.checkLxcPreconditions(resetMigrationPossible);
}
- me.lookup('pveNodeSelector').disallowedNodes = [vm.get('nodename')];
// Only allow nodes where the local storage is available in case of offline migration
// where storage migration is not possible
@@ -218,7 +219,7 @@ Ext.define('PVE.window.Migrate', {
migration.allowedNodes = migrateStats.allowed_nodes;
let target = me.lookup('pveNodeSelector').value;
if (target.length && !migrateStats.allowed_nodes.includes(target)) {
- let disallowed = migrateStats.not_allowed_nodes[target];
+ let disallowed = migrateStats.not_allowed_nodes[target] ?? {};
if (disallowed.unavailable_storages !== undefined) {
let missingStorages = disallowed.unavailable_storages.join(', ');
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: [PATCH manager] ui: migrate: fix disabled migrate button glitch
2023-06-22 12:15 [pve-devel] [PATCH manager] ui: migrate: fix disabled migrate button glitch Dominik Csapak
@ 2023-06-22 12:53 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-06-22 12:53 UTC (permalink / raw)
To: Proxmox VE development discussion, Dominik Csapak
Am 22/06/2023 um 14:15 schrieb Dominik Csapak:
> under certain circumstances, the migrate button stays disabled, even
> when a valid target node was selected:
> * the first node that gets autoselected (most likely the second)
> is not a valid migration target
> * the user changes to a migration target that is a valid one
>
> if that happens, the migration button would stay disabled.
> switching once to a non valid target and would enable the button.
>
> To fix it, we have to do two things here:
>
> 'checkQemuPreconditions' is actually an async function that awaits an
> api call and uses the result to set the 'migration.allowedNodes'
> property
>
> 'checkMigratePreconditions' calls 'checkQemuPreconditions' and uses the
> 'migration.allowedNodes' property afterwards.
>
> but since 'checkMigratePreconditions' is not async, that happens before
> the api call can return the valid data and thus leaves it empty, making
> all nodes valid in the selector. (thus the initial selected node is
> valid)
>
> instead make 'checkMigratePreconditions' also async and await the result
> of 'checkQemuPreconditions'
>
> this unearthed another issue, namely we access an object that is
> possibly undefined (worked out before due to race conditions) so
> fallback to an empty object.
>
> and lastly, since we want the 'disallowedNodes' set before actually
> checking the qemu preconditions, we move the setting of that on
> the node selector above the qemu preconditions check
> (this is the only place where we set it anyway, and the source does not
> change, we probably could move that out of that function altogether)
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> www/manager6/window/Migrate.js | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-22 12:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-22 12:15 [pve-devel] [PATCH manager] ui: migrate: fix disabled migrate button glitch Dominik Csapak
2023-06-22 12:53 ` [pve-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox