all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC ha-manager 5/7] pve2 env: validate shutdown policy from override file
Date: Fri, 16 Jun 2023 13:33:42 +0200	[thread overview]
Message-ID: <20230616113345.65996-7-f.ebner@proxmox.com> (raw)
In-Reply-To: <20230616113345.65996-1-f.ebner@proxmox.com>

for future-proofing.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

Not sure if this is worth it.

(Build-)dependency bump for libpve-cluster-perl needed

 src/PVE/HA/Env/PVE2.pm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/PVE/HA/Env/PVE2.pm b/src/PVE/HA/Env/PVE2.pm
index 6a75bd4..6eb4aa7 100644
--- a/src/PVE/HA/Env/PVE2.pm
+++ b/src/PVE/HA/Env/PVE2.pm
@@ -12,6 +12,7 @@ use PVE::Tools;
 use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_write_file cfs_lock_file);
 use PVE::DataCenterConfig;
 use PVE::INotify;
+use PVE::JSONSchema;
 use PVE::RPCEnvironment;
 
 use PVE::HA::Tools ':exit_codes';
@@ -463,7 +464,17 @@ sub get_datacenter_settings {
     $self->log('warning', "error reading shutdown policy override from $sp_override_fn - $@") if $@;
 
     my $overrides = {};
-    $overrides->{ha}->{shutdown_policy} = $shutdown_policy_override if $shutdown_policy_override;
+
+    if ($shutdown_policy_override) {
+	eval {
+	    PVE::JSONSchema::validate(
+		$shutdown_policy_override,
+		PVE::JSONSchema::get_standard_option('pve-ha-shutdown-policy'),
+	    );
+	    $overrides->{ha}->{shutdown_policy} = $shutdown_policy_override;
+	};
+	$self->log('warning', "error validating shutdown policy override - $@") if $@;
+    }
 
     return {
 	ha => $datacenterconfig->{ha} // {},
-- 
2.39.2





  parent reply	other threads:[~2023-06-16 11:34 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 ` Fiona Ebner [this message]
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

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=20230616113345.65996-7-f.ebner@proxmox.com \
    --to=f.ebner@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 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