all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] applied: [PATCH manager] ha: affinity rules: use single data store and mirror it to child grids
Date: Sat,  2 Aug 2025 19:26:19 +0200	[thread overview]
Message-ID: <20250802172619.3692858-2-t.lamprecht@proxmox.com> (raw)

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@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



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

                 reply	other threads:[~2025-08-02 17:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250802172619.3692858-2-t.lamprecht@proxmox.com \
    --to=t.lamprecht@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal