[pve-devel] [PATCH ha-manager v2] allow empty json status files

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Jul 18 14:02:42 CEST 2016


Else we crash fatally on an existing but empty status file like
/etc/pve/manager_status , reproducible with:
$ > /etc/pve/ha/manager_status

We do not want to catch arbitrary errors as then users cannot
reconstruct what happened in the event of an error.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

changes since v1:
* do not catch arbitrary errors, just empty files.
  arbitrary error should happen only in development and there its more usefull
  to not overwrite the file and crash instead, so that the culprit may be found.

 src/PVE/HA/Config.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index c9aa8a5..00b338d 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -38,7 +38,7 @@ cfs_register_file($ha_fence_config,
 sub json_reader {
     my ($filename, $data) = @_;
 
-    return defined($data) ? decode_json($data) : {};
+    return defined($data) && length($data) > 0 ? decode_json($data) : {};
 }
 
 sub json_writer {
-- 
2.1.4




More information about the pve-devel mailing list