public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH manager 1/1] api: nodes: allow setting HA shutdown policy during shutdown/reboot
Date: Tue, 20 Jun 2023 10:35:48 +0200	[thread overview]
Message-ID: <1687250028.wwgk7kylta.astroid@yuna.none> (raw)
In-Reply-To: <20230616113345.65996-10-f.ebner@proxmox.com>

On June 16, 2023 1:33 pm, Fiona Ebner wrote:
> Increases flexibility/user-friendliness.
> 
> Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
> 
> (Build-)dependency bump for libpve-cluster-perl needed.
> 
> Dependency bump for ha-manager needed (to have the runtime dir exist
> and LRM honor the new param).
> 
>  PVE/API2/Nodes.pm | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
> index 9269694d..1cb83af5 100644
> --- a/PVE/API2/Nodes.pm
> +++ b/PVE/API2/Nodes.pm
> @@ -8,7 +8,7 @@ use Digest::SHA;
>  use Filesys::Df;
>  use HTTP::Status qw(:constants);
>  use JSON;
> -use POSIX qw(LONG_MAX);
> +use POSIX qw(ENOENT LONG_MAX);
>  use Time::Local qw(timegm_nocheck);
>  use Socket;
>  use IO::Socket::SSL;
> @@ -557,12 +557,21 @@ __PACKAGE__->register_method({
>  		type => 'string',
>  		enum => [qw(reboot shutdown)],
>  	    },
> +	    'shutdown-policy' => get_standard_option('pve-ha-shutdown-policy', { optional => 1 }),
>  	},
>      },
>      returns => { type => "null" },
>      code => sub {
>  	my ($param) = @_;
>  
> +	my $sp_override_fn = '/run/pve-ha-lrm/shutdown-policy.local-override';
> +	if ($param->{'shutdown-policy'}) {
> +	    eval { PVE::Tools::file_set_contents($sp_override_fn, $param->{'shutdown-policy'}); };
> +	    die "could not write shutdown policy override to $sp_override_fn - $@" if $@;
> +	} else {
> +	    unlink $sp_override_fn or $! == ENOENT or die "unable to remove $sp_override_fn - $!";
> +	}

should this part (setting or removing the override if one is set)
require `Sys.Modify` (like setting the policy via datacenter.cfg would)
in addition to `Sys.PowerMgmt` that the endpoint itself requires?

> +
>  	if ($param->{command} eq 'reboot') {
>  	    system ("(sleep 2;/sbin/reboot)&");
>  	} elsif ($param->{command} eq 'shutdown') {
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




      reply	other threads:[~2023-06-20  8:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-16 11:33 [pve-devel] [PATCH-SERIES cluster/(ha-)manager] allow node HA shutdown policy override Fiona Ebner
2023-06-16 11:33 ` [pve-devel] [PATCH cluster 1/1] datacenter config: turn shutdown policy into a standard option Fiona Ebner
2023-06-16 12:47   ` [pve-devel] applied: " Thomas Lamprecht
2023-06-16 11:33 ` [pve-devel] [PATCH ha-manager 1/7] lrm service: add runtime directory Fiona Ebner
2023-06-16 11:33 ` [pve-devel] [RFC ha-manager 2/7] lrm service: move PID file to service's " Fiona Ebner
2023-06-16 11:33 ` [pve-devel] [PATCH ha-manager 3/7] pve2 env: get shutdown policy override set by node's shutdown API endpoint Fiona Ebner
2023-06-16 11:33 ` [pve-devel] [PATCH ha-manager 4/7] lrm: honor " Fiona Ebner
2023-06-16 11:33 ` [pve-devel] [RFC ha-manager 5/7] pve2 env: validate shutdown policy from override file Fiona Ebner
2023-06-16 11:33 ` [pve-devel] [PATCH ha-manager 6/7] sim env: add support for datacenter config overrides Fiona Ebner
2023-06-16 11:33 ` [pve-devel] [PATCH ha-manager 7/7] tests: add test for shutdown policy override Fiona Ebner
2023-06-16 11:33 ` [pve-devel] [PATCH manager 1/1] api: nodes: allow setting HA shutdown policy during shutdown/reboot Fiona Ebner
2023-06-20  8:35   ` Fabian Grünbichler [this message]

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=1687250028.wwgk7kylta.astroid@yuna.none \
    --to=f.gruenbichler@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 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