all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Rusovac <d.rusovac@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Thomas Skinner <thomas@atskinner.net>
Subject: [PATCH pve-manager v4 2/4] fix #6144: ui: ha: status: allow toggling maintenance mode
Date: Fri, 13 Nov 2026 16:26:18 +0100	[thread overview]
Message-ID: <20261113152620.2662417-3-d.rusovac@proxmox.com> (raw)
In-Reply-To: <20261113152620.2662417-1-d.rusovac@proxmox.com>

maintenance mode could only be enabled or disabled through the HA
manager's CLI

add a 'Node Maintenance' menu to the HA status panel, which requests
enabling/disabling maintenance mode for the node of the selected lrm
entry

as the CRM only processes the request on its next round, show a
spinner on the lrm entry of the node and keep the menu disabled for
it until the status reports the requested state, like it is done when
disarming HA

enabling is not offered while HA is disarmed, as the CRM ignores such
requests in that state. menu is disabled for users lacking the
Sys.Modify privilege on nodes

the LRM also enters maintenance mode on shutdown with the 'migrate'
shutdown policy, which a disable request would not undo

'fa fa-check' icon was chosen for 'Disable' option to be consistent
with which icon a node gets when coming back from maintenance mode

Originally-by: Thomas Skinner <thomas@atskinner.net>
Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
---

Notes:
    changes since v3:
    * reword commit subject and body
    * move the menu into the HA status panel toolbar next to
      Arm/Disarm, using its view model and controller instead of a
      second toolbar
    * decide the offered action based on the maintenance-requested
      flag
    * update the state on selection changes and store loads, which
      also handles deselection
    * use complete sentences for translatable strings
    * show a spinner on the lrm entry while a maintenance request is
      processed, like for disarming HA
    * disable 'Enable' while HA is disarmed
    * check Sys.Modify on nodes, matching the endpoint

 www/manager6/ha/Status.js     | 102 ++++++++++++++++++++++++++++++++++
 www/manager6/ha/StatusView.js |  36 +++++++++++-
 2 files changed, 137 insertions(+), 1 deletion(-)

diff --git a/www/manager6/ha/Status.js b/www/manager6/ha/Status.js
index c01bd737..c040c1b2 100644
--- a/www/manager6/ha/Status.js
+++ b/www/manager6/ha/Status.js
@@ -11,6 +11,17 @@ Ext.define('PVE.ha.Status', {
     viewModel: {
         data: {
             haDisarmed: false,
+            maintenanceNode: null,
+            maintenanceRequested: false,
+            maintenancePending: false,
+        },
+        formulas: {
+            noMaintenanceAction: (get) =>
+                !get('maintenanceNode') ||
+                get('maintenancePending') ||
+                !Ext.state.Manager.get('GuiCap').nodes['Sys.Modify'],
+            // the CRM ignores requests to enable maintenance mode while HA is disarmed
+            noMaintenanceEnable: (get) => get('maintenanceRequested') || get('haDisarmed'),
         },
     },
 
@@ -52,6 +63,67 @@ Ext.define('PVE.ha.Status', {
             );
         },
 
+        updateMaintenanceState: function () {
+            let me = this;
+            let vm = me.getViewModel();
+            let sv = me.getView().down('pveHAStatusView');
+            let rec = sv.getSelection()[0];
+            let isLrm = rec?.get('type') === 'lrm';
+
+            vm.set('maintenanceNode', isLrm ? rec.get('node') : null);
+            vm.set('maintenanceRequested', isLrm && rec.get('maintenance-requested'));
+            vm.set('maintenancePending', isLrm && sv.isMaintenancePending(rec.get('node')));
+        },
+
+        handleMaintenanceButton: function (menuItem) {
+            let me = this;
+            let node = me.getViewModel().get('maintenanceNode');
+            if (!node) {
+                return;
+            }
+
+            let msg;
+            if (menuItem.maintenanceMode === 'disable') {
+                msg = Ext.String.format(
+                    gettext("Are you sure you want to disable maintenance mode for node '{0}'?"),
+                    node,
+                );
+                if (me.getViewModel().get('haDisarmed')) {
+                    msg +=
+                        '<br><br>' +
+                        Ext.String.format(
+                            gettext("HA resources will be migrated back to node '{0}' once HA is re-armed."),
+                            node,
+                        );
+                }
+            } else {
+                msg = Ext.String.format(
+                    gettext("Are you sure you want to enable maintenance mode for node '{0}'?"),
+                    node,
+                );
+                msg +=
+                    '<br><br>' +
+                    gettext('HA resources on the node will be migrated to other nodes.');
+            }
+
+            Ext.Msg.confirm(gettext('Confirm'), msg, function (btn) {
+                if (btn !== 'yes') {
+                    return;
+                }
+                Proxmox.Utils.API2Request({
+                    url: `/nodes/${node}/maintenance`,
+                    params: { 'maintenance-mode': menuItem.maintenanceMode },
+                    method: 'PUT',
+                    success: function () {
+                        let sv = me.getView().down('pveHAStatusView');
+                        sv.setMaintenancePending(node, menuItem.maintenanceMode === 'enable');
+                        me.updateMaintenanceState();
+                    },
+                    failure: (response) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+                });
+            });
+        },
+
         openCRSOptions: function () {
             Ext.create('PVE.form.CRSOptions', {
                 autoShow: true,
@@ -121,6 +193,34 @@ Ext.define('PVE.ha.Status', {
                 },
             ],
         },
+        '-',
+        {
+            text: gettext('Node Maintenance'),
+            iconCls: 'fa fa-wrench',
+            bind: {
+                disabled: '{noMaintenanceAction}',
+            },
+            menu: [
+                {
+                    text: gettext('Enable'),
+                    iconCls: 'fa fa-wrench',
+                    maintenanceMode: 'enable',
+                    bind: {
+                        disabled: '{noMaintenanceEnable}',
+                    },
+                    handler: 'handleMaintenanceButton',
+                },
+                {
+                    text: gettext('Disable'),
+                    iconCls: 'fa fa-check',
+                    maintenanceMode: 'disable',
+                    bind: {
+                        disabled: '{!maintenanceRequested}',
+                    },
+                    handler: 'handleMaintenanceButton',
+                },
+            ],
+        },
         '->',
         {
             text: gettext('CRS Settings'),
@@ -153,11 +253,13 @@ Ext.define('PVE.ha.Status', {
                 collapsible: true,
                 padding: '0 0 20 0',
                 listeners: {
+                    selectionchange: () => me.getController().updateMaintenanceState(),
                     hastatuschange: function (isDisarmed) {
                         let vm = me.getViewModel();
                         let sv = me.query('pveHAStatusView')[0];
 
                         vm.set('haDisarmed', isDisarmed);
+                        me.getController().updateMaintenanceState();
 
                         if (sv.isDisarmedPendingState === null) {
                             return;
diff --git a/www/manager6/ha/StatusView.js b/www/manager6/ha/StatusView.js
index f260bc0d..5e8f001e 100644
--- a/www/manager6/ha/StatusView.js
+++ b/www/manager6/ha/StatusView.js
@@ -23,6 +23,19 @@ Ext.define(
             me.getView().refresh();
         },
 
+        // maps node names to the expected value of their maintenance-requested field
+        maintenancePending: null,
+
+        setMaintenancePending: function (node, requested) {
+            let me = this;
+            me.maintenancePending[node] = requested;
+            me.getView().refresh();
+        },
+
+        isMaintenancePending: function (node) {
+            return this.maintenancePending[node] !== undefined;
+        },
+
         initComponent: function () {
             var me = this;
 
@@ -30,6 +43,8 @@ Ext.define(
                 throw 'no rstore given';
             }
 
+            me.maintenancePending = {};
+
             Proxmox.Utils.monStoreErrors(me, me.rstore);
 
             var store = Ext.create('Proxmox.data.DiffStore', {
@@ -52,6 +67,18 @@ Ext.define(
             });
 
             me.rstore.on('load', function () {
+                let maintenanceDone = false;
+                for (const [node, requested] of Object.entries(me.maintenancePending)) {
+                    let rec = store.getById(`lrm:${node}`);
+                    if (!rec || rec.get('maintenance-requested') === requested) {
+                        delete me.maintenancePending[node];
+                        maintenanceDone = true;
+                    }
+                }
+                if (maintenanceDone) {
+                    me.getView().refresh();
+                }
+
                 let fencing = store.findRecord('type', 'fencing');
                 let disarmed = fencing && fencing.get('armed-state') === 'disarmed';
 
@@ -76,7 +103,10 @@ Ext.define(
                         flex: 1,
                         dataIndex: 'status',
                         renderer: function (value, _metaData, rec) {
-                            if (rec.data.type === 'fencing' && me.pending) {
+                            if (
+                                (rec.data.type === 'fencing' && me.pending) ||
+                                (rec.data.type === 'lrm' && me.isMaintenancePending(rec.data.node))
+                            ) {
                                 return value + ' <i class="fa fa-spinner fa-spin"></i>';
                             }
                             return value;
@@ -132,6 +162,10 @@ Ext.define(
                     },
                 },
                 'armed-state',
+                {
+                    name: 'maintenance-requested',
+                    type: 'boolean',
+                },
             ],
             idProperty: 'id',
         });
-- 
2.47.3





  parent reply	other threads:[~2026-11-13 15:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 15:26 [PATCH-SERIES docs/ha-manager/manager v4 0/4] fix #6144: add api and ui for node maintenance mode Dominik Rusovac
2026-11-13 15:26 ` [PATCH pve-manager v4 1/4] api: nodes: add endpoint to set " Dominik Rusovac
2026-11-16 11:57   ` Daniel Kral
2026-11-17  8:58     ` Dominik Rusovac
2026-11-17  9:21       ` Daniel Kral
2026-11-17  9:40         ` Dominik Rusovac
2026-11-13 15:26 ` Dominik Rusovac [this message]
2026-11-17  9:07   ` [PATCH pve-manager v4 2/4] fix #6144: ui: ha: status: allow toggling " Daniel Kral
2026-11-17 11:02     ` Dominik Rusovac
2026-11-13 15:26 ` [PATCH pve-ha-manager v4 3/4] api: status: report node maintenance request for lrm entries Dominik Rusovac
2026-11-16 12:02   ` Daniel Kral
2026-11-13 15:26 ` [PATCH pve-docs v4 4/4] ha-manager: maintenance mode: mention web ui menu Dominik Rusovac
2026-11-19 10:05 ` [PATCH-SERIES docs/ha-manager/manager v4 0/4] fix #6144: add api and ui for node maintenance mode Dominik Rusovac

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=20261113152620.2662417-3-d.rusovac@proxmox.com \
    --to=d.rusovac@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=thomas@atskinner.net \
    /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