[pve-devel] [RFC ha-manager 5/7] pve2 env: validate shutdown policy from override file
Fiona Ebner
f.ebner at proxmox.com
Fri Jun 16 13:33:42 CEST 2023
for future-proofing.
Signed-off-by: Fiona Ebner <f.ebner at 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
More information about the pve-devel
mailing list