[pve-devel] applied: [PATCH manager] ha: affinity rules: use single data store and mirror it to child grids

Thomas Lamprecht t.lamprecht at proxmox.com
Sat Aug 2 19:26:19 CEST 2025


This avoids loading the data twice, which is annoying especially on
high-latency links. Further, it ensures both views are always backed
by the exact same data, avoiding inconsistent state and thus e.g.
confusing warnings if something changed in the backend between on of
both loads.

To implement this add a new model that derives from the main one but
uses an in-memory proxy. Then move the "real" store out to the parent
component, where we need to manually initialise it as ExtJS panel are
more generic compared to grids–which always got a backing store.
Anyway, in the parent add a listener to copy any data to the in-memory
stores of the child grids for each affinity rule type. In the child
grid's relay any store load–e.g., after adding/changing/deleting a
rule–to the parent.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---


This is a replacement for:
https://lore.proxmox.com/pve-devel/20250801165845.97353-2-m.koeppl@proxmox.com/

I did a few other clean-ups and made the whole implementation a bit more
declarative, but most of it should not be really relevant w.r.t.
semantic changes, so posting only this one. Just check the git log for
the other changes if you're interested,


 www/manager6/ha/Rules.js | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/www/manager6/ha/Rules.js b/www/manager6/ha/Rules.js
index 775f2e0e7..35efdabec 100644
--- a/www/manager6/ha/Rules.js
+++ b/www/manager6/ha/Rules.js
@@ -21,14 +21,19 @@ Ext.define('pve-ha-rules', {
     },
     idProperty: 'rule',
 });
+Ext.define('pve-ha-rules-memory', {
+    extend: 'pve-ha-rules',
+    proxy: {
+        type: 'memory',
+    },
+});
 
 Ext.define('PVE.ha.RulesBaseView', {
     extend: 'Ext.grid.GridPanel',
     mixins: ['Proxmox.Mixin.CBind'],
 
     store: {
-        model: 'pve-ha-rules',
-        autoLoad: true,
+        model: 'pve-ha-rules-memory',
         cbind: {}, // empty cbind to ensure mixin iterates into filter array.
         filters: [
             {
@@ -47,7 +52,7 @@ Ext.define('PVE.ha.RulesBaseView', {
             throw 'no rule type given';
         }
 
-        let reloadStore = () => me.store.load();
+        let reloadStore = () => me.up('pveHARulesView').store.load();
 
         let sm = Ext.create('Ext.selection.RowModel', {});
 
@@ -176,6 +181,28 @@ Ext.define('PVE.ha.RulesView', {
         align: 'stretch',
     },
 
+    controller: {
+        xclass: 'Ext.app.ViewController',
+
+        init: function (view) {
+            view.store = new Ext.data.Store({
+                model: 'pve-ha-rules',
+                storeId: 'pve-ha-rules',
+                autoLoad: true,
+            });
+            view.store.on('load', this.onStoreLoad, this);
+        },
+
+        onStoreLoad: function (store, records, success) {
+            let me = this;
+            let view = me.getView();
+
+            for (const grid of view.query('grid[ruleType]')) {
+                grid.getStore().setRecords(records);
+            }
+        },
+    },
+
     items: [
         {
             title: gettext('HA Node Affinity Rules'),
-- 
2.47.2





More information about the pve-devel mailing list