From e6652bd08aa1b904d5f2752564b569f3d37cff85 Mon Sep 17 00:00:00 2001 From: Michal Opala Date: Wed, 1 Mar 2023 13:19:30 +0100 Subject: [PATCH] F #6029: Normalize exit codes for rsync backup actions (#2535) Possible fix for "Message received: BACKUP SUCCESS 96 -" (?) --- src/datastore_mad/remotes/rsync/backup | 6 ++++-- src/datastore_mad/remotes/rsync/stat | 14 +++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/datastore_mad/remotes/rsync/backup b/src/datastore_mad/remotes/rsync/backup index 738c21f5ae..e7faced565 100755 --- a/src/datastore_mad/remotes/rsync/backup +++ b/src/datastore_mad/remotes/rsync/backup @@ -91,7 +91,7 @@ begin ds = TransferManager::Datastore.new(:ds_xml => ds_xml) rescue StandardError => e STDERR.puts e.message - exit(1) + exit(-1) end path = Pathname.new(base).cleanpath.to_s @@ -139,4 +139,6 @@ if rc.code != 0 || rc.stdout.empty? exit(-1) end -puts "#{backup_id} #{rc.stdout.split[0]}" +STDOUT.puts "#{backup_id} #{rc.stdout.split[0]}" + +exit(0) diff --git a/src/datastore_mad/remotes/rsync/stat b/src/datastore_mad/remotes/rsync/stat index 7700671c55..0bcb769d0e 100755 --- a/src/datastore_mad/remotes/rsync/stat +++ b/src/datastore_mad/remotes/rsync/stat @@ -82,7 +82,7 @@ begin if !diskid STDERR.puts "Wrong format for disk filename #{parts[2]}" - exit(1) + exit(-1) end last_snap = parts[1].split(',')[-1].split(':')[-1] @@ -90,7 +90,7 @@ begin cmd = "cat #{base_path}#{last_snap}/vm.xml" rescue StandardError => e STDERR.puts e.message - exit(1) + exit(-1) end rc = TransferManager::Action.ssh('gather_vm_xml', @@ -102,7 +102,7 @@ rc = TransferManager::Action.ssh('gather_vm_xml', if rc.code != 0 STDERR.puts rc.stderr - exit(1) + exit(-1) end vm = REXML::Document.new(Base64.decode64(rc.stdout)).root @@ -113,16 +113,16 @@ disk = vm.elements[xpath] if !disk STDERR.puts "Cannot find disk #{diskid[1]} in VM backup info" - exit(1) + exit(-1) end size = disk.elements['//SIZE'] if !size STDERR.puts "Cannot find size for disk #{diskid[1]} in VM backup info" - exit(1) + exit(-1) end -puts size.text +STDOUT.puts size.text -exit 0 +exit(0)