* [pve-devel] [RFC pve-manager 1/1] add ha node maintenance mode to the UI and API
[not found] <20250602161052.170879-1-joao.sousa@eurotux.com>
@ 2025-06-02 16:10 ` Tiago Sousa via pve-devel
[not found] ` <20250602161052.170879-2-joao.sousa@eurotux.com>
1 sibling, 0 replies; 2+ messages in thread
From: Tiago Sousa via pve-devel @ 2025-06-02 16:10 UTC (permalink / raw)
To: pve-devel; +Cc: Tiago Sousa
[-- Attachment #1: Type: message/rfc822, Size: 8418 bytes --]
From: Tiago Sousa <joao.sousa@eurotux.com>
To: pve-devel@lists.proxmox.com
Subject: [RFC pve-manager 1/1] add ha node maintenance mode to the UI and API
Date: Mon, 2 Jun 2025 17:10:52 +0100
Message-ID: <20250602161052.170879-2-joao.sousa@eurotux.com>
Signed-off-by: Tiago Sousa <joao.sousa@eurotux.com>
---
PVE/API2/Nodes.pm | 45 ++++++++++++++++++++++++++++++++++++
www/manager6/Utils.js | 1 +
| 36 +++++++++++++++++++++++++++--
3 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 791d2dec..f2365e59 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -21,6 +21,7 @@ use PVE::DataCenterConfig;
use PVE::Exception qw(raise raise_perm_exc raise_param_exc);
use PVE::Firewall;
use PVE::HA::Config;
+use PVE::HA::Usage;
use PVE::HA::Env::PVE2;
use PVE::INotify;
use PVE::JSONSchema qw(get_standard_option);
@@ -300,6 +301,7 @@ __PACKAGE__->register_method ({
{ name => 'vncshell' },
{ name => 'vzdump' },
{ name => 'wakeonlan' },
+ { name => 'node-maintenance-set' },
];
push @$result, { name => 'sdn' } if $have_sdn;
@@ -802,6 +804,49 @@ __PACKAGE__->register_method({
return $wol_config->{mac};
}});
+__PACKAGE__->register_method({
+ name => 'node-maintenance-set',
+ path => 'node-maintenance-set',
+ method => 'POST',
+ permissions => {
+ check => ['perm', '/nodes/{node}', [ 'Sys.PowerMgmt' ]],
+ },
+ protected => 1,
+ description => "Set node maintenance mode (enable or disable)",
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ disable => {
+ description => "Requests disabling or enabling maintenance-mode.",
+ type => 'boolean',
+ },
+ },
+ },
+ returns => {
+ type => 'string',
+ format => 'string',
+ description => '',
+ },
+ code => sub {
+ my ($param) = @_;
+ my $node = $param->{node};
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+
+ PVE::Cluster::check_node_exists($node);
+ my $state = $param->{disable} ? 'disable' : 'enable';
+ my $hacmd = sub {
+ my $upid = shift;
+ print "Requesting to $state HA node maintenance for node $node\n";
+ my $cmd = ['ha-manager', 'crm-command', 'node-maintenance', $state, $node];
+ PVE::Tools::run_command($cmd);
+ return;
+ };
+
+ return $rpcenv->fork_worker('hamaintenance', undef, $authuser, $hacmd);
+ }});
+
__PACKAGE__->register_method({
name => 'rrd',
path => 'rrd',
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 1f6778cd..48dac090 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -2034,6 +2034,7 @@ Ext.define('PVE.Utils', {
hamigrate: ['HA', gettext('Migrate')],
hashutdown: ['HA', gettext('Shutdown')],
hastart: ['HA', gettext('Start')],
+ hamaintenance: ['HA', gettext('Node Maintenance')],
hastop: ['HA', gettext('Stop')],
imgcopy: ['', gettext('Copy data')],
imgdel: ['', gettext('Erase data')],
--git a/www/manager6/node/CmdMenu.js b/www/manager6/node/CmdMenu.js
index 7bdfebc5..0a8dc008 100644
--- a/www/manager6/node/CmdMenu.js
+++ b/www/manager6/node/CmdMenu.js
@@ -94,6 +94,34 @@ Ext.define('PVE.node.CmdMenu', {
PVE.Utils.openDefaultConsoleWindow(true, 'shell', undefined, nodename, undefined);
},
},
+ {
+ text: gettext('Enter Maintenance Mode'),
+ itemId: 'entermaintenance',
+ iconCls: 'fa fa-fw fa-building',
+ handler: function() {
+ let nodename = this.up('menu').nodename;
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${nodename}/node-maintenance-set`,
+ params: { disable: 0 },
+ method: 'POST',
+ failure: (response, opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+ });
+ },
+ },
+ {
+ text: gettext('Exit Maintenance Mode'),
+ itemId: 'exitmaintenance',
+ iconCls: 'fa fa-fw fa-building',
+ handler: function() {
+ let nodename = this.up('menu').nodename;
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${nodename}/node-maintenance-set`,
+ params: { disable: 1 },
+ method: 'POST',
+ failure: (response, opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+ });
+ },
+ },
{ xtype: 'menuseparator' },
{
text: gettext('Wake-on-LAN'),
@@ -150,11 +178,15 @@ Ext.define('PVE.node.CmdMenu', {
}
if (!caps.nodes['Sys.Console']) {
me.getComponent('shell').setDisabled(true);
- }
+ }
+ if (me.pveSelNode.data.hastate === 'maintenance') {
+ me.getComponent('entermaintenance').setVisible(false);
+ } else {
+ me.getComponent('exitmaintenance').setVisible(false);
+ }
if (me.pveSelNode.data.running) {
me.getComponent('wakeonlan').setDisabled(true);
}
-
if (PVE.Utils.isStandaloneNode()) {
me.getComponent('bulkmigrate').setVisible(false);
}
--
2.39.5
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [pve-devel] [RFC pve-manager 1/1] add ha node maintenance mode to the UI and API
[not found] ` <20250602161052.170879-2-joao.sousa@eurotux.com>
@ 2025-06-03 6:35 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2025-06-03 6:35 UTC (permalink / raw)
To: Tiago Sousa, pve-devel
Am 02.06.25 um 18:10 schrieb Tiago Sousa:
> Signed-off-by: Tiago Sousa <joao.sousa@eurotux.com>
> ---
> PVE/API2/Nodes.pm | 45 ++++++++++++++++++++++++++++++++++++
Thanks for your patch, some high level comment:
As the API touches HA it should also go into the pve-ha-manager repo, there it
could directly check the current state, and queue a CRM command directly, without
using run_command.
I'd also place the UI there in the HA overview, as its IMO required for the admin
to check the current HA stack's state before scheduling anything here.
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-03 6:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20250602161052.170879-1-joao.sousa@eurotux.com>
2025-06-02 16:10 ` [pve-devel] [RFC pve-manager 1/1] add ha node maintenance mode to the UI and API Tiago Sousa via pve-devel
[not found] ` <20250602161052.170879-2-joao.sousa@eurotux.com>
2025-06-03 6:35 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal