[pve-devel] [PATCH manager v2 1/2] add api setter for node maintenance mode
Daniel Kral
d.kral at proxmox.com
Thu Oct 2 13:47:19 CEST 2025
Only two small notes inline, otherwise looks good to me, also if we
support putting the node itself in maintenance or need other maintenance
mode than just enabling/disabling them.
On Sat Sep 20, 2025 at 8:20 PM CEST, Thomas Skinner wrote:
> Signed-off-by: Thomas Skinner <thomas at atskinner.net>
> ---
> PVE/API2/Nodes.pm | 38 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
> index 48898045..3f31ac6c 100644
> --- a/PVE/API2/Nodes.pm
> +++ b/PVE/API2/Nodes.pm
> @@ -275,6 +275,7 @@ __PACKAGE__->register_method({
> { name => 'hosts' },
> { name => 'journal' },
> { name => 'lxc' },
> + { name => 'maintenance' },
> { name => 'migrateall' },
> { name => 'netstat' },
> { name => 'network' },
> @@ -2663,6 +2664,43 @@ __PACKAGE__->register_method({
> },
> });
>
> +__PACKAGE__->register_method({
> + name => 'maintenance_set',
> + protected => 1,
> + path => 'maintenance',
> + method => 'PUT',
> + description =>
> + "Set the maintenance parameters for the node. Currently only supports HA maintenance mode for the LRM on a node.",
> + permissions => {
> + check => ['perm', '/', ['Sys.Console']],
Hm, if we align that API endpoint to the PBS datastore's one (where
there is also a enumerated maintenande mode), then this should probably
be
check => ['perm', '/nodes/{node}', ['Sys.Modify']],
There's also 'Sys.PowerMgmt', but I don't really see this as a power
management-related thing.
> + },
> + parameters => {
> + additionalProperties => 0,
> + properties => {
> + node => get_standard_option('pve-node'),
> + 'maintenance-mode' => {
> + description => "Enables or disabled maintenance mode for the HA LRM.",
nit: s/disabled/disables/
> + type => 'string',
> + enum => ['enable', 'disable'],
> + },
> + },
> + },
> + returns => { type => 'null' },
> + code => sub {
> + my ($param) = @_;
> +
> + PVE::Cluster::check_node_exists($param->{node});
> +
> + my $cmd =
> + $param->{'maintenance-mode'} eq 'enable'
> + ? 'enable-node-maintenance'
> + : 'disable-node-maintenance';
> + PVE::HA::Config::queue_crm_commands("$cmd $param->{node}");
> +
> + return undef;
> + },
> +});
> +
More information about the pve-devel
mailing list