From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 33CEF1FF0AA for ; Tue, 17 Nov 2026 12:02:26 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 8C401215C2; Tue, 17 Nov 2026 12:02:25 +0100 (CET) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 17 Nov 2026 12:02:15 +0100 Message-Id: Subject: Re: [PATCH pve-manager v4 2/4] fix #6144: ui: ha: status: allow toggling maintenance mode From: "Dominik Rusovac" To: "Daniel Kral" , X-Mailer: aerc 0.20.0 References: <20261113152620.2662417-1-d.rusovac@proxmox.com> <20261113152620.2662417-3-d.rusovac@proxmox.com> In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794913335246 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: R4AWFLGKFTDV6YRGPXZVETSZH2MJYSS6 X-Message-ID-Hash: R4AWFLGKFTDV6YRGPXZVETSZH2MJYSS6 X-MailFrom: d.rusovac@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Thomas Skinner X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: thx for your review! will make the changes in v5 On Tue Nov 17, 2026 at 10:07 AM CET, Daniel Kral wrote: > On Fri Nov 13, 2026 at 4:26 PM CET, Dominik Rusovac wrote: >> maintenance mode could only be enabled or disabled through the HA >> manager's CLI >> [snip] >> 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, > > nit: 'selectedNode' describes the content a bit better; maybe even > 'selectedLrmNode' > ack, will go with 'selectedLrmNode' >> + maintenanceRequested: false, >> + maintenancePending: false, > > These are also only true for the selectedLrmNode... But prefixing this > would get rather long, so maybe just a comment, so it's clear? true, will add a comment above the fields > >> + }, >> + formulas: { >> + noMaintenanceAction: (get) =3D> >> + !get('maintenanceNode') || >> + get('maintenancePending') || >> + !Ext.state.Manager.get('GuiCap').nodes['Sys.Modify'], > > AFAIK the formula will never update if the GuiCap changes, because > formulas are only updated by get()'ing view model data... > > Though this is probably very minor, because the GuiCaps are only set > roughly whenever the user logins. And if a user logs out and logs back > in again in the same session, this component seems to be reloaded anyway > and therefore the formula is reevaluated as well. > thx for the heads up afaict this is consistent with the rest of the codebase, so I'd keep it as is >> + // the CRM ignores requests to enable maintenance mode whil= e HA is disarmed >> + noMaintenanceEnable: (get) =3D> get('maintenanceRequested')= || get('haDisarmed'), >> }, >> }, >> =20 >> @@ -52,6 +63,67 @@ Ext.define('PVE.ha.Status', { >> ); >> }, >> =20 >> + updateMaintenanceState: function () { >> + let me =3D this; >> + let vm =3D me.getViewModel(); >> + let sv =3D me.getView().down('pveHAStatusView'); >> + let rec =3D sv.getSelection()[0]; >> + let isLrm =3D rec?.get('type') =3D=3D=3D 'lrm'; >> + >> + vm.set('maintenanceNode', isLrm ? rec.get('node') : null); >> + vm.set('maintenanceRequested', isLrm && rec.get('maintenanc= e-requested')); >> + vm.set('maintenancePending', isLrm && sv.isMaintenancePendi= ng(rec.get('node'))); >> + }, >> + >> + handleMaintenanceButton: function (menuItem) { > > AFAIK the handlers for tbar items have the signature > > function (menuItem, event, record) {} > > i.e., record would already contain the currently selected status grid > item, which would then just need to be checked against whether it is an > LRM. > > However, since these are already used to check whether the button should > be disabled/enabled at all, it seems better to stick with the current > solution. ack, thx for the context, keeping it then > > Unfortunately, I didn't find the documentation (the tbar property is > just documented as Object|Object[] in the ExtJS documentation ;-)), but > we use it in some parts of our codebase. > >> + let me =3D this; >> + let node =3D me.getViewModel().get('maintenanceNode'); >> + if (!node) { >> + return; >> + } >> + >> + let msg; >> + if (menuItem.maintenanceMode =3D=3D=3D 'disable') { >> + msg =3D Ext.String.format( >> + gettext("Are you sure you want to disable maintenan= ce mode for node '{0}'?"), >> + node, >> + ); > > nit: could probably be factored out with another gettext parameter for > maintenanceMode being either 'disable' or 'enable'. > the use of complete sentences for translatable strings is deliberate here >> + if (me.getViewModel().get('haDisarmed')) { >> + msg +=3D >> + '

' + >> + Ext.String.format( >> + gettext("HA resources will be migrated back= to node '{0}' once HA is re-armed."), >> + node, >> + ); >> + } >> + } else { > > } else if (menuItem.maintenanceMode =3D=3D=3D 'enable') { > ack, thx >> + msg =3D Ext.String.format( >> + gettext("Are you sure you want to enable maintenanc= e mode for node '{0}'?"), >> + node, >> + ); >> + msg +=3D >> + '

' + >> + gettext('HA resources on the node will be migrated = to other nodes.'); >> + } > > } else { > throw "Invalid maintenance mode '...'"; > } > > or something similar, so when another maintenance mode is added in the > GUI this will be apparent on clicking it the first time. > ack, good point, thx [snip] >> 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(); >> }, >> =20 >> + // maps node names to the expected value of their maintenance-r= equested field >> + maintenancePending: null, > > This should already be initialized with {} > ack [snip] >> =20 >> me.rstore.on('load', function () { >> + let maintenanceDone =3D false; > > nit: `maintenanceRequestAccepted` would be more accurate > not sure, but I agree that renaming makes sense would go with `pendingCleared`=20 >> + for (const [node, requested] of Object.entries(me.maint= enancePending)) { >> + let rec =3D store.getById(`lrm:${node}`); >> + if (!rec || rec.get('maintenance-requested') =3D=3D= =3D requested) { >> + delete me.maintenancePending[node]; >> + maintenanceDone =3D true; >> + } >> + } > > Found by automated review: the maintenancePending should also be removed > if something hinders the maintenance request landing in the > manager_status, e.g., LRM is already disarmed or offline. > > Even though the API handler can error and then take the error path, > that's still racy because the disarm or offline node could just happen > in the same exact HA Manager round... So this should be either handled > additionally or check some other way whether the maintenance request is > still pending. > I'm planning on making the HA status report for lrm entries whether a maintenance request is still queued=20 will add a local pending state to the UI to cover the gap between status polls, so it shows the spinner while the request is queued; also across page reloads [snip]